/* ================================================
   Targeto Dashboard Layout - Unified Client Zone
   Modern 2025 Design with Collapsible Sidebar
   ================================================ */

/* CSS Variables for Dashboard */
:root {
  --sidebar-width: 212px;
  --sidebar-collapsed-width: 56px;
  --sidebar-bg: rgba(255, 255, 255, 0.7);
  --sidebar-border: rgba(37, 99, 235, 0.08);
  --sidebar-text: #64748b;
  --sidebar-text-active: #1d4ed8;
  --sidebar-hover-bg: rgba(37, 99, 235, 0.05);
  --sidebar-active-bg: rgba(37, 99, 235, 0.08);
  --sidebar-active-border: transparent;
  --topbar-height: 44px;
  --transition-speed: 300ms;
  --transition-ease: cubic-bezier(0.4, 0, 0.2, 1);
  --bottom-tab-height: 52px;
  --safe-area-top: env(safe-area-inset-top, 0px);
}

/* Dashboard Layout Container */
.dashboard-layout {
  display: flex;
  min-height: 100vh;
  background: #f8fafc;
}

/* ================================================
   Sidebar Styles
   ================================================ */
.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  width: var(--sidebar-width);
  height: 100vh;
  background: var(--sidebar-bg);
  backdrop-filter: saturate(180%) blur(40px);
  -webkit-backdrop-filter: saturate(180%) blur(40px);
  border-right: 1px solid var(--sidebar-border);
  display: flex;
  flex-direction: column;
  transition: width var(--transition-speed) var(--transition-ease), transform var(--transition-speed) var(--transition-ease);
  z-index: 1000;
  overflow: visible;
}

.sidebar.collapsed {
  width: var(--sidebar-collapsed-width);
}

/* Sidebar Header */
.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 12px;
  border-bottom: 1px solid var(--sidebar-border);
  min-height: 44px;
  position: relative;
}

.sidebar.collapsed .sidebar-header {
  justify-content: center;
  padding: 12px 8px;
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
  overflow: hidden;
}

