/* ─── RESPONSIVE NAV SYSTEM ─── */
  :root {
    --sidebar-width: 270px;
    --sidebar-collapsed-width: 80px;
  }

  .main-wrapper {
    display: flex;
    transition: padding 0.3s ease;
  }

  .main-content {
    flex: 1;
    min-width: 0;
    transition: margin 0.3s ease;
    margin-right: 80px;
  }

  /* Sidebar Base */
  .sidebar {
    position: fixed;
    top: 0;
    right: 0;
    height: 100vh;
    display: flex;
    z-index: 2000;
    width: 80px;
    /* Fixed width of the rail */
    background: transparent;
    transition: width 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  }

  .sidebar.expanded {
    width: 260px;
  }

  /* Column 1: The Permanent Rail (TOP LAYER) */
  .sidebar-rail {
    width: 80px;
    height: 100%;
    background: var(--bg-rail);
    border-left: 1px solid var(--border-subtle);
    display: flex;
    flex-direction: column;
    align-items: center;
    padding-top: 20px;
    flex-shrink: 0;
    z-index: 10;
    box-shadow: var(--shadow-sm);
  }

  .rail-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 60px;
    height: 60px;
    margin-bottom: 15px;
    border-radius: 16px;
    cursor: pointer;
    color: var(--text-muted);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    gap: 5px;
    position: relative;
  }

  .rail-item i {
    font-size: 18px;
    transition: all 0.3s;
  }

  .rail-label {
    font-size: 9px;
    font-weight: 800;
    text-align: center;
    line-height: 1;
  }

  .rail-item:hover {
    background: var(--hover-bg);
    color: var(--text-primary);
    transform: translateY(-2px);
  }

  .rail-item.active {
    background: var(--text-primary);
    color: var(--bg-surface);
    box-shadow: var(--shadow-md);
  }

  .rail-item.active::after {
    content: '';
    position: absolute;
    right: -10px;
    top: 50%;
    transform: translateY(-50%);
    width: 4px;
    height: 25px;
    background: var(--text-primary);
    border-radius: 4px 0 0 4px;
  }

  /* ─── PRINT SYSTEM (RELIABLE ARABIC) ─── */
  #print-area {
    display: none;
  }

  @media print {
    @page {
      margin: 0.5cm;
      size: A4 portrait;
    }

    html,
    body {
      background: #fff !important;
      margin: 0 !important;
      padding: 0 !important;
      width: 100%;
      height: auto;
    }

    body>*:not(#print-area) {
      display: none !important;
    }

    #print-area {
      display: block !important;
      width: 100%;
      direction: rtl;
      font-family: 'Cairo', sans-serif !important;
      background: #fff !important;
    }

    #print-area * {
      visibility: visible !important;
    }

    .page-break {
      page-break-after: always;
    }
  }

  .subscription-mini {
    background: #fff8f1;
    border: 1px solid #ffedd5;
    margin-bottom: 20px;
  }

  .subscription-mini:hover {
    background: #ffedd5;
  }

  .status-indicator {
    position: absolute;
    top: 10px;
    right: 10px;
    width: 8px;
    height: 8px;
    background: var(--text-primary);
    border-radius: 50%;
    border: 2px solid var(--bg-rail);
    box-shadow: 0 0 0 2px var(--border-subtle);
  }

  .subscription-card-grid:hover i.fa-crown {
    color: #f59e0b !important;
    transform: scale(1.2);
  }

  .subscription-card-grid i.fa-crown {
    transition: all 0.3s ease;
  }

  /* Layer 2: The Sliding Drawer (Lower Layer) */
  .sidebar-panel {
    position: absolute;
    top: 0;
    right: 80px; /* Positioned exactly to the left of the rail */
    width: 190px;
    height: 100%;
    background: var(--bg-sidebar);
    display: flex;
    flex-direction: column;
    z-index: 5;
    border-left: 1px solid var(--border-subtle);
    transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.3s ease;
    transform: translateX(100%); /* Hidden off-screen to the right */
    pointer-events: none;
    opacity: 0;
    overflow-y: auto;
    scrollbar-width: none; /* Hide scrollbar on Firefox */
  }

  .sidebar-panel::-webkit-scrollbar {
    display: none; /* Hide scrollbar on Chrome/Safari/Edge */
  }

  .sidebar.expanded .sidebar-panel {
    transform: translateX(0); /* Slides in from the right to its target position */
    pointer-events: auto;
    opacity: 1;
  }

  .sidebar-header {
    padding: 24px 20px;
    display: flex;
    align-items: center;
    justify-content: center;
  }

  .sidebar-logo {
    height: 28px;
  }

  .sidebar-search {
    padding: 0 15px 15px;
  }

  .search-wrap {
    position: relative;
    width: 100%;
  }

  .search-wrap i {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    font-size: 14px;
  }

  .search-wrap input {
    width: 100%;
    padding: 10px 35px 10px 10px;
    border: 1px solid var(--border-medium);
    border-radius: 10px;
    font-size: 13px;
    background: var(--bg-elevated);
    color: var(--text-primary);
  }

  .sidebar-menu {
    padding: 10px;
    overflow-y: auto;
    flex: 1;
  }

  .menu-label {
    font-size: 11px;
    font-weight: 800;
    color: var(--text-muted);
    text-transform: uppercase;
    margin: 15px;
    letter-spacing: 0.5px;
  }

  .side-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 15px;
    margin: 0 10px 4px;
    border-radius: 10px;
    color: var(--text-secondary);
    font-weight: 700;
    font-size: 14px;
    cursor: pointer;
  }

  .side-item:hover {
    background: var(--hover-bg);
    color: var(--text-primary);
  }

  .side-item.active {
    background: var(--active-bg);
    color: var(--text-primary);
    border-right: 3px solid #475569;
  }

  /* Shortcuts Section: Modern Grid Design */
  .shortcuts-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
    padding: 5px 15px 15px;
  }

  .shortcut-card {
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    border-radius: 12px;
    padding: 12px 10px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.02);
  }

  .shortcut-card:hover {
    transform: translateY(-3px);
    border-color: #475569;
    box-shadow: var(--shadow-md);
  }

  .shortcut-card i {
    width: 32px;
    height: 32px;
    background: var(--hover-bg);
    color: var(--text-primary);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    transition: 0.3s;
  }

  .shortcut-card:hover i {
    background: #475569;
    color: #fff;
  }

  .shortcut-card span {
    font-size: 11px;
    font-weight: 800;
    color: var(--text-secondary);
  }

  .shortcut-card.add-new {
    border: 1px dashed #cbd5e1;
    background: #fafafa;
    box-shadow: none;
  }

  .shortcut-card.add-new i {
    background: #f1f5f9;
    color: #94a3b8;
  }

  .shortcut-card.add-new:hover {
    border-color: #94a3b8;
    background: #f8fafc;
  }


  .trial-icon {
    width: 40px;
    height: 40px;
    background: var(--bg-surface);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 12px;
    color: var(--text-primary);
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.05);
    border: 1px solid var(--border-subtle);
  }

  .trial-title {
    font-size: 12px;
    font-weight: 800;
    color: var(--text-primary);
    margin-bottom: 4px;
  }

  .trial-days {
    font-size: 11px;
    color: var(--text-secondary);
    margin-bottom: 15px;
  }

  .btn-upgrade {
    width: 100%;
    padding: 8px;
    background: var(--bg-surface);
    border: 1px solid var(--border-medium);
    border-radius: 10px;
    font-size: 12px;
    font-weight: 800;
    color: var(--text-primary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: 0.2s;
  }

  .btn-upgrade:hover {
    background: #f8fafc;
    border-color: #cbd5e1;
  }

  /* User Info removed from sidebar */

  .sidebar-toggle {
    background: none;
    border: none;
    border-radius: 8px;
    width: 32px;
    height: 32px;
    cursor: pointer;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #64748b;
    transition: all 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    flex-shrink: 0;
    padding: 0;
  }

  .toggle-line {
    position: absolute;
    width: 16px;
    height: 2px;
    background: #64748b;
    border-radius: 2px;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  }

  /* Morphing Logic for RTL Sidebar on Right */
  /* OPEN State: Arrow pointing RIGHT (to close) */
  .toggle-line:nth-child(1) {
    transform: translateY(-5px);
  }

  .toggle-line:nth-child(2) {
    width: 18px;
  }

  .toggle-line:nth-child(3) {
    transform: translateY(5px);
  }

  .sidebar-toggle .toggle-line {
    position: absolute;
    width: 18px;
    height: 2px;
    background: #64748b;
    border-radius: 2px;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    right: 7px;
    /* Center horizontally in the 32px button */
  }

  /* Morphing Logic for RTL Sidebar on Right */
  /* OPEN State: Sharp Arrow pointing RIGHT */
  .sidebar-toggle .toggle-line:nth-child(1) {
    transform: rotate(45deg) scaleX(0.6);
    transform-origin: right;
    top: 15px;
  }

  .sidebar-toggle .toggle-line:nth-child(2) {
    width: 18px;
    top: 15px;
  }

  .sidebar-toggle .toggle-line:nth-child(3) {
    transform: rotate(-45deg) scaleX(0.6);
    transform-origin: right;
    top: 15px;
  }

  /* CLOSED State (Collapsed): Hamburger (3 bars) */
  .sidebar.collapsed .sidebar-toggle .toggle-line:nth-child(1) {
    transform: translateY(-6px) rotate(0) scaleX(1);
    top: 15px;
    width: 18px;
  }

  .sidebar.collapsed .sidebar-toggle .toggle-line:nth-child(2) {
    transform: translateY(0) rotate(0) scaleX(1);
    top: 15px;
    width: 18px;
  }

  .sidebar.collapsed .sidebar-toggle .toggle-line:nth-child(3) {
    transform: translateY(6px) rotate(0) scaleX(1);
    top: 15px;
    width: 18px;
  }

  .sidebar-toggle:hover .toggle-line {
    background: var(--text-primary);
  }

  /* Collapsed State Fixes with Morph Effect */
  .sidebar.collapsed {
    width: var(--sidebar-collapsed-width);
  }

  .sidebar.collapsed .sidebar-logo-container,
  .sidebar.collapsed .sidebar-search,
  .sidebar.collapsed .menu-label,
  .sidebar.collapsed .user-meta {
    display: none !important;
  }

  .sidebar.collapsed .sidebar-header {
    padding: 24px 0;
    display: flex;
    justify-content: center;
    align-items: center;
  }

  .sidebar.collapsed .sidebar-menu {
    padding: 10px 0;
    display: flex;
    flex-direction: column;
    align-items: center;
  }

  /* Active item in collapsed mode: No card, just icon color */
  .sidebar.collapsed .side-item.active {
    background: none !important;
    border-color: transparent !important;
    box-shadow: none !important;
  }

  /* Logout removed from sidebar as requested */
  #logout-btn-collapsed {
    display: none;
  }

  /* Mobile Sidebar Overlay */
  .mobile-overlay-bg {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.5);
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
    z-index: 1999;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
  }
  body.mobile-menu-open .mobile-overlay-bg {
    opacity: 1;
    visibility: visible;
  }
  
  .mobile-menu-btn {
    display: none;
    font-size: 18px;
    color: var(--text-primary);
    cursor: pointer;
    width: 36px; height: 36px;
    align-items: center; justify-content: center;
    border-radius: 10px;
    background: var(--bg-elevated);
    border: 1px solid var(--border-subtle);
  }

  /* Visibility Logic */
  @media (max-width: 768px) {
    .mobile-menu-btn {
      display: flex;
    }

    .sidebar {
      display: flex !important;
      transform: translateX(100%);
      transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
      width: 250px !important;
      box-shadow: -5px 0 25px rgba(0,0,0,0.1);
    }

    body.mobile-menu-open .sidebar {
      transform: translateX(0);
    }
    
    .sidebar-rail {
      width: 70px;
    }

    .sidebar-panel {
      position: absolute;
      right: 70px;
      width: 180px;
      transform: translateX(0) !important;
      opacity: 1 !important;
      pointer-events: auto !important;
      border-left: none;
    }

    .bottom-nav {
      display: none !important;
    }

    .main-content {
      margin-right: 0 !important;
    }

    .header {
      right: 0 !important;
      width: 100% !important;
    }

    .page {
      padding-top: 80px;
      padding-bottom: 30px;
    }
  }

  @media (min-width: 769px) {
    .sidebar {
      display: flex !important;
    }

    .bottom-nav {
      display: none !important;
    }

    .main-content {
      margin-right: var(--sidebar-width);
    }

    body.sidebar-is-collapsed .main-content {
      margin-right: var(--sidebar-collapsed-width);
    }

    .header {
      right: var(--sidebar-width);
    }

    body.sidebar-is-collapsed .header {
      right: var(--sidebar-collapsed-width);
    }

    .page {
      padding-top: 85px;
      padding-bottom: 30px;
    }
  }

  /* ==========================================================================
     SIDEBAR SMART WIDGET STACK OVERRIDES
     ========================================================================== */
  /* ==========================================================================
     SIDEBAR SMART WIDGET STACK OVERRIDES (PREMIUM REDESIGN)
     ========================================================================== */
  #sidebar #smartWidgetStack {
    grid-column: span 2;
    height: 185px !important;
    margin-bottom: 12px;
    border-radius: 20px;
    border: 1px solid var(--border-subtle);
    box-shadow: var(--shadow-md);
    width: 100% !important;
    box-sizing: border-box;
    overflow: hidden;
    position: relative;
  }

  /* Animated glowing accent line on top of the widget container */
  #sidebar #smartWidgetStack::after {
    display: none;
  }

  #sidebar #smartWidgetStack .widget-card {
    height: 100% !important;
  }

  .widget-card {
    padding: 0 !important;
    border-radius: 20px !important;
    display: block !important;
    box-sizing: border-box !important;
    position: relative;
    overflow: visible !important; /* Allow 3D rotation without clipping inside slide bounds */
    transition: all 0.3s ease;
    perspective: 1000px !important; /* 3D effect container */
    background: transparent !important;
  }

  /* Inner container that holds both front and back faces */
  .widget-card .widget-card-inner {
    position: relative;
    width: 100%;
    height: 100%;
    text-align: center;
    transition: transform 0.6s cubic-bezier(0.4, 0, 0.2, 1);
    transform-style: preserve-3d;
  }

  /* Trigger flip state and scale up slightly on click */
  .widget-card.flipped .widget-card-inner {
    transform: rotateY(180deg) scale(1.04);
  }

  /* Front and back faces basic style */
  .widget-card .widget-card-front,
  .widget-card .widget-card-back {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    -webkit-backface-visibility: hidden; /* Hide other face during flip */
    backface-visibility: hidden;
    border-radius: 20px;
    padding: 14px 12px 16px;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-shadow: var(--shadow-md);
    border: 1px solid rgba(255, 255, 255, 0.08);
  }

  .widget-card .widget-card-front {
    z-index: 2;
    transform: rotateY(0deg);
  }

  /* Overlay card glass glow effect on front/back faces */
  .widget-card .widget-card-front::before,
  .widget-card .widget-card-back::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle, rgba(255,255,255,0.15) 0%, transparent 60%);
    pointer-events: none;
    transform: rotate(15deg);
    z-index: 1;
  }

  /* Redesigned back card face: unified premium dark glassmorphic styling */
  .widget-card .widget-card-back {
    transform: rotateY(180deg);
    background: linear-gradient(135deg, rgba(15, 23, 42, 0.95), rgba(30, 41, 59, 0.95)) !important;
    backdrop-filter: blur(12px) !important;
    -webkit-backdrop-filter: blur(12px) !important;
    border: 1px solid rgba(255, 255, 255, 0.15) !important;
    color: #ffffff !important;
    box-shadow: inset 0 1px 1px rgba(255, 255, 255, 0.15), 0 8px 20px rgba(0, 0, 0, 0.3) !important;
    z-index: 1;
  }

  /* Redesigned Widget Header */
  .widget-card .widget-header {
    display: flex !important;
    align-items: center !important;
    justify-content: flex-start !important;
    gap: 8px !important;
    font-size: 11px !important;
    font-weight: 800 !important;
    color: rgba(255, 255, 255, 0.9) !important;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
    width: 100% !important;
    border-bottom: 1px solid rgba(255, 255, 255, 0.12) !important;
    padding-bottom: 8px !important;
    margin-bottom: 10px !important;
    box-sizing: border-box !important;
  }

  .widget-card .widget-header i {
    font-size: 13px !important;
    filter: drop-shadow(0 0 3px currentColor);
    animation: iconPulse 2.5s infinite ease-in-out;
  }

  @keyframes iconPulse {
    0%, 100% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.15); opacity: 0.85; filter: drop-shadow(0 0 6px currentColor); }
  }

  /* Redesigned Widget Body (centered main info) */
  .widget-card .widget-body {
    display: flex !important;
    flex-direction: column !important;
    justify-content: center !important;
    align-items: center !important;
    flex: 1 !important;
    width: 100% !important;
    text-align: center !important;
    box-sizing: border-box !important;
    margin-bottom: 10px !important; /* space for pagination */
    gap: 4px !important;
  }

  /* The hero value/metric */
  .widget-card .widget-value {
    font-size: 24px !important; /* LARGE text */
    font-weight: 950 !important;
    color: #ffffff !important;
    letter-spacing: -0.5px !important;
    line-height: 1.2 !important;
    white-space: nowrap !important;
    text-overflow: ellipsis !important;
    overflow: hidden !important;
    max-width: 100% !important;
    display: inline-block !important;
  }
  
  .widget-card .text-glow {
    text-shadow: 0 0 15px rgba(255, 255, 255, 0.5), 0 2px 5px rgba(0, 0, 0, 0.3) !important;
  }

  /* Specific size overrides for therapist & service names to prevent wrapping/clipping issues */
  .widget-card #fact-top-therapist,
  .widget-card #fact-top-service {
    font-size: 18px !important; /* Large and clear to fit arabic names */
    font-weight: 900 !important;
    white-space: normal !important;
    display: -webkit-box !important;
    -webkit-line-clamp: 2 !important;
    -webkit-box-orient: vertical !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    line-height: 1.35 !important;
    max-height: 46px !important;
  }

  /* Subtext labels at the bottom of the card body */
  .widget-card .widget-subtext {
    font-size: 10px !important;
    font-weight: 700 !important;
    color: rgba(255, 255, 255, 0.75) !important;
    letter-spacing: 0.1px;
    white-space: nowrap !important;
    text-overflow: ellipsis !important;
    overflow: hidden !important;
    max-width: 100% !important;
  }

  /* Goal Progress Bar & Track styling */
  .widget-card .goal-track {
    background: rgba(255, 255, 255, 0.18) !important;
    height: 7px !important;
    border-radius: 6px !important;
    width: 100% !important;
    overflow: hidden !important;
    border: 1px solid rgba(255, 255, 255, 0.08) !important;
    box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.2);
  }

  .widget-card #w-goal-bar {
    background: linear-gradient(90deg, #2dd4bf, #06b6d4, #38bdf8) !important;
    box-shadow: 0 0 8px rgba(45, 212, 191, 0.8) !important;
    height: 100% !important;
    border-radius: 6px !important;
    transition: width 0.8s cubic-bezier(0.4, 0, 0.2, 1) !important;
  }

  /* Customize slide styling */
  .widget-card.add-new-widget {
    justify-content: center !important;
    align-items: center !important;
    background: rgba(255, 255, 255, 0.03) !important;
    border: 2px dashed rgba(255, 255, 255, 0.15) !important;
    cursor: pointer;
  }

  .widget-card.add-new-widget:hover {
    background: rgba(255, 255, 255, 0.08) !important;
    border-color: rgba(255, 255, 255, 0.3) !important;
  }

  .widget-card .icon-circle {
    width: 44px !important;
    height: 44px !important;
    font-size: 16px !important;
    margin: 0 auto 8px !important;
    border-radius: 50% !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    background: rgba(255, 255, 255, 0.1) !important;
    border: 1px solid rgba(255, 255, 255, 0.15) !important;
    color: #ffffff !important;
    transition: all 0.3s ease;
  }

  .widget-card.add-new-widget:hover .icon-circle {
    transform: scale(1.12) rotate(90deg);
    background: rgba(255, 255, 255, 0.2) !important;
    border-color: rgba(255, 255, 255, 0.3) !important;
    box-shadow: 0 0 10px rgba(255, 255, 255, 0.2);
  }

  #sidebar #smartWidgetStack .swiper-pagination-bullet {
    width: 6px !important;
    height: 6px !important;
    background: rgba(255, 255, 255, 0.35) !important;
    opacity: 1 !important;
    transition: all 0.3s ease;
  }

  #sidebar #smartWidgetStack .swiper-pagination-bullet-active {
    width: 16px !important;
    border-radius: 4px !important;
    background: #ffffff !important;
    box-shadow: 0 0 8px rgba(255, 255, 255, 0.8) !important;
  }

  /* Make sure spacing inside the sidebar drawer looks consistent */
  #sidebar .shortcuts-grid {
    padding: 5px 15px 25px !important;
  }

