/* ============================================
   Responsive Styles & Media Queries
   ============================================ */

/* ============================================
   Desktop - 1025px and above
   Explicitly set multi-column layouts for desktop
   ============================================ */

@media (min-width: 1025px) {
    /* Hero row - 2 columns on desktop */
    .shopify-hero-row {
        display: grid !important;
        grid-template-columns: 1fr 1fr !important;
        gap: 1rem !important;
    }

    /* Stats row - 4 columns on desktop */
    .shopify-stats-row {
        display: grid !important;
        grid-template-columns: repeat(4, 1fr) !important;
        gap: 0.75rem !important;
    }

    /* Charts row - 2fr 1fr on desktop */
    .shopify-charts-row {
        display: grid !important;
        grid-template-columns: 2fr 1fr !important;
        gap: 1rem !important;
    }
}

/* ============================================
   Mobile Header - Hidden on desktop
   ============================================ */

.mobile-header {
    display: none;
}

.mobile-menu-close {
    display: none;
}

/* ============================================
   Tablet - 1024px and below
   ============================================ */

@media (max-width: 1024px) {
    /* Mobile Header - Fixed at top */
    .mobile-header {
        display: flex;
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        height: 60px;
        background: var(--glass-bg-white);
        backdrop-filter: blur(var(--blur-xl));
        -webkit-backdrop-filter: blur(var(--blur-xl));
        border-bottom: 1px solid var(--border-light);
        z-index: 999;
        padding: 0 1rem;
        align-items: center;
        justify-content: space-between;
    }

    .mobile-header-logo {
        display: flex;
        align-items: center;
    }

    .mobile-menu-toggle {
        display: flex;
        align-items: center;
        justify-content: center;
        width: 44px;
        height: 44px;
        background: transparent;
        border: none;
        border-radius: 12px;
        cursor: pointer;
        color: var(--text-primary);
        transition: background 0.2s ease;
    }

    .mobile-menu-toggle:hover {
        background: var(--bg-secondary);
    }

    /* Mobile Overlay */
    .mobile-overlay {
        display: none;
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(0, 0, 0, 0.5);
        z-index: 1000;
        opacity: 0;
        transition: opacity 0.3s ease;
    }

    .mobile-overlay.active {
        display: block;
        opacity: 1;
    }

    /* Sidebar - Slide from right */
    .sidebar {
        position: fixed;
        top: 0;
        right: 0;
        bottom: 0;
        left: auto;
        width: 70%;
        max-width: 320px;
        height: 100%;
        flex-direction: column;
        padding: 1.5rem;
        border-radius: 0;
        z-index: 1001;
        background: var(--glass-bg-white);
        backdrop-filter: blur(var(--blur-xl));
        -webkit-backdrop-filter: blur(var(--blur-xl));
        box-shadow: -4px 0 24px rgba(0, 0, 0, 0.15);
        transform: translateX(100%);
        transition: transform 0.3s ease;
        overflow-y: auto;
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .sidebar-header {
        display: flex;
        align-items: center;
        justify-content: space-between;
        margin-bottom: 1.5rem;
        padding-bottom: 1rem;
        border-bottom: 1px solid var(--border-light);
    }

    .sidebar-logo {
        display: block;
    }

    .mobile-menu-close {
        display: flex;
        align-items: center;
        justify-content: center;
        width: 40px;
        height: 40px;
        background: transparent;
        border: none;
        border-radius: 10px;
        cursor: pointer;
        color: var(--text-secondary);
        transition: all 0.2s ease;
    }

    .mobile-menu-close:hover {
        background: var(--bg-secondary);
        color: var(--text-primary);
    }

    .sidebar-label {
        display: block;
        font-size: 0.75rem;
        font-weight: 600;
        color: var(--text-muted);
        text-transform: uppercase;
        letter-spacing: 0.5px;
        margin: 1.5rem 0 0.75rem;
    }

    .sidebar-nav {
        flex-direction: column;
        gap: 0.25rem;
    }

    .sidebar-item {
        width: 100%;
        height: auto;
        padding: 0.875rem 1rem;
        border-radius: 10px;
        justify-content: flex-start;
        font-size: 0.9375rem;
        gap: 0.75rem;
    }

    .sidebar-item span:not(.sidebar-icon) {
        display: inline;
    }

    /* Sidebar dropdown adjustments for mobile */
    .sidebar-dropdown-trigger {
        padding: 0.875rem 1rem;
        font-size: 0.9375rem;
    }

    .sidebar-dropdown-menu {
        padding-left: 0.5rem;
    }

    .sidebar-dropdown-item {
        padding: 0.75rem 1rem;
        font-size: 0.875rem;
    }

    .search-box {
        display: none;
    }

    /* Main content - add top padding for mobile header */
    .main-content {
        margin-left: 0;
        width: 100%;
        padding-top: 60px;
    }

    .content {
        padding: 1.5rem;
        padding-bottom: 2rem;
    }

    .top-bar {
        padding: 0.75rem 1rem;
    }

    /* Automations Grid */
    .automations-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    /* Shopify Dashboard - Tablet */
    .shopify-dash-header {
        gap: 0.75rem;
    }

    .shopify-dash-title {
        font-size: 1.5rem !important;
    }

    /* Hero cards: Keep 2 columns on tablet */
    .shopify-hero-row {
        grid-template-columns: 1fr 1fr !important;
        gap: 0.75rem !important;
    }

    /* 4 stat cards: 2x2 grid on tablet */
    .shopify-stats-row {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 0.75rem !important;
    }

    /* Charts: Stack on tablet */
    .shopify-charts-row {
        grid-template-columns: 1fr !important;
        gap: 1rem !important;
    }

    .shopify-chart-card .chart-container {
        height: 200px !important;
    }

    .shopify-chart-card .donut-container {
        height: 140px !important;
    }

    .shopify-features-grid {
        grid-template-columns: 1fr !important;
    }
}

/* ============================================
   Mobile - 768px and below
   ============================================ */

@media (max-width: 768px) {
    /* Prevent horizontal scroll on mobile */
    html, body {
        overflow-x: hidden !important;
        max-width: 100vw !important;
    }

    /* App container width fix */
    .app-container,
    .app-container.active {
        width: 100% !important;
        max-width: 100vw !important;
        overflow-x: hidden;
    }

    /* Main content width fix */
    .main-content {
        margin-left: 0;
        width: 100%;
        max-width: 100vw;
        overflow-x: hidden;
        padding-top: 60px;
    }

    .content {
        padding: 0.75rem;
        padding-bottom: 2rem;
        max-width: 100%;
        width: 100%;
        overflow-x: hidden;
        box-sizing: border-box;
    }

    /* Tab content - proper width */
    .tab-content,
    .tab-content.active {
        width: 100% !important;
        max-width: 100% !important;
        overflow-x: hidden;
        box-sizing: border-box;
        padding: 0 !important;
    }

    /* Shopify Connected Dashboard container */
    #shopifyConnectedDash {
        width: 100% !important;
        max-width: 100% !important;
        box-sizing: border-box;
        overflow-x: hidden;
    }

    /* Force all shopify dashboard children to respect width */
    #shopifyConnectedDash > div {
        width: 100% !important;
        max-width: 100% !important;
        box-sizing: border-box !important;
    }

    /* Ensure cards don't overflow */
    #shopifyConnectedDash .card {
        min-width: 0 !important;
        max-width: 100% !important;
    }

    /* Override inline grid styles for not connected */
    #shopify [style*="grid-template-columns"],
    #shopifyNotConnected [style*="grid-template-columns"],
    .shopify-features-grid {
        grid-template-columns: 1fr !important;
    }

    /* Shopify Connected Dashboard - Mobile */
    .shopify-dash-header {
        gap: 0.5rem;
    }

    .shopify-dash-title {
        font-size: 1.25rem !important;
    }

    /* Hero cards: Single column on mobile - full width */
    .shopify-hero-row {
        grid-template-columns: 1fr !important;
        gap: 0.75rem !important;
        width: 100% !important;
        max-width: 100% !important;
        margin-bottom: 1rem !important;
    }

    .shopify-hero-card {
        padding: 1rem !important;
        border-radius: 12px !important;
        min-width: 0 !important;
        width: 100% !important;
    }

    .shopify-hero-card .hero-value {
        font-size: 1.75rem !important;
    }

    .shopify-hero-card .hero-label {
        font-size: 0.75rem !important;
    }

    .shopify-hero-card .hero-subtext {
        font-size: 0.6875rem !important;
    }

    /* Stat cards: Single column on mobile - full width */
    .shopify-stats-row {
        grid-template-columns: 1fr !important;
        gap: 0.75rem !important;
        width: 100% !important;
        max-width: 100% !important;
        margin-bottom: 1rem !important;
    }

    .shopify-stat-card {
        padding: 1rem !important;
        min-width: 0 !important;
        width: 100% !important;
    }

    .shopify-stat-card .stat-icon {
        width: 32px !important;
        height: 32px !important;
        margin-bottom: 0.5rem !important;
    }

    .shopify-stat-card .stat-icon svg {
        width: 16px !important;
        height: 16px !important;
    }

    .shopify-stat-card .stat-value {
        font-size: 1.125rem !important;
    }

    .shopify-stat-card .stat-label {
        font-size: 0.625rem !important;
    }

    .shopify-stat-card .stat-trend {
        font-size: 0.5625rem !important;
    }

    .shopify-stat-card .trend-text {
        display: none;
    }

    /* Charts: Stacked on mobile */
    .shopify-charts-row {
        grid-template-columns: 1fr !important;
        gap: 0.75rem !important;
        width: 100% !important;
        max-width: 100% !important;
        margin-bottom: 1rem !important;
    }

    .shopify-chart-card {
        padding: 0.875rem !important;
        min-width: 0 !important;
        width: 100% !important;
    }

    .shopify-chart-card .chart-title {
        font-size: 0.8125rem !important;
    }

    .shopify-chart-card .chart-container {
        height: 180px !important;
    }

    .shopify-chart-card .donut-container {
        height: 120px !important;
    }

    .order-status-legend {
        gap: 0.5rem !important;
        font-size: 0.625rem !important;
    }

    .order-status-legend .legend-label {
        display: none;
    }

    /* Footer: Compact on mobile */
    .shopify-footer {
        padding: 0.75rem !important;
        gap: 0.5rem !important;
        width: 100% !important;
        max-width: 100% !important;
        box-sizing: border-box !important;
    }

    .shopify-footer .footer-details {
        gap: 0.5rem !important;
        justify-content: center;
        width: 100%;
    }

    .shopify-footer .footer-divider {
        height: 12px !important;
    }

    .shopify-footer .footer-item span {
        font-size: 0.625rem !important;
    }

    .shopify-disconnect-btn {
        width: 100%;
        justify-content: center;
    }

    /* Legacy Shopify Dashboard - Mobile */
    .shopify-stats-grid,
    #shopify .stats-grid,
    .dashboard-shopify-stats,
    .stats-grid,
    .dashboard-grid {
        grid-template-columns: 1fr;
        gap: 1rem;
    }

    /* Metrics row: keep 3 cols on mobile */
    .shopify-metrics-row {
        grid-template-columns: repeat(3, 1fr);
        gap: 0.75rem;
    }

    /* Hero stats: keep 2 cols for revenue/orders on mobile */
    .shopify-hero-grid,
    .shopify-hero-stats {
        grid-template-columns: repeat(2, 1fr);
        gap: 0.75rem;
    }

    /* Dashboard grid: keep 2 cols on mobile */
    .shopify-dashboard-grid {
        grid-template-columns: 1fr 1fr;
        gap: 0.75rem;
    }

    /* Quick actions: 4 cols on mobile */
    .shopify-quick-actions-grid {
        grid-template-columns: repeat(4, 1fr);
        gap: 0.75rem;
    }

    /* Dashboard header: stack vertically */
    .shopify-dash-header {
        flex-direction: column;
        align-items: stretch;
        gap: 1rem;
    }

    .shopify-header-title {
        flex-wrap: wrap;
        gap: 0.75rem;
    }

    .shopify-header-actions {
        flex-direction: column;
        width: 100%;
    }

    .shopify-header-actions .btn {
        width: 100%;
        justify-content: center;
    }

    /* Hero cards */
    .shopify-hero-card {
        padding: 1.25rem;
    }

    /* Stat values - smaller on mobile */
    .stat-value {
        font-size: 1.25rem;
        word-break: break-word;
    }

    /* Hero card big numbers - smaller on mobile */
    .shopify-hero-card div[style*="font-size: 2.5rem"],
    .shopify-hero-card div[style*="font-size: 2rem"] {
        font-size: 1.75rem !important;
    }

    /* Quick action cards */
    .shopify-quick-action {
        padding: 1rem;
    }

    /* Order status legend */
    .order-status-legend {
        flex-wrap: wrap;
        gap: 0.5rem;
        justify-content: flex-start;
    }

    /* Chart containers */
    .chart-container {
        max-width: 100%;
        overflow: hidden;
    }

    .chart-container canvas {
        max-width: 100%;
    }

    /* Chart headers */
    .shopify-charts-grid .card-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.75rem;
    }

    .chart-period-tabs {
        flex-wrap: wrap;
    }

    /* Cards - prevent overflow */
    .card,
    .stat-card {
        max-width: 100%;
        overflow: hidden;
        box-sizing: border-box;
    }

    .card-header {
        flex-wrap: wrap;
    }

    /* Page header */
    .page-header {
        max-width: 100%;
    }

    .page-title {
        word-break: break-word;
    }

    /* Insights Grid */
    .insights-grid {
        grid-template-columns: 1fr;
    }

    .insight-card.full-width {
        grid-column: span 1;
    }

    .insight-metrics {
        flex-direction: column;
        gap: 1rem;
    }

    /* Top Selling Products */
    .top-product-item {
        max-width: 100%;
    }

    .top-product-item * {
        overflow: hidden;
        text-overflow: ellipsis;
    }

    /* Connection details */
    .connection-detail-row {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.25rem;
    }

    .connection-detail-row span:last-child {
        word-break: break-all;
        max-width: 100%;
    }

    /* Disconnect section */
    #shopifyConnectedDash .card:has(#shopifyDashDisconnectBtn) > div {
        flex-direction: column;
        align-items: stretch;
        gap: 1rem;
        text-align: center;
    }

    #shopifyDashDisconnectBtn {
        width: 100%;
        justify-content: center;
    }

    /* ============================================
       Product Health Page - Mobile Card Layout
       ============================================ */

    /* Health Summary Card - Stack on mobile */
    #productHealthSummaryCard > div {
        flex-direction: column !important;
        gap: 1.5rem !important;
    }

    #productHealthSummaryCard > div > div:last-child {
        display: grid !important;
        grid-template-columns: repeat(4, 1fr) !important;
        gap: 0.5rem !important;
        width: 100% !important;
    }

    #productHealthSummaryCard [style*="font-size: 1.75rem"] {
        font-size: 1.25rem !important;
    }

    /* Filter/Search controls - Stack vertically */
    #shopify-products .card > div > div[style*="grid-template-columns"] {
        grid-template-columns: 1fr !important;
    }

    /* Hide table headers on mobile */
    #productHealthTable thead {
        display: none !important;
    }

    /* Transform table rows into cards */
    #productHealthTable,
    #productHealthTable tbody {
        display: block !important;
        width: 100% !important;
    }

    #productHealthTable tbody tr {
        display: flex !important;
        flex-direction: column !important;
        padding: 1rem !important;
        margin-bottom: 0.75rem !important;
        border: 1px solid var(--border-light) !important;
        border-radius: 12px !important;
        background: var(--bg-main) !important;
    }

    #productHealthTable tbody tr:hover {
        background: var(--bg-secondary) !important;
    }

    /* Product cell - full width */
    #productHealthTable tbody td:first-child {
        padding: 0 !important;
        margin-bottom: 0.75rem !important;
        width: 100% !important;
    }

    #productHealthTable tbody td:first-child > div {
        width: 100% !important;
    }

    #productHealthTable tbody td:first-child img {
        width: 56px !important;
        height: 56px !important;
    }

    /* Score and Issues - inline row */
    #productHealthTable tbody td:nth-child(2),
    #productHealthTable tbody td:nth-child(3) {
        display: inline-flex !important;
        padding: 0 !important;
        text-align: left !important;
        justify-content: flex-start !important;
        width: auto !important;
        margin-right: 0.75rem !important;
    }

    /* Action button - full width at bottom */
    #productHealthTable tbody td:last-child {
        padding: 0.75rem 0 0 0 !important;
        margin-top: 0.75rem !important;
        border-top: 1px solid var(--border-light) !important;
        text-align: center !important;
        width: 100% !important;
    }

    #productHealthTable tbody td:last-child .btn {
        width: 100% !important;
        justify-content: center !important;
    }

    /* Pagination - full width buttons */
    #productHealthPagination {
        flex-direction: column !important;
        gap: 0.75rem !important;
        align-items: stretch !important;
    }

    #productHealthPagination > div {
        display: flex !important;
        justify-content: center !important;
    }

    /* Page Health tab - same treatment */
    #pageHealthTable thead {
        display: none !important;
    }

    #pageHealthTable,
    #pageHealthTable tbody {
        display: block !important;
        width: 100% !important;
    }

    #pageHealthTable tbody tr {
        display: flex !important;
        flex-direction: column !important;
        padding: 1rem !important;
        margin-bottom: 0.75rem !important;
        border: 1px solid var(--border-light) !important;
        border-radius: 12px !important;
        background: var(--bg-main) !important;
    }

    #pageHealthTable tbody tr:hover {
        background: var(--bg-secondary) !important;
    }

    /* Page cell - full width */
    #pageHealthTable tbody td:first-child {
        padding: 0 !important;
        margin-bottom: 0.75rem !important;
        width: 100% !important;
    }

    #pageHealthTable tbody td:first-child > div {
        width: 100% !important;
    }

    #pageHealthTable tbody td:first-child > div > div:last-child > div:first-child {
        max-width: none !important;
    }

    /* Type, Score and Issues - inline row */
    #pageHealthTable tbody td:nth-child(2),
    #pageHealthTable tbody td:nth-child(3),
    #pageHealthTable tbody td:nth-child(4) {
        display: inline-flex !important;
        padding: 0 !important;
        text-align: left !important;
        justify-content: flex-start !important;
        width: auto !important;
        margin-right: 0.75rem !important;
        margin-bottom: 0.5rem !important;
    }

    /* Action button - full width at bottom */
    #pageHealthTable tbody td:last-child {
        padding: 0.75rem 0 0 0 !important;
        margin-top: 0.5rem !important;
        border-top: 1px solid var(--border-light) !important;
        text-align: center !important;
        width: 100% !important;
    }

    #pageHealthTable tbody td:last-child > div {
        flex-direction: column !important;
        gap: 0.5rem !important;
    }

    #pageHealthTable tbody td:last-child .btn {
        width: 100% !important;
        justify-content: center !important;
    }

    /* Page Health Pagination - full width buttons */
    #pageHealthPagination {
        flex-direction: column !important;
        gap: 0.75rem !important;
        align-items: stretch !important;
    }

    #pageHealthPagination > div {
        display: flex !important;
        justify-content: center !important;
    }

    /* ============================================
       Content Hub - Mobile
       ============================================ */

    /* Page header - responsive */
    #content-hub .page-header {
        flex-direction: column !important;
        align-items: stretch !important;
        gap: 1rem !important;
    }

    #content-hub .page-header .btn {
        width: 100% !important;
        justify-content: center !important;
    }

    /* Stats grid - 2x2 on tablet */
    #content-hub .stats-grid {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 0.75rem !important;
    }

    /* Main content grid - Stack calendar and AI suggestions */
    #content-hub > div[style*="grid-template-columns: minmax"] {
        grid-template-columns: 1fr !important;
        gap: 1rem !important;
    }

    /* AI suggestions card - full width */
    #content-hub .card[style*="linear-gradient(135deg, rgba(113, 254, 235"] {
        order: -1 !important; /* Show AI suggestions first on mobile */
    }

    /* Calendar card - responsive */
    #contentCalendarCard .card-header {
        flex-direction: column !important;
        gap: 0.75rem !important;
        align-items: stretch !important;
    }

    #contentCalendarCard .card-header > div:first-child {
        justify-content: center !important;
    }

    #contentCalendarCard .card-header > button {
        width: 100% !important;
        justify-content: center !important;
    }

    /* Quick actions row - 2x2 grid on tablet */
    #content-hub > div[style*="grid-template-columns: repeat(4, 1fr)"] {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 0.75rem !important;
    }

    /* Quick action cards - smaller padding */
    #content-hub > div[style*="grid-template-columns: repeat(4, 1fr)"] > .card {
        padding: 0.875rem !important;
    }

    /* Quick action icon - smaller */
    #content-hub > div[style*="grid-template-columns: repeat(4, 1fr)"] > .card > div:first-child {
        width: 36px !important;
        height: 36px !important;
        margin-right: 0.625rem !important;
    }

    #content-hub > div[style*="grid-template-columns: repeat(4, 1fr)"] > .card > div:first-child svg {
        width: 16px !important;
        height: 16px !important;
    }

    /* Content table - Hide some columns on tablet */
    #content-hub .table-container table thead th:nth-child(3),
    #content-hub .table-container table tbody td:nth-child(3) {
        display: none !important; /* Hide Platform column */
    }

    /* Filter buttons - Scrollable */
    #content-hub .card-header > div[style*="background: var(--bg-secondary)"] {
        flex-wrap: nowrap !important;
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch !important;
        padding: 0.375rem !important;
    }

    #content-hub .card-header > div[style*="background: var(--bg-secondary)"] button {
        flex-shrink: 0 !important;
    }

    /* ============================================
       Revenue Health Score - Mobile
       ============================================ */

    /* Overall Score Card - Smaller text on mobile */
    #health-score .card[style*="linear-gradient(135deg, var(--glass-bg-primary)"] {
        padding: 2rem 1.5rem !important;
    }

    #healthScoreValue {
        font-size: 3.5rem !important;
    }

    #healthScoreGrade {
        font-size: 1rem !important;
    }

    #healthScoreLossTotal {
        font-size: 0.875rem !important;
    }

    /* Score card buttons - stack on mobile */
    #health-score .card[style*="linear-gradient(135deg, var(--glass-bg-primary)"] > div:last-child {
        flex-direction: column !important;
        gap: 0.75rem !important;
        width: 100% !important;
    }

    #health-score .card[style*="linear-gradient(135deg, var(--glass-bg-primary)"] > div:last-child .btn {
        width: 100% !important;
        justify-content: center !important;
    }

    /* Category Scores Grid - 2 columns on tablet */
    #healthCategoryScores {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 1rem !important;
    }

    /* Revenue Leaks - Stack content */
    #healthRevenueLeaks > div {
        padding: 1.25rem !important;
    }

    #healthRevenueLeaks > div > div {
        flex-direction: column !important;
        gap: 1rem !important;
    }

    #healthRevenueLeaks > div > div > div:first-child {
        width: 48px !important;
        height: 48px !important;
        flex-shrink: 0 !important;
    }

    /* Revenue leak stats - 2 columns */
    #healthRevenueLeaks [style*="display: flex"][style*="gap: 2rem"] {
        gap: 1rem !important;
    }

    /* Progress Tracking Section */
    #progressTrackingSection .card-body > div:first-child {
        grid-template-columns: repeat(2, 1fr) !important;
    }

    /* ============================================
       Product Health Modal - Mobile
       ============================================ */

    #productHealthModal .modal,
    #pageHealthModal .modal {
        max-width: 100% !important;
        margin: 0.5rem !important;
        padding: 1.25rem !important;
        max-height: calc(100vh - 1rem) !important;
    }

    /* Modal header - stack image and title */
    #productHealthModal .modal > div:first-child,
    #pageHealthModal .modal > div:first-child {
        flex-direction: column !important;
        align-items: flex-start !important;
        gap: 0.75rem !important;
    }

    #productHealthModal .modal > div:first-child > div:first-child,
    #pageHealthModal .modal > div:first-child > div:first-child {
        flex-direction: row !important;
        align-items: center !important;
        width: 100% !important;
    }

    #healthModalProductImage,
    #pageHealthModalIcon {
        width: 48px !important;
        height: 48px !important;
    }

    #healthModalProductTitle,
    #pageHealthModalTitle {
        font-size: 1rem !important;
    }

    /* Score section - stack on mobile */
    #productHealthModal .modal > div:nth-child(2),
    #pageHealthModal .modal > div:nth-child(2) {
        flex-direction: column !important;
        gap: 1rem !important;
        padding: 1rem !important;
    }

    #healthModalScoreCircle,
    #pageHealthModalScoreCircle {
        width: 70px !important;
        height: 70px !important;
    }

    #healthModalBreakdown,
    #pageHealthModalBreakdown {
        grid-template-columns: 1fr !important;
        gap: 0.375rem !important;
    }

    /* Actions - stack buttons */
    #productHealthModal .modal > div:last-child,
    #pageHealthModal .modal > div:last-child {
        flex-direction: column !important;
        gap: 0.5rem !important;
    }

    #productHealthModal .modal > div:last-child .btn,
    #pageHealthModal .modal > div:last-child .btn {
        width: 100% !important;
        flex: none !important;
    }

    /* ============================================
       Email Automations - Tablet (768px)
       ============================================ */

    /* Stats grid - 2x2 on tablet */
    #email-automations .stats-grid {
        grid-template-columns: repeat(2, 1fr) !important;
    }

    /* Dashboard grid - Stack chart and performance table */
    #email-automations .dashboard-grid[style*="grid-template-columns: 1fr 1fr"] {
        grid-template-columns: 1fr !important;
    }

    /* Performance table - Card layout */
    #eaPerformanceTable table {
        display: block !important;
    }

    #eaPerformanceTable table thead {
        display: none !important;
    }

    #eaPerformanceTable table tbody {
        display: flex !important;
        flex-direction: column !important;
        gap: 0.5rem !important;
    }

    #eaPerformanceTable table tbody tr {
        display: flex !important;
        flex-wrap: wrap !important;
        padding: 0.75rem !important;
        background: var(--bg-secondary) !important;
        border-radius: 8px !important;
        border: 1px solid var(--border-light) !important;
    }

    #eaPerformanceTable table tbody td {
        border: none !important;
        padding: 0.25rem !important;
    }

    #eaPerformanceTable table tbody td:first-child {
        width: 100% !important;
        font-weight: 600 !important;
        margin-bottom: 0.25rem !important;
    }

    #eaPerformanceTable table tbody td:not(:first-child) {
        flex: 1 !important;
        text-align: center !important;
    }

    #eaPerformanceTable table tbody td:not(:first-child)::before {
        display: block !important;
        font-size: 0.625rem !important;
        color: var(--text-muted) !important;
        text-transform: uppercase !important;
        margin-bottom: 0.125rem !important;
    }

    #eaPerformanceTable table tbody td:nth-child(2)::before { content: 'Sent'; }
    #eaPerformanceTable table tbody td:nth-child(3)::before { content: 'Opens'; }
    #eaPerformanceTable table tbody td:nth-child(4)::before { content: 'Clicks'; }

    /* Automation cards - Ensure they stack properly */
    #email-automations .dashboard-grid[style*="repeat(auto-fit, minmax(320px, 1fr))"] {
        grid-template-columns: 1fr !important;
    }

    /* Cart Abandonment Modal - Responsive */
    #cartAbandonmentModal .modal {
        max-width: 95% !important;
        max-height: 95vh !important;
        margin: 0.5rem !important;
    }

    /* Modal two-column layout - Stack on tablet */
    #cartAbandonmentModal [style*="grid-template-columns: 1fr 1fr"] {
        grid-template-columns: 1fr !important;
    }

    /* Timeline - Compact on tablet */
    #cartAbandonmentModal [style*="justify-content: space-between"][style*="position: relative"] > div {
        flex-direction: column !important;
        text-align: center !important;
    }

    /* Post-Purchase Modal - Responsive */
    #postPurchaseModal .modal {
        max-width: 95% !important;
        max-height: 95vh !important;
        margin: 0.5rem !important;
    }

    #postPurchaseModal [style*="grid-template-columns: 1fr 1fr"] {
        grid-template-columns: 1fr !important;
    }

    /* Review Request Modal - Responsive */
    #reviewRequestModal .modal {
        max-width: 95% !important;
        max-height: 95vh !important;
        margin: 0.5rem !important;
    }

    #reviewRequestModal [style*="grid-template-columns: 1fr 1fr"] {
        grid-template-columns: 1fr !important;
    }

    /* ============================================
       AI Assistant - Tablet (768px)
       ============================================ */

    /* Chat container - adjust height */
    #ai-assistant .ai-chat-container {
        padding: 0 0.5rem !important;
    }

    /* Inline form - stack fields */
    .ai-inline-form {
        max-height: 200px !important;
        overflow-y: auto !important;
    }

    .ai-inline-fields {
        grid-template-columns: 1fr !important;
    }

    /* Selected automation header - adjust padding */
    .ai-selected-automation {
        padding: 0.5rem 0.75rem !important;
    }

    /* Picker modal - full width */
    .ai-picker-modal {
        width: 95% !important;
        max-width: none !important;
        bottom: 80px !important;
    }

    /* Picker categories - scroll horizontally */
    .ai-picker-categories {
        flex-wrap: nowrap !important;
        -webkit-overflow-scrolling: touch !important;
    }

    /* Chat messages - adjust padding */
    .ai-chat-messages {
        padding: 1rem 0 !important;
    }

    /* AI Message - responsive adjustments */
    .ai-message {
        gap: 0.75rem !important;
    }

    .ai-message-avatar {
        width: 32px !important;
        height: 32px !important;
        flex-shrink: 0 !important;
    }

    .ai-message-text {
        font-size: 0.875rem !important;
    }

    /* ============================================
       Activity Dashboard - Tablet (768px)
       ============================================ */

    /* Summary cards - 2x2 grid on tablet */
    #runs .stats-grid {
        grid-template-columns: repeat(2, 1fr) !important;
    }

    /* Activity filter buttons - scroll horizontally */
    #runs .card-header > div[style*="display: flex"] {
        flex-wrap: wrap !important;
    }

    .activity-filter-btn {
        padding: 0.375rem 0.625rem !important;
        font-size: 0.75rem !important;
    }

    /* Activity list - adjust padding */
    #activityListContainer {
        max-height: 500px !important;
    }

    /* Activity item - stack on smaller screens */
    .activity-item {
        flex-wrap: wrap !important;
    }

    .activity-details {
        width: calc(100% - 52px) !important;
    }

    .activity-actions {
        width: 100% !important;
        justify-content: flex-end !important;
        margin-top: 0.5rem !important;
        padding-left: 52px !important;
    }

    /* Active Automations card */
    #scheduledAutomationsCard .card-body > div {
        flex-direction: column !important;
        gap: 0.75rem !important;
    }

    /* ============================================
       Billing & Subscription - Tablet (768px)
       ============================================ */

    /* Current Plan header - Stack plan info and usage stats */
    #currentPlanCard > div:first-child {
        flex-direction: column !important;
        gap: 1.25rem !important;
    }

    #currentPlanCard > div:first-child > div:last-child {
        justify-content: flex-start !important;
        gap: 1.5rem !important;
    }

    /* Plan name - smaller on tablet */
    #currentPlanName {
        font-size: 1.5rem !important;
    }

    /* Plan details grid - 2x2 on tablet */
    #currentPlanCard > div[style*="grid-template-columns: repeat(auto-fit, minmax(150px, 1fr))"] {
        grid-template-columns: repeat(2, 1fr) !important;
    }

    /* Available plans grid - 2 columns on tablet */
    #planCards {
        grid-template-columns: repeat(2, 1fr) !important;
    }

    /* Plan cards - smaller padding */
    #planCards > div {
        padding: 1.25rem !important;
    }

    /* Plan card price - smaller */
    #planCards > div > div[style*="font-size: 2rem"] {
        font-size: 1.5rem !important;
    }

    /* Billing history table - Card layout */
    #billing .table-container table {
        display: block !important;
    }

    #billing .table-container table thead {
        display: none !important;
    }

    #billing .table-container table tbody {
        display: flex !important;
        flex-direction: column !important;
        gap: 0.75rem !important;
    }

    #billing .table-container table tbody tr {
        display: flex !important;
        flex-wrap: wrap !important;
        padding: 1rem !important;
        background: var(--bg-secondary) !important;
        border-radius: 12px !important;
        border: 1px solid var(--border-light) !important;
    }

    #billing .table-container table tbody td {
        border: none !important;
        padding: 0.25rem 0.5rem !important;
    }

    #billing .table-container table tbody td:first-child {
        width: 50% !important;
        font-weight: 600 !important;
    }

    #billing .table-container table tbody td:nth-child(2) {
        width: 50% !important;
    }

    #billing .table-container table tbody td:nth-child(3) {
        width: 33% !important;
    }

    #billing .table-container table tbody td:nth-child(4) {
        width: 33% !important;
    }

    #billing .table-container table tbody td:nth-child(5) {
        width: 34% !important;
        text-align: right !important;
    }
}