.sidebar-logo-icon {
  width: 30px;
  height: 30px;
  min-width: 30px;
  background: linear-gradient(135deg, #2563eb 0%, #60a5fa 100%);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.sidebar-logo-icon svg {
  width: 18px;
  height: 18px;
  color: white;
}

.sidebar-logo-img {
  width: 38px;
  height: 38px;
  min-width: 38px;
  border-radius: 10px;
  object-fit: cover;
}

.sidebar-logo-text {
  font-size: 17px;
  font-weight: 700;
  color: #1e293b;
  white-space: nowrap;
  opacity: 1;
  transition: opacity var(--transition-speed) var(--transition-ease);
  letter-spacing: -0.02em;
}

.sidebar-logo-text .logo-pro {
  font-size: 9px;
  margin-top: 1px;
  background: linear-gradient(135deg, #ea580c 0%, #f97316 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.sidebar.collapsed .sidebar-logo-text {
  opacity: 0;
  width: 0;
}

/* Sidebar Toggle Button */
.sidebar-toggle {
  width: 24px;
  height: 24px;
  min-width: 24px;
  border: none;
  background: rgba(37, 99, 235, 0.08);
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition-speed) var(--transition-ease);
}

.sidebar-toggle:hover {
  background: rgba(37, 99, 235, 0.15);
}

.sidebar-toggle svg {
  width: 14px;
  height: 14px;
  color: #2563eb;
  transition: transform var(--transition-speed) var(--transition-ease);
}

/* Collapsed state: toggle button outside sidebar */
.sidebar.collapsed .sidebar-toggle {
  position: absolute;
  right: -14px;
  top: 50%;
  transform: translateY(-50%);
  background: linear-gradient(135deg, #2563eb 0%, #60a5fa 100%);
  border-radius: 50%;
  width: 24px;
  height: 24px;
  box-shadow: 0 2px 8px rgba(37, 99, 235, 0.4);
  z-index: 10;
}

.sidebar.collapsed .sidebar-toggle:hover {
  background: linear-gradient(135deg, #1d4ed8 0%, #2563eb 100%);
  transform: translateY(-50%) scale(1.1);
}

.sidebar.collapsed .sidebar-toggle svg {
  transform: rotate(180deg);
  color: white;
}

/* Sidebar Navigation */
.sidebar-nav {
  flex: 1;
  padding: 8px 0;
  overflow-y: auto;
  overflow-x: hidden;
}

.sidebar-nav::-webkit-scrollbar {
  width: 4px;
}

.sidebar-nav::-webkit-scrollbar-track {
  background: transparent;
}

.sidebar-nav::-webkit-scrollbar-thumb {
  background: rgba(37, 99, 235, 0.15);
  border-radius: 2px;
}

/* Menu Section */
.menu-section {
  margin-bottom: 10px;
}

.menu-section-title {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #2563eb;
  padding: 0 16px;
  margin-bottom: 4px;
  white-space: nowrap;
  overflow: hidden;
  opacity: 0.7;
  transition: opacity var(--transition-speed) var(--transition-ease);
}

.sidebar.collapsed .menu-section-title {
  opacity: 0;
}

/* Menu Items */
.menu-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 5px 10px;
  margin: 1px 8px 1px 6px;
  color: var(--sidebar-text);
  text-decoration: none;
  font-size: 13px;
  font-weight: 500;
  border-radius: 6px;
  transition: all var(--transition-speed) var(--transition-ease);
  white-space: nowrap;
  position: relative;
}

.menu-item:hover {
  background: var(--sidebar-hover-bg);
  color: var(--sidebar-text-active);
  transform: translateX(2px);
}

.menu-item.active {
  background: linear-gradient(135deg, rgba(37, 99, 235, 0.1), rgba(37, 99, 235, 0.08));
  color: var(--sidebar-text-active);
  box-shadow: 0 2px 8px rgba(37, 99, 235, 0.1);
  font-weight: 600;
}

.menu-item-icon {
  width: 18px;
  height: 18px;
  min-width: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.menu-item-icon svg {
  width: 16px;
  height: 16px;
}

.menu-item-text {
  opacity: 1;
  transition: opacity var(--transition-speed) var(--transition-ease);
}

.sidebar.collapsed .menu-item-text {
  opacity: 0;
  width: 0;
}

/* Tooltip for collapsed state */
.sidebar.collapsed .menu-item::after {
  content: attr(data-tooltip);
  position: absolute;
  left: calc(var(--sidebar-collapsed-width) + 6px);
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  color: #1e293b;
  padding: 5px 10px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition-speed) var(--transition-ease);
  z-index: 1001;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08), 0 0 0 1px rgba(37, 99, 235, 0.08);
}

.sidebar.collapsed .menu-item:hover::after {
  opacity: 1;
}

/* Admin menu item styling */
.admin-menu-item .menu-item-icon {
  color: #f59e0b;
}

.admin-menu-item:hover .menu-item-icon,
.admin-menu-item.active .menu-item-icon {
  color: #fbbf24;
}

.admin-menu-item.active {
  background: linear-gradient(135deg, rgba(245, 158, 11, 0.1), rgba(234, 88, 12, 0.08));
  box-shadow: 0 2px 8px rgba(245, 158, 11, 0.1);
}

/* Feature highlight menu item (Euro-cabinet etc) — light theme, subtle gradient.
   Slightly taller than regular items: hero entry-point, allowed to wrap to 2 lines
   so localized labels ("Open Euro-cabinet" / "Открыть Euro-кабинет") never truncate
   next to the NEW badge. Extra padding/min-height are scoped to the expanded
   sidebar — when collapsed, this row matches all other icon-only items. */
.menu-item--feature {
  background: linear-gradient(135deg, rgba(37, 99, 235, 0.08), rgba(37, 99, 235, 0.06));
  border: 1px solid rgba(37, 99, 235, 0.18);
  color: #1d4ed8;
  margin: 4px 8px 6px 6px;
  align-items: center;
}
.sidebar:not(.collapsed) .menu-item--feature,
.sidebar.mobile-open .menu-item--feature {
  padding: 9px 10px;
  min-height: 44px;
  white-space: normal;
}
.menu-item--feature:hover { transform: none; }
.menu-item--feature .menu-item-icon { color: #2563eb; }
.menu-item--feature:hover {
  background: linear-gradient(135deg, rgba(37, 99, 235, 0.14), rgba(37, 99, 235, 0.1));
  border-color: rgba(37, 99, 235, 0.3);
  color: #1d4ed8;
}
.menu-item--feature.active {
  background: linear-gradient(135deg, rgba(37, 99, 235, 0.18), rgba(37, 99, 235, 0.14));
  border-color: rgba(37, 99, 235, 0.4);
  box-shadow: 0 2px 8px rgba(37, 99, 235, 0.15);
  font-weight: 600;
}
.menu-item--feature .menu-item-text {
  flex: 1 1 auto;
  min-width: 0;
  line-height: 1.25;
}
.sidebar:not(.collapsed) .menu-item--feature .menu-item-text,
.sidebar.mobile-open .menu-item--feature .menu-item-text {
  white-space: normal;
  overflow-wrap: anywhere;
}
.menu-item__badge {
  flex-shrink: 0;
  margin-left: auto;
  padding: 1px 5px;
  background: linear-gradient(135deg, #2563eb, #60a5fa);
  color: #fff;
  font-size: 8px;
  font-weight: 800;
  border-radius: 4px;
  letter-spacing: 0.06em;
  line-height: 1.5;
  text-transform: uppercase;
  box-shadow: 0 1px 3px rgba(37,99,235,0.25);
}
.sidebar.collapsed .menu-item__badge { display: none; }

/* Sidebar Footer / My Account */
.sidebar-footer {
  padding: 8px;
  border-top: 1px solid var(--sidebar-border);
  position: relative;
}

.sidebar.collapsed .sidebar-footer {
  padding: 6px;
}

/* My Account Button */
.my-account-btn {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  background: rgba(37, 99, 235, 0.04);
  border: 1px solid transparent;
  border-radius: 6px;
  cursor: pointer;
  transition: all var(--transition-speed) var(--transition-ease);
  color: #1d4ed8;
  font-size: 12px;
  font-weight: 600;
}

.my-account-btn:hover {
  background: rgba(37, 99, 235, 0.1);
  border-color: rgba(37, 99, 235, 0.15);
}

.my-account-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

.my-account-icon svg {
  width: 16px;
  height: 16px;
}

.my-account-text {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  opacity: 1;
  transition: opacity var(--transition-speed) var(--transition-ease);
}

.sidebar.collapsed .my-account-btn {
  justify-content: center;
  padding: 8px;
}

.sidebar.collapsed .my-account-text {
  display: none;
}

/* Account Flyout */
.account-flyout {
  position: absolute;
  bottom: 8px;
  left: calc(100% + 8px);
  min-width: 200px;
  background: white;
  border: 1px solid rgba(37, 99, 235, 0.12);
  border-radius: 8px;
  box-shadow: 0 8px 32px rgba(15, 23, 42, 0.12), 0 2px 8px rgba(37, 99, 235, 0.08);
  padding: 6px;
  opacity: 0;
  visibility: hidden;
  transform: translateX(-8px);
  transition: all 0.2s ease;
  z-index: 2000;
}

.account-flyout.open {
  opacity: 1;
  visibility: visible;
  transform: translateX(0);
}

/* Flyout Items */
.flyout-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.15s ease;
  color: #334155;
  font-size: 12px;
  font-weight: 500;
  text-decoration: none;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
}

.flyout-item:hover {
  background: rgba(37, 99, 235, 0.06);
  color: #1d4ed8;
}

.flyout-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

.flyout-icon svg {
  width: 14px;
  height: 14px;
}

/* Flyout Language Item */
.flyout-lang {
  justify-content: flex-start;
  cursor: default;
}

.flyout-lang-options {
  display: flex;
  gap: 4px;
  margin-left: auto;
}

.flyout-lang-btn {
  padding: 4px 10px;
  border: 1px solid rgba(37, 99, 235, 0.15);
  border-radius: 6px;
  background: transparent;
  color: #64748b;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
}

.flyout-lang-btn:hover {
  background: rgba(37, 99, 235, 0.08);
  color: #1d4ed8;
}

.flyout-lang-btn.active {
  background: rgba(37, 99, 235, 0.12);
  border-color: rgba(37, 99, 235, 0.3);
  color: #1d4ed8;
}

/* Flyout Plan Item */
.flyout-plan-info {
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 0;
}

.flyout-plan-name {
  font-size: 13px;
  font-weight: 600;
  color: #1d4ed8;
}

.flyout-plan.pro .flyout-plan-name {
  color: #059669;
}

.flyout-plan-expires {
  font-size: 11px;
  color: #94a3b8;
  white-space: nowrap;
}

.flyout-plan-expires.expired {
  color: #ef4444;
  font-weight: 500;
}

.flyout-plan-expires.unlimited {
  font-size: 13px;
  font-weight: 600;
  color: #10b981;
}

.flyout-plan-expires.expiring-soon {
  color: #f59e0b;
  font-weight: 600;
  animation: pulse-warning 2s infinite;
}

@keyframes pulse-warning {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.6; }
}

/* Flyout Logout */
.flyout-logout:hover {
  background: rgba(239, 68, 68, 0.06);
  color: #ef4444;
}

.flyout-logout:hover .flyout-icon svg {
  color: #ef4444;
}

/* Renew button in flyout */
.plan-renew-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 4px 10px;
  margin-left: auto;
  background: linear-gradient(135deg, #10b981 0%, #059669 100%);
  border: none;
  border-radius: 6px;
  color: white;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  cursor: pointer;
  transition: all 0.15s ease;
  white-space: nowrap;
}

.plan-renew-btn:hover {
  transform: scale(1.05);
  box-shadow: 0 2px 12px rgba(16, 185, 129, 0.3);
}

.plan-renew-btn svg {
  width: 12px;
  height: 12px;
}

/* ================================================
   Main Content Area
   ================================================ */
.main-content {
  flex: 1;
  margin-left: var(--sidebar-width);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  transition: margin-left var(--transition-speed) var(--transition-ease);
  overflow-x: hidden;
  overflow-y: visible;
  max-width: calc(100vw - var(--sidebar-width));
}

.sidebar.collapsed ~ .main-content {
  margin-left: var(--sidebar-collapsed-width);
  max-width: calc(100vw - var(--sidebar-collapsed-width));
}

/* Top Bar */
.top-bar {
  position: sticky;
  top: 0;
  height: var(--topbar-height);
  background: rgba(255, 255, 255, 0.35);
  backdrop-filter: saturate(180%) blur(40px);
  -webkit-backdrop-filter: saturate(180%) blur(40px);
  border-bottom: 1px solid rgba(37, 99, 235, 0.06);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  padding-top: env(safe-area-inset-top, 0px);
  z-index: 100;
  box-shadow: 0 1px 8px rgba(0, 0, 0, 0.02);
}

.top-bar-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.mobile-menu-toggle {
  display: none;
  width: 40px;
  height: 40px;
  border: none;
  background: transparent;
  cursor: pointer;
  border-radius: 8px;
  align-items: center;
  justify-content: center;
}

.mobile-menu-toggle:hover {
  background: rgba(0, 0, 0, 0.05);
}

.mobile-menu-toggle svg {
  width: 24px;
  height: 24px;
  color: #1e293b;
}

.page-title {
  font-size: 15px;
  font-weight: 600;
  color: #1e293b;
}

.top-bar-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

/* Content Area - no inner scroll, use window scroll only */
.content-area {
  flex: 1;
  padding: 12px 16px;
  overflow: visible;
  max-width: 100%;
  position: relative;
  z-index: 1;
}

/* ================================================
   Mobile Overlay
   ================================================ */
.sidebar-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.15);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  z-index: 999;
  opacity: 0;
  transition: opacity var(--transition-speed) var(--transition-ease);
}