/* ==========================================
   WIDGET DETAIL OVERLAY & GLASS CARD STYLE
   ========================================== */
.widget-detail-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(15, 23, 42, 0.55); /* Slate 900 tint */
  backdrop-filter: blur(16px) saturate(180%);
  -webkit-backdrop-filter: blur(16px) saturate(180%);
  z-index: 100000; /* Superimpose above all overlays and sidebars */
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.4s cubic-bezier(0.25, 1, 0.5, 1);
  padding: 24px;
  box-sizing: border-box;
}

.widget-detail-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

/* ==========================================
   GENERIC WIDGET CARD & FLIP STYLE FOR CLONES
   ========================================== */
.widget-card {
  perspective: 1000px !important;
}

.widget-card .widget-card-inner {
  position: relative;
  width: 100%;
  height: 100%;
  text-align: center;
  transition: transform 0.6s cubic-bezier(0.34, 1.56, 0.64, 1) !important;
  transform-style: preserve-3d !important;
  will-change: transform;
}

.widget-card .widget-card-front,
.widget-card .widget-card-back {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  -webkit-backface-visibility: hidden !important;
  backface-visibility: hidden !important;
  border-radius: 20px;
  padding: 14px 12px 16px;
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: var(--shadow-md);
  border: 1px solid rgba(255, 255, 255, 0.08);
  will-change: transform, opacity;
}