/* ============================================
   Small Mobile - 640px and below
   ============================================ */

@media (max-width: 640px) {
    .automations-grid {
        grid-template-columns: 1fr;
    }
}

/* ============================================
   Extra Small Mobile - 600px and below
   ============================================ */

@media (max-width: 600px) {
    .content {
        padding: 1rem;
        padding-top: 1rem;
    }

    .automation-grid {
        grid-template-columns: 1fr;
    }

    .modal-content {
        width: 95%;
        margin: 1rem;
        max-height: calc(100vh - 2rem);
    }

    /* Shopify Connected Dashboard - Extra Small */
    .shopify-dash-title {
        font-size: 1.125rem !important;
    }

    #shopifyDashSyncStatus {
        font-size: 0.6875rem !important;
    }

    /* Refresh button: Icon only on extra small */
    #shopifyDashSyncBtn .refresh-text {
        display: none;
    }

    #shopifyDashSyncBtn {
        padding: 0.5rem !important;
        min-width: 36px;
    }

    /* Hero cards: Stack to single column */
    .shopify-hero-row {
        grid-template-columns: 1fr !important;
        gap: 0.5rem !important;
    }

    .shopify-hero-card {
        padding: 0.875rem !important;
    }

    .shopify-hero-card .hero-value {
        font-size: 1.75rem !important;
    }

    /* Stat cards: Single column on extra small - full width */
    .shopify-stats-row {
        grid-template-columns: 1fr !important;
        gap: 0.5rem !important;
    }

    .shopify-stat-card {
        padding: 0.875rem !important;
        width: 100% !important;
    }

    .shopify-stat-card .stat-icon {
        width: 28px !important;
        height: 28px !important;
        margin-bottom: 0.375rem !important;
        border-radius: 8px !important;
    }

    .shopify-stat-card .stat-icon svg {
        width: 14px !important;
        height: 14px !important;
    }

    .shopify-stat-card .stat-value {
        font-size: 1rem !important;
    }

    .shopify-stat-card .stat-label {
        font-size: 0.5625rem !important;
    }

    .shopify-stat-card .stat-trend {
        display: none !important;
    }

    /* Charts */
    .shopify-chart-card {
        padding: 0.75rem !important;
    }

    .shopify-chart-card .chart-container {
        height: 160px !important;
    }

    .shopify-chart-card .donut-container {
        height: 100px !important;
    }

    .order-status-legend {
        margin-top: 0.5rem !important;
    }

    .order-status-legend .legend-item {
        gap: 0.125rem !important;
    }

    /* Footer: Simplified on extra small */
    .shopify-footer {
        flex-direction: column;
        text-align: center;
        padding: 0.625rem !important;
    }

    .shopify-footer .footer-details {
        justify-content: center;
        gap: 0.375rem !important;
    }

    .shopify-footer .footer-divider {
        display: none;
    }

    .shopify-footer .footer-item {
        flex-direction: column;
        gap: 0 !important;
    }

    .shopify-disconnect-btn {
        margin-top: 0.25rem;
    }

    /* All cards smaller padding */
    #shopifyConnectedDash .card {
        padding: 0.75rem;
    }

    /* Top products */
    #topSellingProductsList .top-product-item {
        padding: 0.75rem;
    }

    /* Charts - smaller height */
    .chart-container {
        height: 180px;
    }

    /* ============================================
       Product Health - Extra Small Screen
       ============================================ */

    /* Health Summary - 2x2 grid for counts */
    #productHealthSummaryCard > div > div:last-child {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 0.75rem !important;
    }

    #productHealthSummaryCard [style*="font-size: 3rem"] {
        font-size: 2rem !important;
    }

    #productHealthSummaryCard [style*="font-size: 1.25rem"] {
        font-size: 1rem !important;
    }

    /* Product cards - smaller padding */
    #productHealthTable tbody tr {
        padding: 0.75rem !important;
    }

    #productHealthTable tbody td:first-child img {
        width: 48px !important;
        height: 48px !important;
    }

    /* Score badge - smaller */
    #productHealthTable tbody td:nth-child(2) > div {
        padding: 0.25rem 0.5rem !important;
        font-size: 0.8125rem !important;
    }

    /* Issues button - smaller */
    #productHealthTable tbody td:nth-child(3) .btn {
        padding: 0.25rem 0.5rem !important;
        font-size: 0.75rem !important;
    }

    /* Filters card - smaller padding */
    #shopify-products .card {
        padding: 0.75rem !important;
    }

    /* Page header - smaller */
    #shopify-products .page-title {
        font-size: 1.25rem !important;
    }

    #shopify-products .page-subtitle {
        font-size: 0.8125rem !important;
    }

    /* Refresh button - icon only */
    #refreshProductHealth span,
    #refreshPageHealth span {
        display: none !important;
    }

    #refreshProductHealth,
    #refreshPageHealth {
        padding: 0.5rem !important;
    }

    /* ============================================
       Page Health - Extra Small Screen
       ============================================ */

    /* Page Health Summary - 2x2 grid for counts */
    #pageHealthSummaryCard > div > div:last-child {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 0.75rem !important;
    }

    #pageHealthSummaryCard [style*="font-size: 3rem"] {
        font-size: 2rem !important;
    }

    #pageHealthSummaryCard [style*="font-size: 1.25rem"] {
        font-size: 1rem !important;
    }

    /* Page Health Summary - Stack on very small */
    #pageHealthSummaryCard > div {
        flex-direction: column !important;
        gap: 1.25rem !important;
    }

    /* Page cards - smaller padding */
    #pageHealthTable tbody tr {
        padding: 0.75rem !important;
    }

    /* Score badge - smaller */
    #pageHealthTable tbody td:nth-child(3) > div {
        padding: 0.25rem 0.5rem !important;
        font-size: 0.8125rem !important;
    }

    /* Filter dropdowns - stack on extra small */
    #page-health .card [style*="grid-template-columns: 1fr 1fr"] {
        grid-template-columns: 1fr !important;
    }

    /* Filters card - smaller padding */
    #page-health .card {
        padding: 0.75rem !important;
    }

    /* Page header - smaller */
    #page-health .page-title {
        font-size: 1.25rem !important;
    }

    #page-health .page-subtitle {
        font-size: 0.8125rem !important;
    }

    /* ============================================
       Content Hub - Extra Small Screen
       ============================================ */

    /* Stats grid - single column on extra small */
    #content-hub .stats-grid {
        grid-template-columns: 1fr !important;
    }

    /* Quick actions - single column on extra small */
    #content-hub > div[style*="grid-template-columns: repeat(4, 1fr)"] {
        grid-template-columns: 1fr !important;
    }

    /* Quick action cards - horizontal layout */
    #content-hub > div[style*="grid-template-columns: repeat(4, 1fr)"] > .card {
        flex-direction: row !important;
        align-items: center !important;
    }

    /* Calendar - smaller day cells */
    .calendar-day {
        min-height: 48px !important;
        padding: 0.25rem !important;
    }

    .calendar-day-number {
        font-size: 0.6875rem !important;
    }

    .calendar-event {
        font-size: 0.5rem !important;
        padding: 1px 3px !important;
    }

    .calendar-day-header {
        padding: 0.375rem 0.125rem !important;
        font-size: 0.5rem !important;
    }

    /* Content table - Transform to cards */
    #content-hub .table-container table {
        display: block !important;
    }

    #content-hub .table-container table thead {
        display: none !important;
    }

    #content-hub .table-container table tbody {
        display: block !important;
    }

    #content-hub .table-container table tbody tr {
        display: flex !important;
        flex-direction: column !important;
        padding: 1rem !important;
        margin-bottom: 0.75rem !important;
        border: 1px solid var(--border-light) !important;
        border-radius: 12px !important;
        background: var(--bg-main) !important;
    }

    #content-hub .table-container table tbody td {
        display: block !important;
        padding: 0.25rem 0 !important;
        border: none !important;
        text-align: left !important;
    }

    #content-hub .table-container table tbody td:first-child {
        font-weight: 600 !important;
        margin-bottom: 0.5rem !important;
    }

    #content-hub .table-container table tbody td:last-child {
        margin-top: 0.5rem !important;
        padding-top: 0.5rem !important;
        border-top: 1px solid var(--border-light) !important;
    }

    /* Hide Platform and Date on extra small */
    #content-hub .table-container table tbody td:nth-child(3),
    #content-hub .table-container table tbody td:nth-child(5) {
        display: none !important;
    }

    /* Page header - smaller text */
    #content-hub .page-title {
        font-size: 1.25rem !important;
    }

    #content-hub .page-subtitle {
        font-size: 0.8125rem !important;
    }

    /* AI suggestions items - smaller */
    .ai-suggestion-item {
        padding: 0.625rem !important;
    }

    /* ============================================
       Revenue Health Score - Extra Small Screen
       ============================================ */

    /* Overall Score - smaller */
    #healthScoreValue {
        font-size: 2.75rem !important;
    }

    #healthScoreGrade {
        font-size: 0.875rem !important;
        margin-bottom: 1rem !important;
    }

    #healthScoreLossTotal {
        font-size: 0.8125rem !important;
        margin-bottom: 1rem !important;
    }

    /* Category Scores - single column on extra small */
    #healthCategoryScores {
        grid-template-columns: 1fr !important;
    }

    .health-score-card {
        padding: 1.25rem !important;
    }

    .health-score-card [style*="font-size: 2rem"] {
        font-size: 1.5rem !important;
    }

    /* Progress Tracking - 2 columns */
    #progressTrackingSection .card-body > div:first-child {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 0.75rem !important;
    }

    #progressTrackingSection [style*="font-size: 2rem"] {
        font-size: 1.5rem !important;
    }

    #progressTrackingSection [style*="padding: 1.25rem"] {
        padding: 1rem !important;
    }

    /* Revenue Leaks - smaller padding */
    #healthRevenueLeaks > div {
        padding: 1rem !important;
    }

    #healthRevenueLeaks [style*="font-size: 1.5rem"] {
        font-size: 1.25rem !important;
    }

    #healthRevenueLeaks [style*="font-size: 1.125rem"] {
        font-size: 1rem !important;
    }

    /* Score History Chart - smaller height */
    #scoreHistoryChartContainer {
        height: 150px !important;
    }

    /* Page header - smaller */
    #health-score .page-title {
        font-size: 1.25rem !important;
    }

    #health-score .page-subtitle {
        font-size: 0.8125rem !important;
    }

    /* ============================================
       Email Automations - Extra Small Screen
       ============================================ */

    /* Stats grid - Single column on extra small */
    #email-automations .stats-grid {
        grid-template-columns: 1fr !important;
    }

    /* Stat cards - horizontal compact layout */
    #email-automations .stat-card {
        display: flex !important;
        flex-direction: row !important;
        align-items: center !important;
        gap: 0.75rem !important;
        padding: 0.75rem !important;
    }

    #email-automations .stat-card .stat-icon {
        flex-shrink: 0 !important;
        width: 40px !important;
        height: 40px !important;
        margin-bottom: 0 !important;
    }

    #email-automations .stat-card .stat-value {
        font-size: 1.25rem !important;
    }

    /* Chart - Smaller height on extra small */
    #email-automations .card-body[style*="height: 250px"] {
        height: 180px !important;
    }

    /* Automation cards - Mini stats grid to 3 columns */
    #email-automations .card-body > div[style*="grid-template-columns: repeat(3, 1fr)"] {
        gap: 0.5rem !important;
    }

    #email-automations .card-body > div[style*="grid-template-columns: repeat(3, 1fr)"] > div [style*="font-size: 1.25rem"] {
        font-size: 1rem !important;
    }

    /* Action buttons - Stack on extra small */
    #email-automations .card-body > div[style*="display: flex"][style*="gap: 0.5rem"] {
        flex-direction: column !important;
    }

    #email-automations .card-body > div[style*="display: flex"][style*="gap: 0.5rem"] .btn {
        flex: none !important;
        width: 100% !important;
    }

    /* Page header - smaller */
    #email-automations .page-title {
        font-size: 1.25rem !important;
    }

    #email-automations .page-subtitle {
        font-size: 0.8125rem !important;
    }

    /* Cart Abandonment Modal - Extra Small */
    #cartAbandonmentModal .modal {
        padding: 1rem !important;
    }

    /* Email sequence timeline - Hide on extra small */
    #cartAbandonmentModal [style*="Email Sequence Timeline"] {
        display: none !important;
    }

    /* Email tabs - smaller on extra small */
    #cartAbandonmentModal .cart-email-tab {
        padding: 0.5rem !important;
        font-size: 0.75rem !important;
    }

    /* Email preview section - Hide on extra small to save space */
    #cartAbandonmentModal #cartEmailPreview {
        display: none !important;
    }

    /* Post-Purchase Modal - Extra Small */
    #postPurchaseModal .modal {
        padding: 1rem !important;
    }

    /* Review Request Modal - Extra Small */
    #reviewRequestModal .modal {
        padding: 1rem !important;
    }

    /* ============================================
       AI Assistant - Extra Small Screen
       ============================================ */

    /* Chat container - reduce padding */
    #ai-assistant .ai-chat-container {
        padding: 0 !important;
        height: calc(100vh - 120px) !important;
    }

    /* Welcome state - smaller */
    .ai-chat-welcome {
        padding: 1rem !important;
    }

    .ai-chat-logo {
        width: 60px !important;
        height: 60px !important;
        margin-bottom: 1rem !important;
    }

    .ai-chat-logo svg {
        width: 32px !important;
        height: 32px !important;
    }

    .ai-chat-greeting {
        font-size: 1.25rem !important;
    }

    .ai-chat-hint {
        font-size: 0.875rem !important;
        margin-bottom: 1rem !important;
    }

    /* Chat input - smaller */
    .ai-chat-input-wrapper {
        padding: 0.375rem !important;
        border-radius: 12px !important;
    }

    .ai-chat-input-container {
        border-radius: 10px !important;
    }

    .ai-chat-input {
        font-size: 0.875rem !important;
        padding: 0.5rem !important;
    }

    /* Input action buttons - smaller */
    .ai-input-action,
    .ai-input-send {
        width: 36px !important;
        height: 36px !important;
    }

    /* Inline form - compact */
    .ai-inline-form {
        max-height: 150px !important;
    }

    .ai-inline-field label {
        font-size: 0.6875rem !important;
    }

    .ai-inline-field input,
    .ai-inline-field textarea,
    .ai-inline-field select {
        padding: 0.5rem !important;
        font-size: 0.8125rem !important;
    }

    /* Selected automation - compact */
    .ai-selected-automation {
        padding: 0.375rem 0.5rem !important;
        border-radius: 10px 10px 0 0 !important;
    }

    .ai-selected-icon {
        font-size: 1rem !important;
    }

    .ai-selected-name {
        font-size: 0.8rem !important;
    }

    /* Picker modal - full screen */
    .ai-picker-modal {
        bottom: 70px !important;
        max-height: 60vh !important;
    }

    .ai-picker-header {
        padding: 0.75rem 1rem !important;
    }

    .ai-picker-search {
        padding: 0.5rem 1rem !important;
    }

    .ai-picker-categories {
        padding: 0.5rem 1rem !important;
    }

    .ai-picker-category {
        padding: 0.3rem 0.75rem !important;
        font-size: 0.75rem !important;
    }

    .ai-picker-item {
        padding: 0.625rem 0.75rem !important;
    }

    .ai-picker-item-icon {
        width: 32px !important;
        height: 32px !important;
    }

    .ai-picker-item-name {
        font-size: 0.8125rem !important;
    }

    .ai-picker-item-desc {
        font-size: 0.6875rem !important;
    }

    /* AI Messages - compact */
    .ai-message {
        gap: 0.5rem !important;
        padding: 0.75rem !important;
    }

    .ai-message-avatar {
        width: 28px !important;
        height: 28px !important;
    }

    .ai-message-role {
        font-size: 0.6875rem !important;
    }

    .ai-message-text {
        font-size: 0.8125rem !important;
    }

    /* Disclaimer - smaller */
    .ai-chat-disclaimer {
        font-size: 0.625rem !important;
        margin-top: 0.5rem !important;
    }

    /* ============================================
       Activity Dashboard - Extra Small Screen
       ============================================ */

    /* Summary cards - single column on extra small */
    #runs .stats-grid {
        grid-template-columns: 1fr !important;
        gap: 0.5rem !important;
    }

    /* Page header - smaller */
    #runs .page-title {
        font-size: 1.25rem !important;
    }

    #runs .page-subtitle {
        font-size: 0.8125rem !important;
    }

    /* Card header - stack on extra small */
    #runs .card-header {
        flex-direction: column !important;
        align-items: flex-start !important;
        gap: 0.75rem !important;
    }

    #runs .card-header > div[style*="display: flex"][style*="gap: 1rem"] {
        width: 100% !important;
        flex-direction: column !important;
        gap: 0.5rem !important;
    }

    /* Filter buttons - smaller */
    .activity-filter-btn {
        padding: 0.375rem 0.5rem !important;
        font-size: 0.6875rem !important;
    }

    .activity-filter-btn svg {
        width: 12px !important;
        height: 12px !important;
    }

    /* Refresh button - icon only */
    #refreshRunsButton span,
    #refreshRunsButton .refresh-text {
        display: none !important;
    }

    #refreshRunsButton {
        padding: 0.5rem !important;
    }

    /* Activity list - reduced height */
    #activityListContainer {
        max-height: 400px !important;
    }

    /* Activity item - compact */
    .activity-item {
        padding: 0.75rem !important;
        gap: 0.75rem !important;
    }

    .activity-icon {
        width: 32px !important;
        height: 32px !important;
    }

    .activity-icon svg {
        width: 14px !important;
        height: 14px !important;
    }

    .activity-title {
        font-size: 0.875rem !important;
    }

    .activity-meta {
        font-size: 0.75rem !important;
        gap: 0.375rem !important;
    }

    .activity-meta .badge {
        font-size: 0.5625rem !important;
        padding: 0.125rem 0.375rem !important;
    }

    /* Activity actions - smaller buttons */
    .activity-actions .btn {
        padding: 0.375rem !important;
    }

    .activity-actions .btn svg {
        width: 12px !important;
        height: 12px !important;
    }

    /* Date group headers - smaller */
    .activity-date-group {
        padding: 0.5rem 0.75rem !important;
        font-size: 0.625rem !important;
    }

    /* Empty state - compact */
    #activityEmptyState {
        padding: 2rem 1rem !important;
    }

    #activityEmptyState svg {
        width: 48px !important;
        height: 48px !important;
    }

    #activityEmptyState h3 {
        font-size: 1rem !important;
    }

    #activityEmptyState p {
        font-size: 0.8125rem !important;
    }

    /* Scheduled automations card - smaller */
    #scheduledAutomationsCard .card-header h3 {
        font-size: 0.9375rem !important;
    }

    /* ============================================
       Billing & Subscription - Extra Small (600px)
       ============================================ */

    /* Page header - smaller */
    #billing .page-title {
        font-size: 1.25rem !important;
    }

    #billing .page-subtitle {
        font-size: 0.8125rem !important;
    }

    /* Current Plan card - compact layout */
    #currentPlanCard {
        padding: 1rem !important;
    }

    #currentPlanName {
        font-size: 1.25rem !important;
    }

    #currentPlanPrice {
        font-size: 0.875rem !important;
    }

    /* Usage stats - smaller */
    #currentPlanCard > div:first-child > div:last-child {
        gap: 1rem !important;
    }

    #currentPlanCard > div:first-child > div:last-child > div [style*="font-size: 1.5rem"] {
        font-size: 1.25rem !important;
    }

    /* Usage bars - thinner */
    #currentPlanCard > div[style*="margin-bottom: 1.5rem"] > div > div[style*="flex: 1"] {
        height: 6px !important;
    }

    /* Plan details grid - 2x2 on extra small */
    #currentPlanCard > div[style*="grid-template-columns: repeat(auto-fit, minmax(150px, 1fr))"] {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 0.75rem !important;
        padding: 0.75rem !important;
    }

    /* Available plans - Single column on extra small */
    #planCards {
        grid-template-columns: 1fr !important;
    }

    /* Plan cards - compact */
    #planCards > div {
        padding: 1rem !important;
    }

    /* Plan card title - smaller */
    #planCards > div h4 {
        font-size: 1.125rem !important;
    }

    /* Plan card price - smaller */
    #planCards > div > div[style*="font-size: 2rem"] {
        font-size: 1.25rem !important;
    }

    #planCards > div > div[style*="font-size: 2rem"] span {
        font-size: 0.875rem !important;
    }

    /* Plan features list - smaller text */
    #planCards > div ul li {
        font-size: 0.8125rem !important;
    }

    /* Plan buttons - full width */
    #planCards > div .btn {
        padding: 0.625rem 1rem !important;
        font-size: 0.875rem !important;
    }

    /* Payment method card - compact */
    #paymentMethodCard .card-body {
        padding: 1rem !important;
    }

    /* Billing history - Simplified card layout */
    #billing .table-container table tbody tr {
        padding: 0.75rem !important;
    }

    #billing .table-container table tbody td {
        padding: 0.125rem 0.25rem !important;
        font-size: 0.8125rem !important;
    }

    #billing .table-container table tbody td:first-child {
        width: 100% !important;
        margin-bottom: 0.375rem !important;
    }

    #billing .table-container table tbody td:nth-child(2) {
        width: 100% !important;
        font-size: 0.75rem !important;
        color: var(--text-secondary) !important;
        margin-bottom: 0.375rem !important;
    }

    #billing .table-container table tbody td:nth-child(3),
    #billing .table-container table tbody td:nth-child(4) {
        width: 50% !important;
    }

    #billing .table-container table tbody td:nth-child(5) {
        width: 100% !important;
        margin-top: 0.5rem !important;
        padding-top: 0.5rem !important;
        border-top: 1px solid var(--border-light) !important;
    }

    #billing .table-container table tbody td:nth-child(5) .btn {
        width: 100% !important;
    }

    /* Cancel subscription section - stack */
    #cancelSubscriptionSection {
        padding-top: 1rem !important;
        margin-top: 1rem !important;
    }

    #cancelSubscriptionSection .btn {
        width: 100% !important;
    }
}