.sidebar-overlay.active {
  opacity: 1;
}

/* ================================================
   Responsive Styles
   ================================================ */
@media (max-width: 1280px) {
  :root {
    --sidebar-width: 200px;
  }
  .content-area {
    padding: 10px 12px;
  }
  .stats-grid {
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 8px;
  }
  .stat-card {
    padding: 10px;
  }
  .stat-value {
    font-size: 16px;
  }
  .stat-icon {
    width: 28px;
    height: 28px;
  }
  .dashboard-card-header {
    padding: 10px 12px;
  }
  .dashboard-card-body {
    padding: 10px 12px;
  }
  .quick-actions {
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 6px;
  }
  .quick-action-btn {
    padding: 6px 10px;
  }
}

/* Tablet (769–1024px): the icon rail is driven by the real .collapsed class
   (auto-added in dashboard.js setupSidebar), NOT by forcing
   `.sidebar:not(.collapsed)` to 56px. The old trick made BOTH toggle states
   56px wide — the chevron could never expand the menu — while the expanded
   styling of the Euro-cabinet feature item (min-height + wrapping text + NEW
   badge) kept applying inside the 56px rail and stretched it vertically.
   Range is bounded at 769px so nothing here leaks into the phone drawer. */
@media (min-width: 769px) and (max-width: 1024px) {
  /* Content always reserves only the rail width; an expanded sidebar overlays
     the page like a drawer instead of reflowing it. */
  .main-content,
  .sidebar.collapsed ~ .main-content {
    margin-left: var(--sidebar-collapsed-width);
    max-width: calc(100vw - var(--sidebar-collapsed-width));
  }

  .sidebar:not(.collapsed) {
    box-shadow: 4px 0 24px rgba(15, 23, 42, 0.12);
  }
}