.widget-card .widget-card-front {
  z-index: 2;
  transform: rotateY(0deg) translateZ(0);
  -webkit-transform: rotateY(0deg) translateZ(0);
}

.widget-card .widget-card-back {
  transform: rotateY(180deg) translateZ(0);
  -webkit-transform: rotateY(180deg) translateZ(0);
}

/* ==========================================
   WIDGET FLY-TO-CENTER EXPANDED STATE
   ========================================== */
.widget-card.expanded-card {
  position: fixed !important;
  width: min(680px, 90vw) !important;
  height: min(600px, 85vh) !important;
  left: calc(50vw - min(340px, 45vw)) !important;
  top: calc(50vh - min(300px, 42.5vh)) !important;
  transform: none !important; /* Override Swiper's transform translate */
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.6), inset 0 1px 1px rgba(255, 255, 255, 0.15) !important;
  border: 1px solid rgba(255, 255, 255, 0.15) !important;
  border-radius: 24px !important;
  z-index: 100001 !important;
  margin: 0 !important;
}

.widget-card.expanded-card .widget-card-inner {
  transform: rotateY(180deg) scale(1) !important;
}

.widget-card.expanded-card .widget-card-back {
  padding: 24px !important;
  background: linear-gradient(135deg, rgba(30, 41, 59, 0.95), rgba(15, 23, 42, 0.98)) !important;
  backdrop-filter: blur(16px) !important;
  -webkit-backdrop-filter: blur(16px) !important;
  color: #ffffff !important;
  box-shadow: inset 0 1px 1px rgba(255, 255, 255, 0.15), 0 8px 20px rgba(0, 0, 0, 0.3) !important;
}