/* ============================================
   Utility Classes
   ============================================ */

.hidden {
    display: none;
}

.text-muted {
    color: var(--text-muted);
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* Flex utilities */
.flex {
    display: flex;
}

.flex-col {
    flex-direction: column;
}

.items-center {
    align-items: center;
}

.justify-center {
    justify-content: center;
}

.justify-between {
    justify-content: space-between;
}

.gap-1 {
    gap: 0.25rem;
}

.gap-2 {
    gap: 0.5rem;
}

.gap-3 {
    gap: 0.75rem;
}

.gap-4 {
    gap: 1rem;
}

/* Text utilities */
.text-center {
    text-align: center;
}

.text-right {
    text-align: right;
}

.font-bold {
    font-weight: 700;
}

.font-semibold {
    font-weight: 600;
}

.font-medium {
    font-weight: 500;
}

/* Margin utilities */
.mt-1 { margin-top: 0.25rem; }
.mt-2 { margin-top: 0.5rem; }
.mt-3 { margin-top: 0.75rem; }
.mt-4 { margin-top: 1rem; }

.mb-1 { margin-bottom: 0.25rem; }
.mb-2 { margin-bottom: 0.5rem; }
.mb-3 { margin-bottom: 0.75rem; }
.mb-4 { margin-bottom: 1rem; }

/* Padding utilities */
.p-1 { padding: 0.25rem; }
.p-2 { padding: 0.5rem; }
.p-3 { padding: 0.75rem; }
.p-4 { padding: 1rem; }

/* Width utilities */
.w-full {
    width: 100%;
}

/* Overflow utilities */
.overflow-hidden {
    overflow: hidden;
}

.overflow-auto {
    overflow: auto;
}

/* Border utilities */
.rounded {
    border-radius: 8px;
}

.rounded-lg {
    border-radius: 12px;
}

.rounded-full {
    border-radius: 9999px;
}

/* Transition utilities */
.transition {
    transition: all 0.15s ease;
}

.transition-colors {
    transition: color 0.15s ease, background-color 0.15s ease, border-color 0.15s ease;
}

/* ============================================
   Admin Panel - Tablet (1024px and below)
   ============================================ */
@media (max-width: 1024px) {
    .admin-sub-tabs {
        flex-wrap: nowrap !important;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        padding-bottom: 4px;
    }
    .admin-stats-row {
        grid-template-columns: repeat(2, 1fr) !important;
    }
    #admin .table-container {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
}

/* ============================================
   Admin Panel - Mobile (768px and below)
   ============================================ */
@media (max-width: 768px) {
    .admin-sub-tabs {
        gap: 0.375rem !important;
        margin-bottom: 1rem !important;
    }
    .admin-sub-tabs .activity-filter-btn {
        padding: 0.375rem 0.625rem !important;
        font-size: 0.75rem !important;
        flex-shrink: 0;
    }
    .admin-stats-row {
        grid-template-columns: 1fr !important;
        gap: 0.75rem !important;
    }
    .admin-stats-row .stat-card {
        display: flex !important;
        flex-direction: row !important;
        align-items: center !important;
        gap: 0.75rem !important;
        padding: 0.75rem 1rem !important;
    }
    .admin-stats-row .stat-card .stat-icon {
        flex-shrink: 0 !important;
        margin-bottom: 0 !important;
    }
    .admin-stats-row .stat-card .stat-value {
        font-size: 1.25rem !important;
    }
    .admin-grid-2col {
        grid-template-columns: 1fr !important;
    }
    #admin [style*="grid-template-columns: 1fr 1fr"],
    #admin [style*="grid-template-columns:1fr 1fr"] {
        grid-template-columns: 1fr !important;
    }
    .admin-filter-body.open {
        flex-direction: column;
        align-items: stretch;
    }
    .admin-filter-body.open input,
    .admin-filter-body.open select {
        width: 100% !important;
        min-width: unset !important;
    }
    #admin .table-container table {
        min-width: 600px;
    }
    #admin .btn,
    #admin .btn-sm {
        min-height: 44px;
        min-width: 44px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }
    #admin .page-title {
        font-size: 1.5rem !important;
    }
    #admin .card {
        padding: 1rem;
    }
    #admin [style*="grid-template-columns:1fr 1fr 1fr"] {
        grid-template-columns: 1fr !important;
    }
}