@media (max-width: 768px) {
  /* Sidebar hidden by default, slides in via hamburger as a full drawer.
     .collapsed is neutralized here (a stale desktop/tablet state must never
     shrink the drawer): closed and open widths are identical, so the panel
     slides in at its final size with no width animation. */
  .sidebar,
  .sidebar.collapsed {
    transform: translateX(-100%);
    width: min(84vw, 300px);
    max-width: none;
    border-radius: 0 16px 16px 0;
    box-shadow: none;
  }

  .sidebar.mobile-open,
  .sidebar.mobile-open.collapsed {
    transform: translateX(0);
    box-shadow: 12px 0 40px rgba(15, 23, 42, 0.18);
  }

  .sidebar.mobile-open .sidebar-logo-text,
  .sidebar.mobile-open .menu-section-title,
  .sidebar.mobile-open .menu-item-text,
  .sidebar.mobile-open .my-account-text {
    opacity: 1;
    width: auto;
  }

  .sidebar.mobile-open .menu-item__badge {
    display: inline-block;
  }

  /* Comfortable touch targets inside the drawer */
  .sidebar-header {
    padding: 14px 16px;
    padding-top: calc(14px + env(safe-area-inset-top, 0px));
  }

  .sidebar .menu-item {
    padding: 11px 12px;
    margin: 1px 10px;
    font-size: 14px;
    min-height: 44px;
  }

  .sidebar .menu-item:hover {
    transform: none;
  }

  .sidebar-footer {
    padding: 10px;
    padding-bottom: calc(10px + env(safe-area-inset-bottom, 0px));
  }

  .sidebar .my-account-btn {
    min-height: 44px;
  }

  /* Overlay visible when sidebar is open */
  .sidebar-overlay {
    display: block;
    pointer-events: none;
  }

  .sidebar-overlay.active {
    pointer-events: auto;
  }

  /* No background scroll while the drawer is open (set in dashboard.js) */
  body.sidebar-locked {
    overflow: hidden;
  }

  /* Show bottom tab bar */
  .bottom-tab-bar {
    display: block;
  }

  /* The chevron inside the drawer header acts as a close button (dashboard.js
     closes the drawer instead of toggling .collapsed at this width). */
  .sidebar-toggle {
    width: 36px;
    height: 36px;
    min-width: 36px;
  }

  .sidebar-toggle svg {
    width: 18px;
    height: 18px;
  }

  .mobile-menu-toggle {
    display: flex !important;
    align-items: center;
    justify-content: center;
    z-index: 1001;
    width: 44px;
    height: 44px;
  }

  /* Main content takes full width with bottom padding for tab bar.
     The .collapsed variant must be repeated: `.sidebar.collapsed ~ .main-content`
     outranks a bare `.main-content`, and a stale .collapsed can survive a
     rotate/resize from desktop or tablet widths. */
  .main-content,
  .sidebar.collapsed ~ .main-content {
    margin-left: 0;
    width: 100%;
    max-width: 100%;
    min-width: 0;
    padding-bottom: calc(var(--bottom-tab-height) + env(safe-area-inset-bottom, 0px));
  }

  .content-area {
    padding: 12px;
  }

  .top-bar {
    padding: 0 16px;
    height: 56px;
  }

  .top-bar-left {
    flex: 1;
    min-width: 0;
    gap: 8px;
  }

  .page-title {
    font-size: 15px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  /* Quick actions on dashboard */
  .quick-actions {
    flex-wrap: wrap;
    gap: 8px;
  }

  .quick-action-btn {
    flex: 1 1 calc(50% - 4px);
    min-width: 140px;
    padding: 8px;
    font-size: 12px;
  }

  .quick-action-btn svg {
    width: 18px;
    height: 18px;
  }

  /* Stats grid mobile */
  .stats-grid {
    grid-template-columns: 1fr 1fr;
    gap: 8px;
  }

  .stat-card {
    padding: 12px;
  }

  .stat-icon {
    width: 36px;
    height: 36px;
  }

  .stat-icon svg {
    width: 18px;
    height: 18px;
  }

  .stat-value {
    font-size: 18px;
  }

  .stat-label {
    font-size: 11px;
  }

  /* Accounts list mobile */
  .accounts-list {
    gap: 8px;
  }

  .account-card {
    padding: 12px;
    flex-direction: column;
    gap: 10px;
  }

  .account-info {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
  }

  .account-stats {
    width: 100%;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 8px;
  }

  .account-actions {
    width: 100%;
    justify-content: flex-end;
    gap: 6px;
  }

  .account-actions .btn {
    padding: 6px 10px;
    font-size: 11px;
  }

  /* Dashboard card header buttons */
  .dashboard-card-header {
    flex-wrap: wrap;
    gap: 8px;
  }

  .dashboard-card-header > div {
    gap: 6px !important;
  }

  /* Toggle accounts button - icon only on mobile */
  #toggleAccountsBtn {
    padding: 6px !important;
    gap: 0 !important;
  }

  #toggleAccountsBtn span {
    display: none;
  }

  #toggleAccountsBtn svg {
    margin: 0 !important;
  }

  /* Account card actions - icon only on mobile, but sized for touch.
     Selectors are nested under .account-card-row/-actions on purpose: the
     base .act-btn rules live LATER in this file, so a bare `.act-btn` here
     would lose the cascade at equal specificity. */
  .account-card-row .act-btn span {
    display: none;
  }
  .account-card-actions .act-btn {
    padding: 0 10px !important;
    height: 38px;
    min-width: 42px;
    justify-content: center;
  }
  .account-card-actions .act-btn svg {
    width: 16px;
    height: 16px;
  }

  /* Account rows: info keeps the first line, action buttons drop to their own
     full-width row instead of squeezing the name on 375px screens */
  .account-card-row {
    flex-wrap: wrap;
    row-gap: 8px;
  }
  .account-card-row .account-card-actions {
    flex-basis: 100%;
    justify-content: flex-end;
    gap: 6px;
  }
}