/* Close button inside expanded widget card */
.widget-detail-close {
  position: absolute;
  top: 16px;
  left: 16px; /* Left-positioned in RTL */
  width: 34px;
  height: 34px;
  border-radius: 50% !important;
  background: rgba(255, 255, 255, 0.08) !important;
  border: 1px solid rgba(255, 255, 255, 0.12) !important;
  color: rgba(255, 255, 255, 0.8) !important;
  font-size: 14px !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  cursor: pointer;
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1) !important;
  z-index: 100002 !important;
  padding: 0 !important;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2) !important;
  outline: none !important;
}

.widget-detail-close:hover {
  background: rgba(255, 255, 255, 0.18) !important;
  border-color: rgba(255, 255, 255, 0.3) !important;
  color: #ffffff !important;
  transform: rotate(90deg) scale(1.08) !important;
}

.widget-card.expanded-card .widget-card-back .widget-body {
  overflow-y: auto !important;
  margin-bottom: 0 !important;
  justify-content: flex-start !important;
  align-items: stretch !important;
  text-align: right !important;
  height: calc(100% - 60px) !important;
  display: block !important;
  padding-left: 6px;
}

/* Row-based lists inside overlay card */
.detail-item-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.06);
  margin-bottom: 12px;
  transition: all 0.25s ease;
}