/* ============================================
   Admin Panel - Extra Small (480px and below)
   ============================================ */
@media (max-width: 480px) {
    .admin-sub-tabs .activity-filter-btn {
        padding: 0.25rem 0.5rem !important;
        font-size: 0.6875rem !important;
    }
    .admin-stats-row .stat-card .stat-value {
        font-size: 1.125rem !important;
    }
    #admin .page-title {
        font-size: 1.25rem !important;
    }
    .admin-date-presets {
        flex-wrap: wrap;
    }
}

/* ============================================
   Workflow Builder Responsive
   ============================================ */

@media (max-width: 1024px) {
    .wf-builder-layout {
        grid-template-columns: 1fr;
    }
    .wf-inspector {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        top: auto;
        max-height: 60vh;
        border-radius: 16px 16px 0 0;
        z-index: 100;
        transform: translateY(100%);
        transition: transform 0.3s ease;
        box-shadow: 0 -4px 24px rgba(0,0,0,0.1);
    }
    .wf-inspector.open {
        transform: translateY(0);
    }
    .wf-inspector-empty {
        display: none;
    }
    .wf-pipeline-canvas {
        padding: 1rem 0.5rem 12rem;
    }
}

@media (max-width: 768px) {
    .wf-list-header {
        flex-direction: column;
    }
    .wf-stats-row {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 0.5rem;
    }
    .wf-stat-chip {
        flex-direction: column;
        gap: 0.125rem;
        text-align: center;
        padding: 0.625rem 0.5rem;
    }
    /* Convert table to cards on mobile */
    .wf-table thead { display: none; }
    .wf-table tbody tr {
        display: flex;
        flex-wrap: wrap;
        padding: 0.875rem 1rem;
        gap: 0.5rem;
        align-items: center;
    }
    .wf-table td {
        padding: 0;
        border: none;
    }
    .wf-table td:nth-child(1) { flex: 1 1 100%; }
    .wf-table td:nth-child(2) { order: -1; }
    .wf-table td:nth-child(3) { flex: 1 1 100%; font-size: 0.8125rem; }
    .wf-table td:nth-child(4),
    .wf-table td:nth-child(5) { font-size: 0.75rem; color: var(--text-muted); }
    .wf-table td:nth-child(6) { margin-left: auto; }

    .wf-templates-overlay { padding: 1rem; }
    .wf-templates-toolbar { flex-direction: column; }
    .wf-search-input { width: 100%; min-width: 0; }
    .wf-category-pills { flex-wrap: wrap; }
    .wf-templates-grid { grid-template-columns: 1fr; }

    .wf-creation-panel { padding: 1.5rem; }
    .wf-creation-options { grid-template-columns: 1fr; }
    .wf-trigger-grid { grid-template-columns: 1fr; }

    .wf-topbar {
        flex-direction: column;
        align-items: flex-start;
    }
    .wf-topbar-right {
        width: 100%;
        justify-content: space-between;
    }
}

@media (max-width: 480px) {
    .wf-stat-chip {
        font-size: 0.8125rem;
    }
    .wf-tpl-card { padding: 1.125rem; }
    .wf-step { padding: 0.75rem 1rem; }
    .wf-builder-title { font-size: 1rem; }
}