/* ================================================
   Dashboard Specific Styles
   ================================================ */

/* Stats Cards */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 10px;
  margin-bottom: 12px;
}

.stat-card {
  background: white;
  border-radius: 8px;
  padding: 10px 12px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
  display: flex;
  align-items: flex-start;
  gap: 10px;
}

.stat-icon {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.stat-icon.primary {
  background: rgba(37, 99, 235, 0.1);
  color: #2563eb;
}

.stat-icon.success {
  background: rgba(16, 185, 129, 0.1);
  color: #10b981;
}

.stat-icon.warning {
  background: rgba(245, 158, 11, 0.1);
  color: #f59e0b;
}

.stat-icon.danger {
  background: rgba(239, 68, 68, 0.1);
  color: #ef4444;
}

.stat-icon svg {
  width: 16px;
  height: 16px;
}

.stat-content {
  flex: 1;
}

.stat-label {
  font-size: 11px;
  color: #64748b;
  margin-bottom: 2px;
}

.stat-value {
  font-size: 15px;
  font-weight: 700;
  color: #1e293b;
  line-height: 1.2;
}

.stat-change {
  font-size: 12px;
  margin-top: 4px;
}

.stat-change.positive {
  color: #10b981;
}

.stat-change.negative {
  color: #ef4444;
}

/* Quick Actions */
.quick-actions {
  display: flex;
  gap: 6px;
  margin-bottom: 10px;
}

.quick-action-btn {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 5px 10px;
  background: white;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s ease;
  text-decoration: none;
  color: #1e293b;
}

.quick-action-btn:hover {
  border-color: #2563eb;
  background: rgba(37, 99, 235, 0.02);
}

.quick-action-btn svg {
  width: 15px;
  height: 15px;
  color: #2563eb;
}

.quick-action-btn span {
  font-size: 11px;
  font-weight: 500;
}

/* Account card row */
.account-card-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  background: #f8fafc;
  border-radius: 8px;
  margin-bottom: 4px;
  cursor: pointer;
  transition: background 0.12s ease;
}
.account-card-row:hover {
  background: #f1f5f9;
}
.account-card-row[data-agency="true"] {
  background: #fef3c7;
  border: 1px solid #fcd34d;
}
.account-card-avatar {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-weight: 600;
  flex-shrink: 0;
  font-size: 13px;
}
.account-card-info {
  flex: 1;
  min-width: 0;
}
.account-card-name {
  font-weight: 600;
  font-size: 13px;
  color: #1e293b;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.account-stat-badge {
  display: inline-flex;
  align-items: center;
  padding: 1px 6px;
  border-radius: 9px;
  font-size: 10px;
  font-weight: 600;
}