.detail-item-row:hover {
  background: rgba(255, 255, 255, 0.06);
  border-color: rgba(255, 255, 255, 0.12);
  transform: translateX(-5px);
}

.detail-item-title {
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 14px;
  color: #f1f5f9;
}

.detail-item-badge {
  padding: 5px 12px;
  border-radius: 10px;
  font-size: 12px;
  font-weight: 800;
  display: inline-block;
}

.badge-low-balance {
  background: rgba(239, 68, 68, 0.18) !important;
  color: #f87171 !important;
  border: 1px solid rgba(239, 68, 68, 0.3) !important;
}

.badge-debt {
  background: rgba(245, 158, 11, 0.18) !important;
  color: #fbbf24 !important;
  border: 1px solid rgba(245, 158, 11, 0.3) !important;
}

.badge-neutral {
  background: rgba(255, 255, 255, 0.08) !important;
  color: #cbd5e1 !important;
  border: 1px solid rgba(255, 255, 255, 0.15) !important;
}

/* Detail tabular content formatting */
.detail-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 10px;
}

.detail-table th, .detail-table td {
  padding: 14px 16px;
  text-align: right;
  font-size: 13px;
}

.detail-table th {
  font-weight: 800;
  color: rgba(255, 255, 255, 0.55);
  border-bottom: 2px solid rgba(255, 255, 255, 0.1);
  text-transform: uppercase;
}

.detail-table td {
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  color: #cbd5e1;
}

.detail-table tr:last-child td {
  border-bottom: none;
}

.detail-table tr:hover td {
  background: rgba(255, 255, 255, 0.02);
  color: #fff;
}

/* Insight individual cards inside the details */
.insight-detail-card {
  padding: 18px;
  border-radius: 16px;
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.02), rgba(255, 255, 255, 0.05));
  border: 1px solid rgba(255, 255, 255, 0.06);
  margin-bottom: 12px;
  display: flex;
  align-items: flex-start;
  gap: 16px;
  transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
}

.insight-detail-card:hover {
  transform: translateY(-2px);
  border-color: rgba(255, 255, 255, 0.14);
  background: rgba(255, 255, 255, 0.07);
}

.insight-detail-icon {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.08);
  color: #a78bfa;
  font-size: 18px;
  flex-shrink: 0;
}

.insight-detail-content {
  flex: 1;
}

.insight-detail-label {
  font-size: 11px;
  color: rgba(255, 255, 255, 0.45);
  font-weight: 800;
  letter-spacing: 0.5px;
}

.insight-detail-val {
  font-size: 15px;
  font-weight: 800;
  color: #ffffff;
  margin-top: 4px;
}

/* Communication Actions Styling */
.action-btn-group {
  display: flex;
  gap: 8px;
}

.action-icon-btn {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: white !important;
  text-decoration: none !important;
}

.btn-whatsapp {
  background: rgba(37, 211, 102, 0.15) !important;
  border-color: rgba(37, 211, 102, 0.3) !important;
  color: #25d366 !important;
}

.btn-whatsapp:hover {
  background: rgba(37, 211, 102, 0.28) !important;
  transform: scale(1.1);
  box-shadow: 0 0 10px rgba(37, 211, 102, 0.2);
}

.btn-call {
  background: rgba(14, 165, 233, 0.15) !important;
  border-color: rgba(14, 165, 233, 0.3) !important;
  color: #0ea5e9 !important;
}

.btn-call:hover {
  background: rgba(14, 165, 233, 0.28) !important;
  transform: scale(1.1);
  box-shadow: 0 0 10px rgba(14, 165, 233, 0.2);
}