/* Header action buttons (Sync All, Add Account) */
.hdr-btn {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 5px 12px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  border: none;
  white-space: nowrap;
  transition: all 0.15s;
}
.hdr-btn--ghost {
  background: white;
  color: #475569;
  border: 1px solid #e2e8f0;
}
.hdr-btn--ghost:hover {
  background: #f1f5f9;
  border-color: #cbd5e1;
  color: #1e293b;
}
.hdr-btn--primary {
  background: #2563eb;
  color: white;
}
.hdr-btn--primary:hover {
  background: #1d4ed8;
}

/* Account card actions */
.account-card-actions {
  display: flex;
  gap: 3px;
  flex-shrink: 0;
  align-items: center;
}

/* Action buttons — subtle bordered pills */
.act-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  border: 1px solid #e2e8f0;
  border-radius: 5px;
  background: white;
  color: #475569;
  font-size: 11px;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  text-decoration: none;
  transition: all 0.12s;
  height: 26px;
  box-sizing: border-box;
}
.act-btn:hover {
  background: #f1f5f9;
  border-color: #cbd5e1;
  color: #1e293b;
}
.act-btn svg {
  width: 12px;
  height: 12px;
  flex-shrink: 0;
}

/* Primary accent button (Quick Login / Open) */
.act-btn--accent {
  background: #eef2ff;
  border-color: #bfdbfe;
  color: #1d4ed8;
}
.act-btn--accent:hover {
  background: #e0e7ff;
  border-color: #a5b4fc;
  color: #1d4ed8;
}

/* Icon-only button (Rename) */
.act-btn--icon {
  padding: 3px 5px;
  color: #94a3b8;
}
.act-btn--icon:hover {
  color: #475569;
}

/* Dashboard Cards */
.dashboard-card {
  background: white;
  border-radius: 8px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
  margin-bottom: 12px;
}

.dashboard-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  border-bottom: 1px solid #f1f5f9;
}

.dashboard-card-title {
  font-size: 13px;
  font-weight: 600;
  color: #1e293b;
}

.dashboard-card-body {
  padding: 10px 12px;
}

/* Activity List */
.activity-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.activity-item {
  display: flex;
  align-items: flex-start;
  gap: 6px;
  padding: 3px 0;
}

.activity-icon {
  width: 22px;
  height: 22px;
  border-radius: 5px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.activity-icon.success {
  background: rgba(16, 185, 129, 0.1);
  color: #10b981;
}

.activity-icon.primary {
  background: rgba(37, 99, 235, 0.1);
  color: #2563eb;
}

.activity-icon.warning {
  background: rgba(245, 158, 11, 0.1);
  color: #f59e0b;
}

.activity-icon svg {
  width: 14px;
  height: 14px;
}

.activity-content {
  flex: 1;
  min-width: 0;
}

.activity-text {
  font-size: 13px;
  color: #1e293b;
  margin-bottom: 2px;
}

.activity-time {
  font-size: 12px;
  color: #94a3b8;
}

/* Empty State */
.empty-state {
  text-align: center;
  padding: 32px 16px;
}

.empty-state-icon {
  width: 48px;
  height: 48px;
  margin: 0 auto 16px;
  color: #cbd5e1;
}

.empty-state-title {
  font-size: 16px;
  font-weight: 600;
  color: #64748b;
  margin-bottom: 8px;
}

.empty-state-text {
  font-size: 14px;
  color: #94a3b8;
}

/* ================================================
   App Footer
   ================================================ */
.app-footer {
  margin-top: auto;
  padding: 16px 0 12px;
  text-align: center;
}

.app-footer-links {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 12px;
  font-size: 13px;
}

.app-footer-links a {
  color: #94a3b8;
  text-decoration: none;
  transition: color 0.2s;
}

.app-footer-links a:hover {
  color: #2563eb;
  text-decoration: underline;
}

.app-footer-links .footer-divider {
  color: #cbd5e1;
}

/* ================================================
   Bottom Tab Bar (Mobile)
   ================================================ */
.bottom-tab-bar {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: var(--bottom-tab-height);
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: saturate(180%) blur(40px);
  -webkit-backdrop-filter: saturate(180%) blur(40px);
  border-top: 1px solid rgba(37, 99, 235, 0.08);
  z-index: 1000;
  padding: 0 8px;
  padding-bottom: env(safe-area-inset-bottom, 0px);
}

.bottom-tab-items {
  display: flex;
  justify-content: space-around;
  align-items: center;
  height: 100%;
  max-width: 500px;
  margin: 0 auto;
}

.bottom-tab-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  padding: 6px 12px;
  color: #94a3b8;
  text-decoration: none;
  border-radius: 12px;
  transition: all var(--transition-speed) var(--transition-ease);
  -webkit-tap-highlight-color: transparent;
  min-width: 56px;
}

.bottom-tab-item:active {
  transform: scale(0.9);
}

.bottom-tab-item.active {
  color: #2563eb;
}

.bottom-tab-icon {
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  transition: all var(--transition-speed) var(--transition-ease);
}

.bottom-tab-item.active .bottom-tab-icon {
  background: linear-gradient(135deg, rgba(37, 99, 235, 0.12), rgba(37, 99, 235, 0.08));
  box-shadow: 0 2px 8px rgba(37, 99, 235, 0.15);
}

.bottom-tab-icon svg {
  width: 20px;
  height: 20px;
}

.bottom-tab-label {
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.01em;
}

/* ================================================
   Skeleton Loading Animation
   ================================================ */
@keyframes shimmer {
  0% { background-position: -200px 0; }
  100% { background-position: 200px 0; }
}

.skeleton-text {
  display: inline-block;
  background: linear-gradient(90deg, #e2e8f0 25%, #f1f5f9 50%, #e2e8f0 75%);
  background-size: 200px 100%;
  animation: shimmer 1.5s ease-in-out infinite;
  border-radius: 4px;
  color: transparent;
  user-select: none;
  min-width: 40px;
}

/* ===== Expiry Warning Banner ===== */
.expiry-banner {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 20px;
  background: linear-gradient(135deg, rgba(245, 158, 11, 0.12) 0%, rgba(234, 88, 12, 0.08) 100%);
  border-bottom: 1px solid rgba(245, 158, 11, 0.3);
  font-size: 13px;
  color: #92400e;
  flex-wrap: wrap;
}

.expiry-banner.is-expired {
  background: linear-gradient(135deg, rgba(239, 68, 68, 0.12) 0%, rgba(220, 38, 38, 0.08) 100%);
  border-bottom-color: rgba(239, 68, 68, 0.3);
  color: #991b1b;
}

.expiry-banner-icon {
  flex-shrink: 0;
  width: 18px;
  height: 18px;
  color: #f59e0b;
}

.expiry-banner.is-expired .expiry-banner-icon { color: #ef4444; }

.expiry-banner-text {
  flex: 1;
  font-weight: 500;
}

.expiry-banner-cta {
  padding: 5px 14px;
  background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
  color: white;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: all 0.15s ease;
  white-space: nowrap;
}

.expiry-banner-cta:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(245, 158, 11, 0.4);
}

.expiry-banner.is-expired .expiry-banner-cta {
  background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
}

.expiry-banner.is-expired .expiry-banner-cta:hover {
  box-shadow: 0 4px 12px rgba(239, 68, 68, 0.4);
}

.expiry-banner-dismiss {
  background: none;
  border: none;
  color: #b45309;
  font-size: 15px;
  line-height: 1;
  cursor: pointer;
  padding: 2px 4px;
  opacity: 0.6;
  transition: opacity 0.15s;
  flex-shrink: 0;
}

.expiry-banner-dismiss:hover { opacity: 1; }

/* ===== Sidebar Extend Button ===== */
.sidebar-extend-btn {
  display: none;
  align-items: center;
  justify-content: center;
  gap: 6px;
  width: calc(100% - 16px);
  margin: 0 8px 8px;
  padding: 8px 12px;
  background: linear-gradient(135deg, #10b981 0%, #059669 100%);
  color: white;
  border: none;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.sidebar-extend-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(16, 185, 129, 0.4);
}

.sidebar.collapsed .sidebar-extend-btn .sidebar-extend-text { display: none; }

.sidebar.collapsed .sidebar-extend-btn {
  width: 36px;
  height: 36px;
  padding: 0;
  margin: 0 auto 8px;
  border-radius: 8px;
}

/* --- Free Plan Showcase Mode --- */

.showcase-banner {
  position: sticky;
  top: 0;
  z-index: 100;
  background: linear-gradient(135deg, #2563eb 0%, #60a5fa 100%);
  color: white;
  padding: 0;
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.3);
}

.showcase-banner-content {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 8px 12px;
  padding: 10px 20px;
  font-size: 14px;
  font-weight: 500;
}

.showcase-banner-content svg {
  stroke: white;
  flex-shrink: 0;
}

.showcase-banner-btn {
  display: inline-flex;
  align-items: center;
  padding: 10px 20px;
  min-height: 44px;
  background: white;
  color: #2563eb;
  text-decoration: none;
  border-radius: 8px;
  font-weight: 600;
  font-size: 13px;
  transition: all 0.2s;
  flex-shrink: 0;
}

.showcase-banner-btn:hover {
  background: #f8fafc;
  transform: translateY(-1px);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

/* Free overlay - blur + card on restricted pages */

.free-overlay {
  position: absolute;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: auto;
}

.free-overlay-card {
  text-align: center;
  max-width: 420px;
  padding: 40px 32px;
  background: white;
  border-radius: 16px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.12), 0 2px 8px rgba(0, 0, 0, 0.06);
  border: 1px solid rgba(37, 99, 235, 0.1);
  pointer-events: auto;
}

.free-overlay-icon {
  color: #2563eb;
  margin-bottom: 16px;
}

.free-overlay-card h2 {
  font-size: 20px;
  font-weight: 700;
  color: #1e293b;
  margin: 0 0 8px;
}

.free-overlay-card p {
  font-size: 14px;
  color: #64748b;
  margin: 0 0 24px;
  line-height: 1.6;
}

.free-overlay-cta {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 14px 28px;
  min-height: 44px;
  font-size: 15px;
  font-weight: 600;
  border-radius: 10px;
  text-decoration: none;
}

/* Onboarding paywall icon */
.ob-flow-paywall-icon {
  font-size: 48px;
  text-align: center;
  margin-bottom: 8px;
}

.ob-flow-paywall-plan {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 20px;
  margin: 16px 0;
}

/* Responsive */
@media (max-width: 768px) {
  .showcase-banner-content {
    padding: 8px 12px;
    gap: 6px 10px;
    font-size: 13px;
  }
  .showcase-banner-content span {
    flex: 1;
    min-width: 0;
  }
  .showcase-banner-btn {
    padding: 8px 16px;
    min-height: 44px;
    font-size: 12px;
  }
  .free-overlay-card {
    margin: 0 16px;
    padding: 28px 20px;
  }
  .free-overlay-cta {
    width: 100%;
    justify-content: center;
  }
}

@media (max-width: 400px) {
  .showcase-banner-content {
    flex-direction: column;
    gap: 6px;
    text-align: center;
  }
  .showcase-banner-content svg {
    display: none;
  }
  .showcase-banner-btn {
    width: 100%;
    justify-content: center;
  }
  .free-overlay-card {
    margin: 0 8px;
    padding: 24px 16px;
  }
  .free-overlay-card h2 {
    font-size: 18px;
  }
}

/* Inbound-postback columns (Leads / Conv / Buys / Revenue) — Phase 5.
   Self-reported by the customer's tracker; display only, never our money math. */
.conv-cell { font-variant-numeric: tabular-nums; }
.conv-zero { color: #cbd5e1; }                 /* muted dash for empty cells */
.conv-rev-cell {
  font-size: 12px; font-weight: 600; color: #15803d;
  white-space: nowrap; max-width: 140px; overflow: hidden; text-overflow: ellipsis;
}

/* When toggling columns, briefly un-contain every row so size-contained
   (content-visibility:auto) rows re-measure against the new column set — clears
   the residual-width strip a hidden column would otherwise leave on scrolled rows. */
#campaignsTable.tv-reflow tbody tr { content-visibility: visible !important; }

/* Table view customization — gear panel (per-column + per-card visibility). */
.tv-wrapper { position: relative; display: inline-block; }
.tv-gear-trigger {
  display: inline-flex; align-items: center; justify-content: center;
  width: 34px; height: 34px; border: 1px solid var(--border-color, #e5e7eb);
  border-radius: 8px; background: #fff; color: #475569; cursor: pointer;
}
.tv-gear-trigger:hover { background: #f8fafc; color: #2563eb; border-color: #bfdbfe; }
.tv-panel {
  position: absolute; right: 0; top: calc(100% + 6px); z-index: 1000;
  width: 300px; max-width: 92vw; background: #fff; border: 1px solid #e5e7eb;
  border-radius: 12px; box-shadow: 0 10px 30px rgba(0,0,0,0.12); padding: 12px;
}
.tv-panel-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; font-weight: 600; font-size: 13px; color: #1e293b; }
.tv-reset { border: none; background: none; color: #2563eb; font-size: 12px; cursor: pointer; padding: 2px 4px; }
.tv-reset:hover { text-decoration: underline; }
.tv-section { margin-top: 10px; }
.tv-section-title { font-size: 11px; text-transform: uppercase; letter-spacing: .04em; color: #94a3b8; margin-bottom: 6px; }
.tv-checks { display: grid; grid-template-columns: 1fr 1fr; gap: 4px 10px; }
.tv-check { display: flex; align-items: center; gap: 6px; font-size: 13px; color: #334155; cursor: pointer; padding: 2px 0; }
.tv-check input { cursor: pointer; margin: 0; }
@media (max-width: 480px) { .tv-checks { grid-template-columns: 1fr; } .tv-panel { width: 240px; } }
