/* ============================================
   AffiliateTracker - Main Light Theme Stylesheet
   ============================================ */

:root {
    --primary:      #7c3aed;
    --primary-dark: #6d28d9;
    --primary-light:#f3e8ff;
    --secondary:    #10B981;
    --warning:      #F59E0B;
    --danger:       #EF4444;
    --info:         #0ea5e9;
    --bg:           #F5F7FA;
    --sidebar-bg:   rgba(255, 255, 255, 0.82);
    --card-bg:      rgba(255, 255, 255, 0.68);
    --border:       rgba(226, 232, 240, 0.65);
    --text:         #1E293B;
    --text-muted:   #64748B;
    --text-light:   #94A3B8;
    --shadow:       0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.05);
    --shadow-md:    0 4px 6px rgba(0,0,0,.07), 0 2px 4px rgba(0,0,0,.05);
    --radius:       10px;
    --radius-sm:    6px;
    --sidebar-w:    250px;
    --topbar-h:     64px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Inter', sans-serif;
    background:
        radial-gradient(circle at 10% 20%, rgba(124, 58, 237, 0.12), transparent 45%),
        radial-gradient(circle at 90% 80%, rgba(14, 165, 233, 0.10), transparent 45%),
        radial-gradient(circle at 50% 50%, rgba(232, 25, 122, 0.08), transparent 45%),
        #F5F7FA;
    background-size: 180% 180%;
    animation: mesh-float 25s ease infinite;
    background-attachment: fixed;
    color: var(--text);
    font-size: 15px;
    line-height: 1.65;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── Layout ── */
.app-layout {
    display: flex;
    min-height: 100vh;
}

/* ── Sidebar ── */
.sidebar {
    width: var(--sidebar-w);
    background: var(--sidebar-bg);
    border-right: 1px solid var(--border);
    display: block;
    position: fixed;
    top: 0; left: 0; bottom: 0;
    height: 100vh;
    height: 100dvh;
    z-index: 100;
    transition: width .25s;
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 24px;
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
}
.sidebar-top {
    display: flex;
    align-items: center;
    border-bottom: 1px solid var(--border);
}
.sidebar-logo {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 20px 20px 16px;
    font-weight: 700;
    font-size: 16px;
    color: var(--primary);
    text-decoration: none;
    flex: 1;
}
.mobile-close-btn {
    display: none;
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 8px;
    margin-right: 8px;
    border-radius: var(--radius-sm);
    transition: .15s;
}
.mobile-close-btn:hover { background: var(--bg); color: var(--text); }
.sidebar-logo .logo-icon {
    width: 36px; height: 36px;
    background: var(--primary);
    border-radius: 8px;
    display: flex; align-items: center; justify-content: center;
    color: #fff;
    font-size: 18px;
    flex-shrink: 0;
}
.sidebar-section {
    padding: 12px 12px 4px;
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .08em;
    color: var(--text-light);
}
.nav-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    margin: 1px 8px;
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    font-size: 14px;
    font-weight: 500;
    transition: .15s;
    text-decoration: none;
}
.nav-link:hover { background: var(--primary-light); color: var(--primary); text-decoration: none; }
.nav-link.active { background: var(--primary-light); color: var(--primary); font-weight: 600; }
.nav-link svg { flex-shrink: 0; width: 16px; height: 16px; }
.nav-badge {
    margin-left: auto;
    background: var(--danger);
    color: #fff;
    font-size: 10px;
    font-weight: 700;
    padding: 1px 6px;
    border-radius: 20px;
}

/* ── Main content ── */
.main-content {
    margin-left: var(--sidebar-w);
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* ── Topbar ── */
.topbar {
    height: var(--topbar-h);
    background: linear-gradient(90deg, #e9e3fa 0%, #e0e9fa 50%, #e0f2fa 100%);
    border-bottom: none;
    display: flex;
    align-items: center;
    padding: 0 24px;
    gap: 16px;
    position: sticky;
    top: 0;
    z-index: 1000;  /* Outrank .dash-header (position:relative => its own
                       stacking context) so topbar dropdowns paint above it. */
}
/* Theme picker + topbar dropdowns must escape any clipping ancestor.
   The menu keeps its own overflow:hidden so button corners follow the
   rounded border-radius, but its ancestors must stay overflow:visible. */
.topbar-actions,
.theme-picker { overflow: visible !important; }
.theme-picker-menu {
    z-index: 9999 !important;
    max-height: none !important;
}
.theme-picker-opt { min-height: 36px; }
.topbar-title {
    font-size: 17px;
    font-weight: 700;
    color: var(--text);
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.topbar-actions { display: flex; align-items: center; gap: 12px; }

.notification-btn {
    position: relative;
    width: 38px; height: 38px;
    border-radius: 50%;
    background: var(--bg);
    border: 1px solid var(--border);
    display: flex; align-items: center; justify-content: center;
    cursor: pointer;
    color: var(--text-muted);
    transition: .15s;
}
.notification-btn:hover { background: var(--primary-light); color: var(--primary); }
.notif-badge {
    position: absolute;
    top: -2px; right: -2px;
    background: var(--danger);
    color: #fff;
    font-size: 9px;
    min-width: 16px; height: 16px; padding: 0 4px; box-sizing: border-box; border-radius: 10px;
    display: flex; align-items: center; justify-content: center;
    font-weight: 700;
}
.user-menu {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 12px;
    border-radius: var(--radius);
    background: var(--bg);
    border: 1px solid var(--border);
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    color: var(--text);
    transition: .15s;
    position: relative;
}
.user-menu:hover { border-color: var(--primary); }
.user-avatar {
    width: 28px; height: 28px;
    border-radius: 50%;
    background: var(--primary);
    color: #fff;
    font-weight: 700;
    font-size: 12px;
    display: flex; align-items: center; justify-content: center;
}
.dropdown-menu {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-md);
    min-width: 160px;
    display: none;
    z-index: 9999;   /* must be above sidebar (200) and sidebar backdrop (199) on mobile */
    overflow: hidden;
}
.dropdown-menu.show { display: block; }
.dropdown-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 9px 14px;
    font-size: 13px;
    color: var(--text);
    transition: .1s;
    text-decoration: none;
}
.dropdown-item:hover { background: var(--bg); text-decoration: none; }
.dropdown-divider { border: none; border-top: 1px solid var(--border); margin: 4px 0; }

/* ── Page body ── */
.page-body {
    padding: 24px;
    flex: 1;
}

/* ── Page header ── */
.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 24px;
}
.page-header h1 {
    font-size: 24px;
    font-weight: 700;
    color: var(--text);
}
.page-header p {
    font-size: 14px;
    color: var(--text-muted);
    margin-top: 2px;
}

/* ── Stat cards ── */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}
.stat-card {
    background: linear-gradient(145deg, rgba(255, 255, 255, 0.95), rgba(248, 250, 252, 0.88));
    border: 1px solid rgba(226, 232, 240, 0.85);
    border-radius: 16px;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.05), 0 8px 10px -6px rgba(0, 0, 0, 0.02), inset 0 1px 0 rgba(255, 255, 255, 0.95);
    transition: transform 0.28s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.28s ease, border-color 0.28s ease;
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    position: relative;
    overflow: hidden;
}
.stat-card:hover {
    box-shadow: 0 20px 35px -8px rgba(124, 58, 237, 0.18), inset 0 1px 0 rgba(255, 255, 255, 0.95);
    transform: translateY(-5px) scale(1.015);
    border-color: rgba(124, 58, 237, 0.35);
}
.stat-label { font-size: 11.5px; color: var(--text-muted); font-weight: 700; text-transform: uppercase; letter-spacing: .07em; }
.stat-value { font-size: 28px; font-weight: 800; color: var(--text); line-height: 1.2; overflow-wrap: anywhere; word-break: break-word; }
.stat-sub { font-size: 13px; color: var(--text-light); }
.stat-icon {
    width: 42px; height: 42px;
    border-radius: 12px;
    display: flex; align-items: center; justify-content: center;
    font-size: 19px;
    margin-bottom: 8px;
    align-self: flex-start;
    box-shadow: 0 4px 12px rgba(0,0,0,0.06), inset 0 1px 0 rgba(255,255,255,0.8);
    transition: transform 0.2s ease;
}
.stat-card:hover .stat-icon {
    transform: scale(1.08) rotate(3deg);
}
.stat-icon.blue   { background: linear-gradient(135deg, #EFF6FF, #DBEAFE); color: #2563EB; border: 1px solid #BFDBFE; }
.stat-icon.green  { background: linear-gradient(135deg, #F0FDF4, #DCFCE7); color: #16A34A; border: 1px solid #BBF7D0; }
.stat-icon.orange { background: linear-gradient(135deg, #FFF7ED, #FFEDD5); color: #EA580C; border: 1px solid #FED7AA; }
.stat-icon.purple { background: linear-gradient(135deg, #F5F3FF, #EDE9FE); color: #7C3AED; border: 1px solid #DDD6FE; }
.stat-icon.red    { background: linear-gradient(135deg, #FEF2F2, #FEE2E2); color: #DC2626; border: 1px solid #FECACA; }
.stat-icon.teal   { background: linear-gradient(135deg, #F0FDFA, #CCFBF1); color: #0F766E; border: 1px solid #99F6E4; }

/* ── Cards ── */
.card {
    background: linear-gradient(145deg, rgba(255, 255, 255, 0.95), rgba(248, 250, 252, 0.88));
    border: 1px solid rgba(226, 232, 240, 0.85);
    border-radius: 16px;
    box-shadow: 0 12px 30px -6px rgba(0, 0, 0, 0.05), 0 4px 12px -2px rgba(0, 0, 0, 0.02), inset 0 1px 0 rgba(255, 255, 255, 0.9);
    overflow: hidden;
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    transition: transform 0.25s ease, box-shadow 0.25s ease;
}
.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
    background: rgba(248, 250, 252, 0.5);
}
.card-title {
    font-size: 16px;
    font-weight: 800;
    color: var(--text);
}
.card-body { padding: 20px; }
.card-footer {
    padding: 12px 20px;
    border-top: 1px solid var(--border);
    background: rgba(248, 250, 252, 0.7);
    font-size: 13px;
    color: var(--text-muted);
}

/* ════════════════════════════════════════
   MODERN TABLE SYSTEM
   ════════════════════════════════════════ */

/* ── Wrapper ── */
.table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

/* ── Base table ── */
table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13.5px;
}

/* ── Header ── */
thead tr {
    background: linear-gradient(135deg, #F0F4FF 0%, #EAF0FF 100%);
}
thead th {
    padding: 14px 18px;
    text-align: left;
    font-weight: 700;
    color: #4338CA;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: .09em;
    border-bottom: 2px solid #DDE4F9;
    white-space: nowrap;
    position: relative;
    user-select: none;
    transition: color .15s, background .15s;
}
thead th:first-child { padding-left: 22px; border-radius: 0; }
thead th:last-child  { padding-right: 22px; }

/* ── DataTables sort icons ── */
thead th.sorting,
thead th.sorting_asc,
thead th.sorting_desc {
    cursor: pointer;
    padding-right: 30px;
}
thead th.sorting::after,
thead th.sorting_asc::after,
thead th.sorting_desc::after {
    content: '';
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    width: 14px;
    height: 14px;
    background-size: 14px;
    background-repeat: no-repeat;
    background-position: center;
    opacity: .35;
    transition: opacity .15s;
}
thead th.sorting::after {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%234338CA' stroke-width='2.5'%3E%3Cpath d='M7 15l5 5 5-5M7 9l5-5 5 5'/%3E%3C/svg%3E");
}
thead th.sorting_asc::after {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%234338CA' stroke-width='2.5'%3E%3Cpath d='M7 15l5 5 5-5'/%3E%3C/svg%3E");
    opacity: 1;
}
thead th.sorting_desc::after {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%234338CA' stroke-width='2.5'%3E%3Cpath d='M7 9l5-5 5 5'/%3E%3C/svg%3E");
    opacity: 1;
}
thead th:hover.sorting,
thead th:hover.sorting_asc,
thead th:hover.sorting_desc {
    color: #3730A3;
    background: #E5EDFF;
}
thead th:hover.sorting::after,
thead th:hover.sorting_asc::after,
thead th:hover.sorting_desc::after { opacity: 1; }

/* ── Body rows ── */
tbody td {
    padding: 14px 18px;
    border-bottom: 1px solid #F1F5FB;
    color: var(--text);
    vertical-align: middle;
    transition: background .1s;
}
tbody td:first-child { padding-left: 22px; }
tbody td:last-child  { padding-right: 22px; }

/* Zebra rows */
tbody tr:nth-child(even) td { background: rgba(79, 70, 229, 0.015); }
tbody tr:nth-child(odd)  td { background: transparent; }

/* Hover */
tbody tr { position: relative; }
tbody tr:hover td { background: #EEF2FF !important; }
tbody tr:hover td:first-child { box-shadow: inset 3px 0 0 #4F46E5; }
tbody tr:last-child td { border-bottom: none; }

/* ── Column types ── */
td.col-num, th.col-num { text-align: right; }
td.col-center, th.col-center { text-align: center; }
td.col-mono { font-family: 'SF Mono', 'Fira Code', 'Courier New', monospace; font-size: 12.5px; }

/* ── Text helpers inside tables ── */
.tbl-primary   { font-weight: 700; color: var(--text); font-size: 14px; }
.tbl-secondary { font-size: 12px; color: var(--text-muted); margin-top: 2px; }
.tbl-code      { font-family: 'SF Mono', 'Fira Code', monospace; font-size: 12px; background: #EEF2FF; color: #4F46E5; padding: 2px 8px; border-radius: 5px; display: inline-block; letter-spacing: .02em; border: 1px solid #DDE3F7; }

/* ── Action cell ── */
.tbl-actions { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }

/* ── No-data row ── */
tbody tr.no-data td,
.dataTables_empty {
    text-align: center;
    padding: 56px 20px !important;
    color: var(--text-muted) !important;
    font-size: 14px !important;
    font-weight: 500 !important;
    background: #fff !important;
    box-shadow: none !important;
}
.dataTables_empty::before {
    content: '';
    display: block;
    width: 48px;
    height: 48px;
    margin: 0 auto 14px;
    background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='48' height='48' viewBox='0 0 24 24' fill='none' stroke='%23C7D2FE' stroke-width='1.5'%3E%3Cellipse cx='12' cy='5' rx='9' ry='3'/%3E%3Cpath d='M21 12c0 1.66-4.03 3-9 3S3 13.66 3 12'/%3E%3Cpath d='M3 5v14c0 1.66 4.03 3 9 3s9-1.34 9-3V5'/%3E%3C/svg%3E") no-repeat center;
    background-size: 48px;
    opacity: .6;
}

/* ── Card + table: clip rounded corners ── */
.card .table-wrap {
    border-radius: 0 0 var(--radius) var(--radius);
    overflow: hidden;
}
.card .table-wrap table {
    border-radius: 0;
}

/* ════════════════════════════════════════
   DATATABLES OVERRIDES — MODERN TOOLBAR
   ════════════════════════════════════════ */

.dataTables_wrapper {
    font-size: 13px;
}

/* Wrapper gets a subtle premium border */
.card .dataTables_wrapper {
    border-radius: var(--radius);
}

/* ── Top toolbar (length + search) ── */
.dataTables_wrapper .dataTables_length,
.dataTables_wrapper .dataTables_filter {
    padding: 14px 22px 12px;
    background: #FAFBFF;
}
.dataTables_wrapper .dataTables_length { float: left; }
.dataTables_wrapper .dataTables_filter { float: right; }

.dataTables_wrapper .dataTables_length label,
.dataTables_wrapper .dataTables_filter label {
    font-size: 12.5px;
    font-weight: 600;
    color: #64748B;
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 0;
    letter-spacing: .01em;
}

/* Show N entries select */
.dataTables_wrapper .dataTables_length select {
    padding: 7px 30px 7px 12px;
    border: 1.5px solid #E2E8F0;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
    color: #334155;
    background: #F8FAFC url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%234F46E5' fill='none' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") no-repeat right 10px center;
    appearance: none;
    cursor: pointer;
    transition: border-color .15s, box-shadow .15s, background .15s;
    box-shadow: 0 1px 3px rgba(0,0,0,.05);
}
.dataTables_wrapper .dataTables_length select:hover {
    border-color: #A5B4FC;
    background-color: #fff;
}
.dataTables_wrapper .dataTables_length select:focus {
    outline: none;
    border-color: #4F46E5;
    background-color: #fff;
    box-shadow: 0 0 0 3px rgba(79,70,229,.12);
}

/* Search input */
.dataTables_wrapper .dataTables_filter input {
    padding: 8px 14px 8px 36px;
    border: 1.5px solid #E2E8F0;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 500;
    color: #334155;
    background: #F8FAFC url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%234F46E5' stroke-width='2'%3E%3Ccircle cx='11' cy='11' r='8'/%3E%3Cpath d='M21 21l-4.35-4.35'/%3E%3C/svg%3E") no-repeat 11px center;
    transition: border-color .15s, box-shadow .15s, width .2s, background .15s;
    width: 200px;
    box-shadow: 0 1px 3px rgba(0,0,0,.05);
}
.dataTables_wrapper .dataTables_filter input:hover {
    border-color: #A5B4FC;
    background-color: #fff;
}
.dataTables_wrapper .dataTables_filter input:focus {
    outline: none;
    border-color: #4F46E5;
    background-color: #fff;
    box-shadow: 0 0 0 3px rgba(79,70,229,.12);
    width: 250px;
}
.dataTables_wrapper .dataTables_filter input::placeholder { color: #94A3B8; }

/* Divider between toolbar and table */
.dataTables_wrapper .dataTables_length,
.dataTables_wrapper .dataTables_filter {
    border-bottom: 1px solid #EEF2FF;
    padding-bottom: 12px;
}

/* Clear floats */
.dataTables_wrapper::after { content: ''; display: table; clear: both; }

/* ── Bottom bar (info + pagination) ── */
.dataTables_wrapper .dataTables_info,
.dataTables_wrapper .dataTables_paginate {
    padding: 14px 22px;
    font-size: 12.5px;
    color: #94A3B8;
    font-weight: 500;
    background: linear-gradient(135deg, #F8FAFF 0%, #F5F7FF 100%);
    border-top: 1px solid #EEF2FF;
}
.dataTables_wrapper .dataTables_info { float: left; line-height: 32px; }
.dataTables_wrapper .dataTables_paginate { float: right; }
.dataTables_wrapper .dataTables_paginate::after { content: ''; display: table; clear: both; }

/* Pagination buttons */
.dataTables_wrapper .dataTables_paginate .paginate_button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 32px;
    height: 32px;
    padding: 0 10px;
    border-radius: 8px;
    font-size: 12.5px;
    font-weight: 600;
    color: #64748B !important;
    cursor: pointer;
    border: 1.5px solid transparent !important;
    margin: 0 2px;
    transition: all .15s;
    background: transparent !important;
    box-shadow: none !important;
}
.dataTables_wrapper .dataTables_paginate .paginate_button:hover:not(.disabled) {
    background: #EEF2FF !important;
    color: #4F46E5 !important;
    border-color: #C7D2FE !important;
}
.dataTables_wrapper .dataTables_paginate .paginate_button.current,
.dataTables_wrapper .dataTables_paginate .paginate_button.current:hover {
    background: linear-gradient(135deg, #4F46E5, #6D28D9) !important;
    color: #fff !important;
    border-color: transparent !important;
    box-shadow: 0 2px 8px rgba(79,70,229,.35) !important;
}
.dataTables_wrapper .dataTables_paginate .paginate_button.disabled,
.dataTables_wrapper .dataTables_paginate .paginate_button.disabled:hover {
    color: #CBD5E1 !important;
    cursor: not-allowed;
    background: transparent !important;
}
/* Previous / Next pill style */
.dataTables_wrapper .dataTables_paginate .paginate_button.previous,
.dataTables_wrapper .dataTables_paginate .paginate_button.next {
    padding: 0 14px;
    border: 1.5px solid #E2E8F0 !important;
    background: #fff !important;
    color: #475569 !important;
    font-weight: 600;
}
.dataTables_wrapper .dataTables_paginate .paginate_button.previous:hover:not(.disabled),
.dataTables_wrapper .dataTables_paginate .paginate_button.next:hover:not(.disabled) {
    background: #EEF2FF !important;
    border-color: #A5B4FC !important;
    color: #4F46E5 !important;
}
.dataTables_wrapper .dataTables_paginate .paginate_button.previous.disabled,
.dataTables_wrapper .dataTables_paginate .paginate_button.next.disabled {
    border-color: #F1F5F9 !important;
    background: #FAFAFA !important;
    color: #CBD5E1 !important;
}
.dataTables_wrapper .dataTables_paginate .ellipsis {
    color: #94A3B8;
    padding: 0 4px;
    line-height: 32px;
    display: inline-block;
}

/* ── Responsive ── */
@media (max-width: 640px) {
    .dataTables_wrapper .dataTables_length,
    .dataTables_wrapper .dataTables_filter { float: none; padding: 12px 16px 10px; }
    .dataTables_wrapper .dataTables_info,
    .dataTables_wrapper .dataTables_paginate { float: none; padding: 10px 16px; text-align: center; }
    .dataTables_wrapper .dataTables_filter input { width: 100%; }
    .dataTables_wrapper .dataTables_filter input:focus { width: 100%; }
    thead th { padding: 11px 12px; font-size: 10.5px; }
    tbody td  { padding: 12px 12px; font-size: 13px; }
    thead th:first-child, tbody td:first-child { padding-left: 14px; }
    thead th:last-child,  tbody td:last-child  { padding-right: 14px; }
}
@media (max-width: 360px) {
    thead th { padding: 9px 10px; font-size: 10px; }
    tbody td  { padding: 9px 10px; font-size: 12px; }
}

/* ── Badges ── */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 4px 11px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .05em;
    line-height: 1;
    white-space: nowrap;
    box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}
.badge-success { background: linear-gradient(135deg, #DCFCE7, #F0FDF4); color: #15803D; border: 1px solid #BBF7D0; }
.badge-warning { background: linear-gradient(135deg, #FEF9C3, #FFFBE0); color: #92400E; border: 1px solid #FDE68A; }
.badge-danger  { background: linear-gradient(135deg, #FEE2E2, #FEF2F2); color: #B91C1C; border: 1px solid #FECACA; }
.badge-info    { background: linear-gradient(135deg, #DBEAFE, #EFF6FF); color: #1D4ED8; border: 1px solid #BFDBFE; }
.badge-muted   { background: linear-gradient(135deg, #F1F5F9, #F8FAFC); color: #475569; border: 1px solid #E2E8F0; }
.badge-purple  { background: linear-gradient(135deg, #F3E8FF, #FAF5FF); color: #7E22CE; border: 1px solid #E9D5FF; }
.badge-orange  { background: linear-gradient(135deg, #FFF7ED, #FFEDD5); color: #C2410C; border: 1px solid #FED7AA; }
/* Dot indicator on badges */
.badge::before {
    content: '';
    display: inline-block;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: currentColor;
    flex-shrink: 0;
}
.badge.no-dot::before { display: none; }

/* ── 3D Interactive Buttons ── */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    padding: 10px 20px;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
    border: none;
    transition: transform 0.18s ease, box-shadow 0.18s ease, background 0.18s ease;
    text-decoration: none;
    white-space: nowrap;
}
.btn:hover { text-decoration: none; }
.btn-primary   {
    background: linear-gradient(135deg, #7c3aed 0%, #6d28d9 100%);
    color: #fff;
    box-shadow: 0 6px 18px rgba(124, 58, 237, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.3);
}
.btn-primary:hover {
    background: linear-gradient(135deg, #6d28d9 0%, #5b21b6 100%);
    color: #fff;
    transform: translateY(-2px);
    box-shadow: 0 10px 24px rgba(124, 58, 237, 0.48), inset 0 1px 0 rgba(255, 255, 255, 0.4);
}
.btn-primary:active {
    transform: translateY(1px);
    box-shadow: 0 3px 10px rgba(124, 58, 237, 0.3);
}

.btn-secondary {
    background: linear-gradient(135deg, #ffffff 0%, #f1f5f9 100%);
    color: var(--text);
    border: 1.5px solid #cbd5e1;
    box-shadow: 0 2px 6px rgba(0,0,0,0.06), inset 0 1px 0 rgba(255,255,255,0.9);
}
.btn-secondary:hover {
    background: #ffffff;
    border-color: #94a3b8;
    color: var(--primary);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

.btn-success {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    color: #fff;
    box-shadow: 0 6px 18px rgba(16, 185, 129, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.3);
}
.btn-success:hover {
    background: linear-gradient(135deg, #059669 0%, #047857 100%);
    color: #fff;
    transform: translateY(-2px);
    box-shadow: 0 10px 24px rgba(16, 185, 129, 0.48);
}

.btn-danger {
    background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
    color: #fff;
    box-shadow: 0 6px 18px rgba(239, 68, 68, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.3);
}
.btn-danger:hover {
    background: linear-gradient(135deg, #dc2626 0%, #b91c1c 100%);
    color: #fff;
    transform: translateY(-2px);
    box-shadow: 0 10px 24px rgba(239, 68, 68, 0.48);
}

.btn-warning {
    background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
    color: #fff;
    box-shadow: 0 6px 18px rgba(245, 158, 11, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.3);
}
.btn-warning:hover {
    background: linear-gradient(135deg, #d97706 0%, #b45309 100%);
    color: #fff;
    transform: translateY(-2px);
    box-shadow: 0 10px 24px rgba(245, 158, 11, 0.48);
}

.btn-sm   { padding: 7px 15px; font-size: 13px; border-radius: 8px; }
.btn-icon { width: 36px; height: 36px; padding: 0; border-radius: 10px; }

/* ── 3D Form Control Inputs ── */
.form-group { margin-bottom: 18px; }
.form-group label {
    display: block;
    font-size: 13.5px;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 6px;
}
.form-control {
    width: 100%;
    padding: 10px 14px;
    border: 1.5px solid rgba(203, 213, 225, 0.8);
    border-radius: 10px;
    font-size: 14px;
    color: var(--text);
    background: linear-gradient(180deg, #ffffff 0%, #f8fafc 100%);
    box-shadow: inset 0 1px 3px rgba(0,0,0,0.04);
    transition: all 0.18s ease;
    appearance: none;
}
.form-control:focus {
    outline: none;
    border-color: var(--primary);
    background: #ffffff;
    box-shadow: 0 0 0 4px rgba(124, 58, 237, 0.15), inset 0 1px 2px rgba(0,0,0,0.02);
}
/* Autofill override for Light Mode: keeps background light/white and text dark slate */
input:-webkit-autofill,
input:-webkit-autofill:hover, 
input:-webkit-autofill:focus, 
input:-webkit-autofill:active,
textarea:-webkit-autofill,
select:-webkit-autofill {
    -webkit-text-fill-color: #1e293b !important;
    -webkit-box-shadow: 0 0 0 1000px #ffffff inset !important;
    box-shadow: 0 0 0 1000px #ffffff inset !important;
    caret-color: #1e293b;
    transition: background-color 5000s ease-in-out 0s;
}
.form-control::placeholder { color: var(--text-light); }
select.form-control { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%2364748B' fill='none' stroke-width='2' stroke-linecap='round'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; padding-right: 36px; }
textarea.form-control { min-height: 100px; resize: vertical; }
.form-row { display: grid; gap: 16px; }
.form-row.cols-2 { grid-template-columns: 1fr 1fr; }
.form-row.cols-3 { grid-template-columns: 1fr 1fr 1fr; }
.form-hint { font-size: 12px; color: var(--text-muted); margin-top: 4px; }
.form-error { font-size: 12px; color: var(--danger); margin-top: 4px; }
.form-check { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; font-size: 13px; }
.form-check input { width: 16px; height: 16px; accent-color: var(--primary); }

/* ── Alerts ── */
.alert {
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    margin-bottom: 16px;
    font-size: 13px;
    display: flex;
    align-items: flex-start;
    gap: 10px;
}
.alert-success { background: #F0FDF4; color: #15803D; border: 1px solid #BBF7D0; }
.alert-error   { background: #FEF2F2; color: #DC2626; border: 1px solid #FECACA; }
.alert-warning { background: #FFFBEB; color: #92400E; border: 1px solid #FDE68A; }
.alert-info    { background: #EFF6FF; color: #1D4ED8; border: 1px solid #BFDBFE; }

/* ── Grid layouts ── */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 20px; }
.grid-4 { display: grid; grid-template-columns: repeat(4,1fr); gap: 16px; }

/* ── Utils ── */
.mb-0 { margin-bottom: 0; }
.mb-1 { margin-bottom: 8px; }
.mb-2 { margin-bottom: 16px; }
.mb-3 { margin-bottom: 24px; }
.mt-1 { margin-top: 8px; }
.mt-2 { margin-top: 16px; }
.mt-3 { margin-top: 24px; }
.text-muted { color: var(--text-muted); }
.text-sm { font-size: 12px; }
.text-right { text-align: right; }
.text-center { text-align: center; }
.fw-bold { font-weight: 700; }
.d-flex { display: flex; }
.align-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }

/* ══════════════════════════════════════════════════════════════════
   3D COPY GROUP ACTION BAR SYSTEM
   ══════════════════════════════════════════════════════════════════ */
.copy-group {
    display: flex !important;
    gap: 8px !important;
    align-items: center !important;
    flex-wrap: wrap !important;
    width: 100% !important;
}

.copy-group .form-control {
    flex: 1 !important;
    min-width: 160px !important;
    height: 38px !important;
    padding: 8px 14px !important;
    font-family: 'SF Mono', 'Fira Code', 'Courier New', monospace !important;
    font-size: 12px !important;
    font-weight: 600 !important;
    color: #1e293b !important;
    background: linear-gradient(180deg, #ffffff 0%, #f8fafc 100%) !important;
    border: 1.5px solid #cbd5e1 !important;
    border-radius: 10px !important;
    box-shadow: inset 0 1.5px 3px rgba(0, 0, 0, 0.05) !important;
    transition: all 0.18s ease !important;
}

.copy-group .form-control:focus {
    border-color: #7c3aed !important;
    background: #ffffff !important;
    box-shadow: 0 0 0 3.5px rgba(124, 58, 237, 0.15), inset 0 1px 2px rgba(0, 0, 0, 0.02) !important;
}

/* 3D Action Buttons inside Copy Group */
.copy-group .btn,
.copy-group button {
    height: 38px !important;
    padding: 0 16px !important;
    font-size: 13px !important;
    font-weight: 800 !important;
    border-radius: 10px !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 6px !important;
    white-space: nowrap !important;
    flex-shrink: 0 !important;
    transition: transform 0.18s ease, box-shadow 0.18s ease, background 0.18s ease !important;
}

/* Copy button secondary 3D style */
.copy-group [data-copy],
.copy-group .btn-secondary {
    background: linear-gradient(135deg, #ffffff 0%, #f1f5f9 100%) !important;
    color: #334155 !important;
    border: 1.5px solid #cbd5e1 !important;
    box-shadow: 0 2.5px 7px rgba(0, 0, 0, 0.07), inset 0 1px 0 rgba(255, 255, 255, 0.95) !important;
}

.copy-group [data-copy]:hover,
.copy-group .btn-secondary:hover {
    background: #ffffff !important;
    border-color: #94a3b8 !important;
    color: #0f172a !important;
    transform: translateY(-1.5px) !important;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12), inset 0 1px 0 rgba(255, 255, 255, 1) !important;
}

/* 3D Cyan Build button */
.copy-group button[onclick*="GenModal"],
.copy-group button[onclick*="ihOpenBuildModal"],
.copy-group button[onclick*="openGenModal"] {
    background: linear-gradient(135deg, #0ea5e9 0%, #0284c7 100%) !important;
    color: #ffffff !important;
    border: none !important;
    box-shadow: 0 4px 14px rgba(14, 165, 233, 0.38), inset 0 1px 0 rgba(255, 255, 255, 0.35) !important;
}

.copy-group button[onclick*="GenModal"]:hover,
.copy-group button[onclick*="ihOpenBuildModal"]:hover,
.copy-group button[onclick*="openGenModal"]:hover {
    background: linear-gradient(135deg, #0284c7 0%, #0369a1 100%) !important;
    color: #ffffff !important;
    transform: translateY(-2px) !important;
    box-shadow: 0 7px 20px rgba(14, 165, 233, 0.5), inset 0 1px 0 rgba(255, 255, 255, 0.45) !important;
}

/* 3D Purple Short button */
.copy-group button[id*="shorten-btn"],
.copy-group button[onclick*="shortenLink"],
.copy-group button[onclick*="GenerateShort"] {
    background: linear-gradient(135deg, #7c3aed 0%, #6d28d9 100%) !important;
    color: #ffffff !important;
    border: none !important;
    box-shadow: 0 4px 14px rgba(124, 58, 237, 0.38), inset 0 1px 0 rgba(255, 255, 255, 0.35) !important;
}

.copy-group button[id*="shorten-btn"]:hover,
.copy-group button[onclick*="shortenLink"]:hover,
.copy-group button[onclick*="GenerateShort"]:hover {
    background: linear-gradient(135deg, #6d28d9 0%, #5b21b6 100%) !important;
    color: #ffffff !important;
    transform: translateY(-2px) !important;
    box-shadow: 0 7px 20px rgba(124, 58, 237, 0.5), inset 0 1px 0 rgba(255, 255, 255, 0.45) !important;
}

.copy-group .btn:active,
.copy-group button:active {
    transform: translateY(1px) !important;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2) !important;
}

/* ── Charts ── */
.chart-container { position: relative; height: 260px; }

/* ── Empty state ── */
.empty-state {
    text-align: center;
    padding: 48px 24px;
    color: var(--text-muted);
}
.empty-state .icon { font-size: 48px; margin-bottom: 12px; }
.empty-state h3 { font-size: 16px; font-weight: 600; margin-bottom: 8px; color: var(--text); }
.empty-state p { font-size: 13px; }

/* ── Sidebar overlay (mobile) — handled by #sidebarBackdrop injected by JS ── */
/* .sidebar-overlay class is kept for backward compat but JS uses #sidebarBackdrop */

/* ── Mobile sidebar toggle button ── */
#sidebarToggle {
    display: none;
    background: none;
    border: none;
    cursor: pointer;
    padding: 6px;
    border-radius: 6px;
    color: var(--text-muted);
    flex-shrink: 0;
    transition: background .15s, color .15s;
    touch-action: manipulation;        /* eliminates 300ms tap delay on iOS/Android */
    -webkit-tap-highlight-color: transparent;
    user-select: none;
    -webkit-user-select: none;
}
#sidebarToggle:hover { background: var(--primary-light); color: var(--primary); }

/* ── Dashboard-specific grids ── */
.dash-stat-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 14px;
    margin-bottom: 20px;
}
.dash-main-grid {
    display: grid;
    grid-template-columns: 1fr 340px;
    gap: 16px;
    margin-bottom: 20px;
}
.dash-kpi-stack { display: flex; flex-direction: column; gap: 12px; }
.dash-table-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    margin-bottom: 20px;
}
.dash-stat-card {
    background: #fff;
    border: 1px solid #E5E7EB;
    border-radius: 10px;
    padding: 18px 16px;
    overflow: hidden;
}
.dash-stat-label {
    font-size: 11px;
    font-weight: 700;
    color: #9CA3AF;
    letter-spacing: .08em;
    text-transform: uppercase;
    margin-bottom: 6px;
}
.dash-stat-value {
    font-size: 30px;
    font-weight: 800;
    color: #111827;
    line-height: 1;
}
.dash-kpi-card {
    background: #fff;
    border: 1px solid #E5E7EB;
    border-radius: 10px;
    padding: 15px 16px;
    display: flex;
    align-items: center;
    gap: 14px;
}
.dash-kpi-icon {
    width: 46px; height: 46px;
    border-radius: 10px;
    display: flex; align-items: center; justify-content: center;
    font-size: 20px;
    flex-shrink: 0;
}
.dash-kpi-value {
    font-size: 20px;
    font-weight: 800;
    color: #111827;
    line-height: 1.2;
}
.dash-kpi-sub { font-size: 13px; color: #9CA3AF; margin-top: 2px; }
.dash-filter-bar {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}
.dash-date-input {
    display: flex;
    align-items: center;
    background: #fff;
    border: 1.5px solid var(--border);
    border-radius: 8px;
    padding: 8px 14px;
    gap: 8px;
    font-size: 14px;
    font-weight: 500;
    color: #374151;
}
.dash-date-input input[type=date] {
    border: none;
    outline: none;
    font-size: 14px;
    font-weight: 500;
    color: #374151;
    background: transparent;
    min-width: 0;
}
.dash-page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 22px;
    flex-wrap: wrap;
    gap: 14px;
}
.dash-page-title-label {
    font-size: 12px;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: .08em;
    margin-bottom: 2px;
}
.dash-page-title {
    font-size: 26px;
    font-weight: 800;
    margin: 0;
    color: #111827;
}
.dash-mgr-banner {
    background: linear-gradient(135deg,#4F46E5,#7C3AED);
    border-radius: 10px;
    padding: 14px 20px;
    margin-bottom: 18px;
    display: flex;
    align-items: center;
    gap: 14px;
    flex-wrap: wrap;
}
.dash-section-title {
    font-size: 16px;
    font-weight: 700;
    color: #111827;
    padding: 16px 20px;
    border-bottom: 1px solid #F3F4F6;
}
.dash-tbl-th {
    padding: 11px 18px;
    text-align: left;
    font-size: 11.5px;
    font-weight: 700;
    color: #6B7280;
    text-transform: uppercase;
    letter-spacing: .06em;
    background: #F9FAFB;
}
.dash-tbl-td {
    padding: 12px 18px;
    font-size: 14px;
    color: #374151;
    border-top: 1px solid #F3F4F6;
}

/* ══════════════════════════════════════════
   RESPONSIVE — no horizontal scroll on any device
   ══════════════════════════════════════════ */

/* Prevent the whole page from scrolling left-right */
html { overflow-x: hidden; }
body { overflow-x: hidden; }
/* Do NOT put overflow on main-content — it would clip the topbar dropdown-menu.
   Horizontal overflow is already handled by html/body above and per-card table-wrap below. */
.main-content { min-width: 0; }

/* Any direct table inside a card scrolls horizontally within the card,
   not the whole page. This covers views that don't use .table-wrap */
.card > table,
.card > .card-body > table,
.card > form > table {
    display: block;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    max-width: 100%;
}

/* Every table lives inside a scrollable wrapper — only the table scrolls, not the page */
.table-wrap,
.dataTables_wrapper,
.card .table-wrap,
.card > .dataTables_wrapper {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    max-width: 100%;
}
/* DataTables generated wrapper */
.dataTables_wrapper { width: 100% !important; }
table { min-width: 0; }

/* Card header row wraps on narrow screens */
.card-header { flex-wrap: wrap; gap: 10px; }

/* Page header action buttons wrap */
.page-header { flex-wrap: wrap; gap: 12px; }
.page-header > *:last-child { flex-shrink: 0; }

/* ── 1100 px ── */
@media (max-width: 1100px) {
    .dash-stat-grid { grid-template-columns: repeat(3, 1fr); }
    .dash-main-grid { grid-template-columns: 1fr 300px; }
}

/* ── 900 px ── */
@media (max-width: 900px) {
    .dash-main-grid { grid-template-columns: 1fr; }
    .dash-kpi-stack { flex-direction: row; flex-wrap: wrap; }
    .dash-kpi-card  { flex: 1 1 calc(50% - 8px); min-width: 160px; }
}

/* ── 768 px (tablet / large phone) ── */
@media (max-width: 768px) {
    /* Show hamburger button */
    #sidebarToggle { display: flex; align-items: center; justify-content: center; }

    /* Sidebar slides in from left; hidden by default */
    .sidebar {
        transform: translateX(-100%);
        transition: transform .28s cubic-bezier(.4,0,.2,1);
        z-index: 200;
        box-shadow: none;
        width: min(280px, 82vw);
        height: 100vh;
        height: 100dvh;
        top: 0;
        bottom: 0;
        overflow-y: auto;
        overflow-x: hidden;
        -webkit-overflow-scrolling: touch;
        pointer-events: none; /* prevent off-canvas sidebar from swallowing touches */
    }
    .sidebar.open {
        transform: translateX(0);
        box-shadow: 6px 0 28px rgba(0,0,0,.18);
        pointer-events: auto;
    }

    .main-content { margin-left: 0; }
    .topbar { padding: 0 12px; gap: 8px; }
    .topbar-title { font-size: 14px; }
    .user-menu span { display: none; }
    .user-menu { padding: 6px 8px; gap: 6px; }

    .page-body { padding: 14px; }
    .page-header { flex-direction: column; align-items: flex-start; gap: 10px; }
    .page-header .d-flex { flex-wrap: wrap; }
    .page-header h1 { font-size: 20px; }

    /* All multi-col grids collapse */
    .stats-grid { grid-template-columns: 1fr 1fr; }
    .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
    .form-row.cols-2, .form-row.cols-3 { grid-template-columns: 1fr; }

    .card-body { padding: 14px; }
    .card-header { padding: 12px 14px; }

    /* DataTables controls wrap */
    .dataTables_wrapper .dataTables_filter,
    .dataTables_wrapper .dataTables_length,
    .dataTables_wrapper .dataTables_info,
    .dataTables_wrapper .dataTables_paginate {
        float: none !important;
        text-align: left !important;
        margin-bottom: 8px;
    }
    .dataTables_wrapper .dataTables_filter input { width: 100%; box-sizing: border-box; }

    /* Dashboard */
    .dash-stat-grid  { grid-template-columns: repeat(2, 1fr); gap: 12px; }
    .dash-table-grid { grid-template-columns: 1fr; }
    .dash-page-header { flex-direction: column; align-items: flex-start; }
    .dash-date-input  { width: 100%; flex-wrap: wrap; }
    .dash-filter-bar  { width: 100%; }
    .dash-mgr-banner  { flex-direction: column; align-items: flex-start; }
    .dash-stat-value  { font-size: 24px; }
    .dash-page-title  { font-size: 20px; }
    .dash-main-grid   { grid-template-columns: 1fr; }
}

/* ── 480 px (phone) ── */
@media (max-width: 480px) {
    .topbar { padding: 0 10px; gap: 6px; height: 56px; }
    --topbar-h: 56px;
    .topbar-title { font-size: 13px; }

    .page-body { padding: 10px; }
    .page-header h1 { font-size: 18px; }

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

    .btn { font-size: 13px; padding: 8px 12px; }
    .btn-sm { padding: 5px 10px; font-size: 12px; }

    .card-header { padding: 10px 12px; }
    .card-body   { padding: 12px; }
    .card-title  { font-size: 14px; }

    .form-group  { margin-bottom: 14px; }
    .form-control { font-size: 14px; padding: 9px 12px; }
    .form-group label { font-size: 13px; }

    /* Tables: smaller padding so more columns fit */
    thead th { padding: 10px 12px; font-size: 10.5px; letter-spacing: .05em; }
    tbody td  { padding: 11px 12px; font-size: 13px; }
    thead th:first-child, tbody td:first-child { padding-left: 14px; }
    thead th:last-child,  tbody td:last-child  { padding-right: 14px; }
    .dataTables_wrapper .dataTables_length,
    .dataTables_wrapper .dataTables_filter { float: none; padding: 10px 14px 0; }
    .dataTables_wrapper .dataTables_filter input { width: 100%; }
    .dataTables_wrapper .dataTables_info,
    .dataTables_wrapper .dataTables_paginate { float: none; padding: 10px 14px; }

    /* Dashboard */
    .dash-stat-grid  { grid-template-columns: 1fr 1fr; gap: 8px; }
    .dash-stat-card  { padding: 14px 12px; }
    .dash-stat-value { font-size: 22px; }
    .dash-stat-label { font-size: 10px; }
    .dash-kpi-card   { flex: 1 1 100%; }
    .dash-kpi-value  { font-size: 16px; }
    .dash-tbl-td     { font-size: 13px; padding: 9px 12px; }
    .dash-tbl-th     { padding: 9px 12px; font-size: 10.5px; }

    .mgr-card        { margin: 8px 6px 12px; }
    .mgr-row-value   { font-size: 12px; max-width: 120px; }

    /* Sidebar narrower on tiny phones */
    .sidebar {
        width: min(260px, 86vw);
        height: 100vh;
        height: 100dvh;
        overflow-y: auto;
        overflow-x: hidden;
        -webkit-overflow-scrolling: touch;
    }

    /* Badges / inline flex rows wrap */
    .d-flex { flex-wrap: wrap; }
    .topbar-actions { gap: 6px; }
}

/* ── 360 px (very small phones) ── */
@media (max-width: 360px) {
    .dash-stat-grid { grid-template-columns: 1fr 1fr; gap: 6px; }
    .dash-stat-value { font-size: 20px; }
    .btn  { padding: 7px 10px; font-size: 12px; }
    .page-body { padding: 8px; }
}

/* ══════════════════════════════════════════════════════════════════
   RESPONSIVE FIXES — Mobile, Tablet, Desktop
   ══════════════════════════════════════════════════════════════════ */

/* ── Sidebar toggle: hidden on desktop, shown on mobile ── */
#sidebarToggle {
    display: none;
    background: none;
    border: none;
    padding: 6px;
    border-radius: 6px;
    cursor: pointer;
    color: var(--text-muted);
    flex-shrink: 0;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
    -webkit-user-select: none;
}

/* ── Sidebar overlay backdrop ── */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.45);
    z-index: 199;
    -webkit-tap-highlight-color: transparent;
}
.sidebar-overlay.show { display: block; }

/* ── Cards: prevent overflow on small screens ── */
.card { overflow: hidden; }

/* ── All fixed-width inner elements — allow shrinking ── */
.form-control, select, textarea, input[type="text"],
input[type="email"], input[type="password"], input[type="number"],
input[type="url"], input[type="tel"] {
    max-width: 100%;
    box-sizing: border-box;
}

/* ── Tables: horizontal scroll instead of overflow ── */
.table-wrap, [style*="overflow-x:auto"] {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

/* ── Grid helpers ── */
.grid-2  { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid-3  { display: grid; grid-template-columns: repeat(3,1fr); gap: 16px; }
.grid-4  { display: grid; grid-template-columns: repeat(4,1fr); gap: 16px; }
.pb-grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }

/* ── Settings page max-width cards ── */
@media (max-width: 768px) {
    .card[style*="max-width"] { max-width: 100% !important; }
    div[style*="max-width:680px"],
    div[style*="max-width:780px"],
    div[style*="max-width:860px"] { max-width: 100% !important; }
}

/* ══ 1024px — Tablet landscape ══════════════════════════════════ */
@media (max-width: 1024px) {
    :root { --sidebar-w: 220px; }
    .grid-4 { grid-template-columns: repeat(2,1fr); }
    .grid-3 { grid-template-columns: repeat(2,1fr); }
}

/* ══ 768px — Tablet portrait / large phone ══════════════════════ */
@media (max-width: 768px) {
    /* Hamburger visible */
    #sidebarToggle { display: flex; align-items: center; justify-content: center; }
    .mobile-close-btn { display: flex; align-items: center; justify-content: center; }

    /* Sidebar slides in */
    .sidebar {
        transform: translateX(-100%);
        transition: transform .28s cubic-bezier(.4,0,.2,1);
        z-index: 200;
        width: min(280px, 82vw);
        box-shadow: none;
        position: fixed;
        top: 0; left: 0; bottom: 0;
        height: 100vh; height: 100dvh;
        overflow-y: auto; overflow-x: hidden;
        -webkit-overflow-scrolling: touch;
        pointer-events: none; /* prevent off-canvas sidebar swallowing touches */
    }
    .sidebar.open {
        transform: translateX(0);
        box-shadow: 6px 0 32px rgba(0,0,0,.2);
        pointer-events: auto;
    }
    .main-content { margin-left: 0; }

    /* Topbar */
    .topbar { padding: 0 12px; gap: 8px; }
    .topbar-title { font-size: 14px; }
    .user-menu span { display: none; }
    .user-menu { padding: 6px 8px; gap: 4px; }

    /* Page body */
    .page-body { padding: 14px; }
    .page-header { flex-direction: column; align-items: flex-start; gap: 10px; }
    .page-header h1 { font-size: 20px; }
    .page-header > div:last-child { flex-wrap: wrap; gap: 6px; }

    /* Grids collapse */
    .grid-2, .grid-3, .grid-4, .pb-grid-2 { grid-template-columns: 1fr; }
    .form-row.cols-2, .form-row.cols-3 { grid-template-columns: 1fr; }
    .stats-grid { grid-template-columns: 1fr 1fr; }

    /* Cards */
    .card-body  { padding: 14px; }
    .card-header { padding: 12px 14px; flex-wrap: wrap; gap: 8px; }
    .card-title { font-size: 14px; }

    /* Settings specific */
    .card[style*="max-width"] { max-width: 100% !important; }

    /* Buttons wrap */
    .btn-group, .d-flex { flex-wrap: wrap; }

    /* DataTables */
    .dataTables_wrapper .dataTables_filter,
    .dataTables_wrapper .dataTables_length,
    .dataTables_wrapper .dataTables_info,
    .dataTables_wrapper .dataTables_paginate {
        float: none !important;
        text-align: left !important;
        margin-bottom: 8px;
    }
    .dataTables_wrapper .dataTables_filter input { width: 100%; }

    /* Dashboard */
    .dash-stat-grid  { grid-template-columns: repeat(2,1fr); gap: 12px; }
    .dash-main-grid  { grid-template-columns: 1fr; }
    .dash-table-grid { grid-template-columns: 1fr; }
    .dash-page-header { flex-direction: column; align-items: flex-start; }
    .dash-date-input  { width: 100%; flex-wrap: wrap; }
    .dash-filter-bar  { width: 100%; }
    .dash-mgr-banner  { flex-direction: column; align-items: flex-start; }
}

/* ══ 580px — Small tablet / large phone ════════════════════════ */
@media (max-width: 580px) {
    .topbar { padding: 0 10px; gap: 6px; }
    .topbar-title { font-size: 13px; }

    /* Stats grid: 2 columns */
    .stats-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
    .dash-stat-grid { grid-template-columns: 1fr 1fr; gap: 10px; }

    /* Inline action rows wrap */
    .d-flex, .flex-row { flex-wrap: wrap; gap: 6px; }

    /* Referral stat row */
    .ref-stat-row { grid-template-columns: 1fr 1fr !important; gap: 10px; }

    /* Postback test wrap */
    .gpt-wrap, .pt-wrap { grid-template-columns: 1fr !important; }

    /* Global PB mgmt table overflow */
    .gpb-table { font-size: 12px; }
    .gpb-table th, .gpb-table td { padding: 8px 10px; }
}

/* ══ 480px — Phone ══════════════════════════════════════════════ */
@media (max-width: 480px) {
    .page-body { padding: 10px; }
    .page-header h1 { font-size: 18px; }
    .card-body  { padding: 12px; }
    .card-header { padding: 10px 12px; }

    .btn { font-size: 13px; padding: 8px 12px; }
    .btn-sm { font-size: 11px; padding: 5px 9px; }

    .form-control { font-size: 14px; padding: 9px 12px; }
    .form-group label { font-size: 13px; }
    .form-group { margin-bottom: 14px; }

    /* Tables */
    thead th { padding: 9px 10px; font-size: 10px; }
    tbody td  { padding: 10px 10px; font-size: 12px; }

    /* Sidebar narrower */
    .sidebar { width: min(260px, 86vw); }

    /* Dashboard stats */
    .dash-stat-value { font-size: 22px; }
    .dash-kpi-card   { flex: 1 1 100%; }
    .dash-kpi-value  { font-size: 16px; }

    /* Referral full-width stat cards */
    .ref-stat-row { grid-template-columns: 1fr !important; }

    /* Settings cards */
    .card[style*="max-width"] { max-width: 100% !important; }

    /* Action buttons in tables: stack */
    td .d-flex, td [style*="display:flex"] { flex-wrap: wrap; gap: 4px; }

    /* Topbar actions: hide less important items */
    .topbar-actions > a:first-child { display: none; }
}

/* ══ 360px — Very small phones ══════════════════════════════════ */
@media (max-width: 360px) {
    .page-body { padding: 8px; }
    .btn { padding: 7px 10px; font-size: 12px; }
    .card-body { padding: 10px; }
    .dash-stat-grid { grid-template-columns: 1fr 1fr; gap: 6px; }
    .dash-stat-value { font-size: 18px; }
    .stats-grid { grid-template-columns: 1fr; }
    .topbar-title { display: none; }
}

/* ══════════════════════════════════════════════════════════════════
   TARGETED MOBILE FIXES — Reports, Click Log, Referral, Login Logs
   ══════════════════════════════════════════════════════════════════ */

/* ── Stat cards grid: always responsive ── */
.stats-grid {
    display: grid;
    gap: 12px;
}
/* Override any inline fixed columns */
.stats-grid[style*="repeat(5"] ,
.stats-grid[style*="repeat(6"] ,
.stats-grid[style*="repeat(4"] {
    grid-template-columns: unset !important;
}

/* ── Filter form: always flex-wrap ── */
.d-flex.gap-3.align-center,
form.d-flex { flex-wrap: wrap !important; }
form .form-group.mb-0 { flex: 1 1 140px; min-width: 120px; max-width: 100%; }
form .form-group.mb-0 .form-control { width: 100%; box-sizing: border-box; }

/* ── Referral stat cards ── */
.ref-stat-row {
    display: grid !important;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)) !important;
    gap: 12px !important;
}
.ref-stat-card .value { font-size: 24px !important; }

/* ── Login logs: live-grid ── */
.live-grid {
    grid-template-columns: repeat(auto-fill, minmax(min(100%, 300px), 1fr)) !important;
}
.act-summary-grid {
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)) !important;
}
/* Unknown user avatar fallback */
.live-avatar-unknown {
    background: #6B7280 !important;
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    font-weight: 700;
    font-size: 18px;
}

/* ── Tab bars: always scrollable ── */
[style*="display:flex"][style*="border-bottom:2px solid #E2E8F0"],
[style*="display:flex"][style*="border-bottom: 2px solid"] {
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch !important;
    scrollbar-width: none !important;
    flex-wrap: nowrap !important;
}

/* ── All filter forms ── */
.act-filter-bar { flex-wrap: wrap !important; }

@media (max-width: 900px) {
    /* Reports stat grid: 3 cols */
    .stats-grid { grid-template-columns: repeat(3, 1fr) !important; }
}

@media (max-width: 640px) {
    /* Reports stat grid: 2 cols */
    .stats-grid { grid-template-columns: repeat(2, 1fr) !important; }

    /* stat card text smaller */
    .stat-card .stat-value { font-size: 22px !important; }
    .stat-card .stat-label { font-size: 10px !important; }

    /* Live grid: 1 col on phones */
    .live-grid { grid-template-columns: 1fr !important; }

    /* Act summary: 2 cols */
    .act-summary-grid { grid-template-columns: repeat(2, 1fr) !important; }

    /* Filter form fields: full width on phone */
    form .form-group.mb-0 { flex: 1 1 100% !important; max-width: 100% !important; }

    /* Date inputs full width */
    input[type="date"].form-control { width: 100%; }

    /* Tab bar items smaller */
    [style*="border-bottom:2px solid #E2E8F0"] a,
    [style*="border-bottom: 2px solid"] a {
        padding: 8px 10px !important;
        font-size: 12px !important;
    }

    /* Referral stat row: 2 cols */
    .ref-stat-row { grid-template-columns: repeat(2, 1fr) !important; }
    .ref-stat-card .label { font-size: 10px !important; }
    .ref-stat-card .value { font-size: 20px !important; }

    /* Login logs summary: 2 cols */
    .act-sum-val { font-size: 20px; }
    .act-sum-icon { width: 38px; height: 38px; font-size: 16px; }

    /* Force all fixed-width filter inputs to auto */
    .form-control[style*="width:110px"],
    .form-control[style*="min-width:110px"],
    .form-control[style*="min-width:130px"],
    .form-control[style*="width: 110px"] {
        width: 100% !important;
        min-width: unset !important;
    }
}

@media (max-width: 400px) {
    .stats-grid { grid-template-columns: repeat(2, 1fr) !important; gap: 8px !important; }
    .stat-card { padding: 12px !important; }
    .stat-card .stat-value { font-size: 18px !important; }
    .ref-stat-row { grid-template-columns: 1fr 1fr !important; }
    .act-summary-grid { grid-template-columns: 1fr 1fr !important; }
}

/* ══════════════════════════════════════════════════════════════════
   COMPREHENSIVE MOBILE RESPONSIVENESS FIXES v2
   Targets all issues visible in mobile screenshots
   ══════════════════════════════════════════════════════════════════ */

/* ── 1. Topbar: prevent overflow, allow wrapping ── */
.topbar {
    flex-wrap: nowrap;
    overflow: visible;  /* must be visible so dropdown-menu (position:absolute) is not clipped */
}
/* Topbar must not create a new stacking context that clips z-index children.
   position:sticky is fine but transform/filter/will-change must not be added. */
.topbar-actions {
    position: relative;  /* anchor for dropdown-menu absolute positioning */
    overflow: visible !important;
}
.user-menu {
    position: relative;
    overflow: visible;  /* never clip the dropdown */
}
/* The inner icon/balance area in affiliate topbar */
.topbar > div[style*="display:flex"] {
    flex-shrink: 1;
    min-width: 0;
    overflow: hidden;
}
/* Balance pill: allow shrinking */
#aff-balance-wrap {
    white-space: nowrap;
    flex-shrink: 1;
    min-width: 0;
    overflow: hidden;
}
/* topbar-title: allow shrinking gracefully */
.topbar-title {
    flex-shrink: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* ── 2. Table overflow: ALL tables get horizontal scroll ── */
.table-wrap {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}
table {
    min-width: 600px;
}
.dataTables_wrapper {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}
/* DataTables scrolling container fix */
.dataTables_scrollBody {
    overflow-x: auto !important;
}

/* ── 3. Card overflow: ensure cards never clip content ── */
.card {
    overflow: visible;
}
.card .table-wrap {
    overflow-x: auto;
}

/* ── 4. Page header button wrapping ── */
.page-header {
    flex-wrap: wrap;
    gap: 10px;
}
.page-header > div:last-child {
    flex-wrap: wrap;
    gap: 6px;
}

/* ── 5. Offers filter: view toggle buttons stay on row ── */
#btn-list-view, #btn-grid-view {
    white-space: nowrap;
    flex-shrink: 0;
}

/* ── 6. Conversions page tabs ── */
.conv-tabs-row {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    white-space: nowrap;
}
.conv-tabs-row::-webkit-scrollbar { display: none; }

/* ── 7. an-kpi-grid: affiliate dashboard KPI cards ── */
.an-kpi-grid {
    display: grid !important;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)) !important;
}

/* ── 8. Notification dropdown: prevent off-screen ── */
#notif-dropdown {
    right: 0 !important;
    max-width: calc(100vw - 20px) !important;
    width: min(320px, calc(100vw - 20px)) !important;
}
/* On narrow phones use fixed positioning so the panel is always fully on-screen */
@media (max-width: 540px) {
    #notif-dropdown {
        position: fixed !important;
        top: 60px !important;
        left: 8px !important;
        right: 8px !important;
        width: auto !important;
        max-width: none !important;
        z-index: 99999 !important;
    }
}

/* ── Advanced Analytics 3-col grid: responsive override ── */
/* Targets the inline style="...grid-template-columns:1fr 1fr 1fr..." used in affiliate analytics */
@media (max-width: 1024px) {
    div[style*="grid-template-columns:1fr 1fr 1fr"] {
        grid-template-columns: 1fr 1fr !important;
    }
}
@media (max-width: 640px) {
    div[style*="grid-template-columns:1fr 1fr 1fr"] {
        grid-template-columns: 1fr !important;
    }
}

/* ── 9. Any inline display:flex with gap: allow wrapping ── */
.card-header {
    flex-wrap: wrap;
    gap: 8px;
    min-height: auto;
}

/* ── 10. Form filter rows: full wrapping ── */
form[style*="display:flex"] {
    flex-wrap: wrap !important;
}
div[style*="display:flex"][style*="gap"] {
    flex-wrap: wrap;
}

/* ── 11. Grid-2 charts: stack on phone ── */
.grid-2 .card canvas {
    max-width: 100%;
}

/* ── 12. Table actions: wrap on small screens ── */
td .d-flex,
td [style*="display:flex"],
td [style*="display: flex"] {
    flex-wrap: wrap;
    gap: 4px;
}

/* ── 13. Min-width on fixed inputs: override ── */
input[style*="min-width"],
select[style*="min-width"] {
    min-width: min(100%, var(--original-min-width, 120px)) !important;
}

/* ══ MOBILE: 768px ══════════════════════════════════════════════ */
@media (max-width: 768px) {

    /* Topbar icons group: shrink and hide less important items */
    .topbar > div[style*="margin-right:8px"] {
        gap: 4px !important;
    }
    #news-bell-wrap { display: none; }

    /* Balance pill: compact on tablet */
    #aff-balance-wrap {
        padding: 4px 8px !important;
        font-size: 12px !important;
    }
    #aff-balance-wrap svg { display: none; }

    /* KPI grid: 3 cols on tablet */
    .an-kpi-grid {
        grid-template-columns: repeat(3, 1fr) !important;
        gap: 10px !important;
    }
    .an-kpi-value { font-size: 20px !important; }
    .an-kpi-card  { padding: 14px 12px 12px !important; }

    /* Stats grid: 2 columns */
    .stats-grid {
        grid-template-columns: repeat(2, 1fr) !important;
    }

    /* Offers filter: each input full width */
    .card-body form .form-group[style*="min-width"] {
        min-width: 0 !important;
        flex: 1 1 calc(50% - 6px) !important;
    }

    /* Offers view toggle: stay right */
    .card-body form > div[style*="margin-left:auto"] {
        margin-left: 0 !important;
        width: 100%;
        justify-content: flex-end;
    }

    /* Affiliate header: stack on mobile */
    .an-header {
        flex-direction: column;
        align-items: flex-start;
        padding: 18px 20px;
    }
    .an-filters {
        width: 100%;
    }
    .an-filter-input {
        flex: 1 1 calc(50% - 5px) !important;
        min-width: 0 !important;
    }

    /* grid-2 charts: stack */
    .grid-2 {
        grid-template-columns: 1fr !important;
    }

    /* Conversion tabs: horizontal scroll */
    div[style*="border-bottom:2px solid #E2E8F0"],
    div[style*="border-bottom: 2px solid #E2E8F0"] {
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch !important;
        white-space: nowrap !important;
        scrollbar-width: none !important;
        display: flex !important;
        flex-wrap: nowrap !important;
    }
    div[style*="border-bottom:2px solid #E2E8F0"]::-webkit-scrollbar,
    div[style*="border-bottom: 2px solid #E2E8F0"]::-webkit-scrollbar {
        display: none;
    }

    /* Conversion tabs: keep inline */
    div[style*="border-bottom:2px solid #E2E8F0"] a,
    div[style*="border-bottom: 2px solid #E2E8F0"] a {
        flex-shrink: 0 !important;
        white-space: nowrap !important;
        padding: 8px 12px !important;
        font-size: 12px !important;
    }

    /* Offers grid view: 1 col */
    #view-grid {
        grid-template-columns: 1fr !important;
    }

    /* Admin/affiliate mode banner */
    div[style*="background:#F59E0B"] {
        flex-wrap: wrap;
        gap: 6px;
        padding: 8px 14px !important;
    }
    div[style*="background:#F59E0B"] span,
    div[style*="background:#F59E0B"] a {
        font-size: 12px !important;
    }

    /* Tracking link cell in offers table */
    td[style*="min-width:280px"] {
        min-width: 220px !important;
    }

    /* Advertiser/Affiliate tables: all cells visible */
    .dataTables_wrapper table,
    .table-wrap table {
        min-width: 500px;
    }

    /* Stat-card value size */
    .stat-card .stat-value {
        font-size: 20px !important;
    }
}

/* ── Mobile dropdown (user-menu): switch to fixed positioning on small screens
   so it never gets clipped by topbar or sidebar stacking contexts ── */
@media (max-width: 768px) {
    .user-menu .dropdown-menu {
        position: fixed !important;
        top: auto !important;
        /* Anchor to bottom of topbar (topbar is 64px; 56px on very small screens) */
        top: 60px !important;
        right: 8px !important;
        left: auto !important;
        width: 200px !important;
        max-width: calc(100vw - 16px) !important;
        z-index: 99999 !important;
    }
}
@media (max-width: 480px) {
    .user-menu .dropdown-menu {
        top: 56px !important;
        right: 8px !important;
        width: calc(100vw - 16px) !important;
        max-width: 280px !important;
    }
}

/* ══ MOBILE: 580px ══════════════════════════════════════════════ */
@media (max-width: 580px) {

    /* Topbar: balance pill hide text, show icon only */
    #aff-balance-display {
        display: none;
    }
    #aff-balance-wrap {
        padding: 5px 7px !important;
    }
    #aff-balance-wrap svg {
        display: block !important;
    }

    /* KPI grid: 2 cols */
    .an-kpi-grid {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 8px !important;
    }
    .an-kpi-value { font-size: 18px !important; }
    .an-kpi-label { font-size: 10px !important; }

    /* Stat cards: 2 cols */
    .stats-grid {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 8px !important;
    }

    /* Page header: stack */
    .page-header {
        flex-direction: column;
        align-items: flex-start;
    }
    .page-header h1 { font-size: 18px; }
    .page-header p  { font-size: 13px; }
    .page-header > div:last-child {
        width: 100%;
        display: flex;
        flex-wrap: wrap;
        gap: 6px;
    }

    /* Buttons on page header: auto width */
    .page-header .btn {
        flex: 1 1 auto;
        text-align: center;
        min-width: 100px;
    }

    /* Affiliate analytics filter */
    .an-filter-input {
        flex: 1 1 100% !important;
    }
    .an-btn-filter {
        width: 100%;
        justify-content: center;
    }
    .an-period-tabs {
        width: 100%;
        justify-content: space-between;
    }

    /* Filter forms: all fields full width */
    .card-body form .form-group,
    .card-body form .form-group[style*="min-width"] {
        flex: 1 1 100% !important;
        min-width: 0 !important;
        max-width: 100% !important;
    }
    .card-body form .form-control {
        width: 100% !important;
        min-width: 0 !important;
        max-width: 100% !important;
    }

    /* Filter submit buttons: full width */
    .card-body form > div[style*="display:flex"] {
        width: 100%;
    }
    .card-body form .btn-primary {
        flex: 1;
    }

    /* Offers view toggle: full width row */
    .card-body form > div[style*="margin-left:auto"] {
        margin-left: 0 !important;
        width: 100%;
        display: flex;
        justify-content: flex-end;
    }

    /* Conversion tabs scroll */
    div[style*="border-bottom:2px solid #E2E8F0"] a,
    div[style*="border-bottom: 2px solid #E2E8F0"] a {
        padding: 7px 9px !important;
        font-size: 11px !important;
        gap: 3px !important;
    }

    /* an-section-title: smaller */
    .an-section-title { font-size: 14px; }

    /* Chart canvases: constrain height */
    canvas { max-height: 220px; }

    /* Offer grid view: 1 col */
    #view-grid {
        grid-template-columns: 1fr !important;
    }
}

/* ══ MOBILE: 480px ══════════════════════════════════════════════ */
@media (max-width: 480px) {

    /* Topbar: very compact */
    .topbar {
        height: auto !important;
        min-height: 52px;
        padding: 8px 10px !important;
        gap: 6px !important;
        flex-wrap: nowrap;
    }

    /* Hide balance entirely, show bell only */
    #aff-balance-wrap { display: none !important; }
    #chat-bell        { display: none !important; }

    /* Notification dropdown: handled by @media 540px fixed block above */

    /* User menu: avatar only */
    .user-menu span { display: none !important; }
    .user-menu > svg:last-child { display: none !important; }
    .user-menu { padding: 5px 7px !important; gap: 0 !important; }

    /* KPI value: smaller */
    .an-kpi-value  { font-size: 16px !important; }
    .an-kpi-card   { padding: 12px 10px !important; }

    /* Stats grid: 2 cols always */
    .stats-grid {
        grid-template-columns: 1fr 1fr !important;
        gap: 6px !important;
    }
    .stat-card { padding: 12px 10px !important; }
    .stat-card .stat-value { font-size: 18px !important; }
    .stat-card .stat-label { font-size: 10px !important; }
    .stat-card .stat-sub   { font-size: 10px !important; }

    /* An-header: compact */
    .an-header { padding: 14px 16px; border-radius: 10px; }
    .an-title  { font-size: 18px !important; }

    /* Card body padding: compact */
    .card-body  { padding: 10px !important; }
    .card-header { padding: 10px 12px !important; }

    /* Canvas charts: max height */
    canvas { max-height: 180px !important; }

    /* Funnel bars: compact */
    .an-funnel-bar { height: 22px; }

    /* Table wrap: full scroll */
    .table-wrap, .dataTables_wrapper {
        width: 100%;
        overflow-x: auto;
    }
    table, table.dataTable {
        min-width: 480px;
    }

    /* Smaller table cells */
    thead th { padding: 8px 8px !important; font-size: 10px !important; }
    tbody td  { padding: 8px 8px !important; font-size: 12px !important; }

    /* Page body padding */
    .page-body { padding: 8px !important; }

    /* Manager banner in affiliate topbar */
    .an-mgr-banner {
        flex-direction: column !important;
        align-items: flex-start !important;
        padding: 12px 16px !important;
    }
}

/* ══ MOBILE: 360px ══════════════════════════════════════════════ */
@media (max-width: 360px) {

    .an-kpi-grid {
        grid-template-columns: 1fr 1fr !important;
        gap: 6px !important;
    }
    .an-kpi-value { font-size: 15px !important; }

    .stats-grid {
        grid-template-columns: 1fr 1fr !important;
        gap: 6px !important;
    }
    .stat-card .stat-value { font-size: 16px !important; }

    .page-body { padding: 6px !important; }
    .card-body  { padding: 8px !important; }

    table, table.dataTable { min-width: 380px; }

    /* Conversion tab: tiny */
    div[style*="border-bottom:2px solid #E2E8F0"] a,
    div[style*="border-bottom: 2px solid #E2E8F0"] a {
        padding: 6px 7px !important;
        font-size: 10px !important;
    }
}

/* ══ UNIVERSAL OVERFLOW PREVENTION ═════════════════════════════ */

/* Prevent any element from causing horizontal page scroll */
.page-body > * {
    max-width: 100%;
}

/* All inline styles with fixed min-widths: override on small screens */
@media (max-width: 480px) {
    [style*="min-width:280px"],
    [style*="min-width: 280px"],
    [style*="min-width:320px"],
    [style*="min-width:300px"] {
        min-width: 0 !important;
        width: 100% !important;
    }
    [style*="width:320px"],
    [style*="width: 320px"],
    [style*="width:300px"] {
        width: 100% !important;
    }
}

/* ══ DATATABLES MOBILE IMPROVEMENTS ════════════════════════════ */
div.dataTables_wrapper div.dataTables_filter {
    text-align: left;
}
@media (max-width: 580px) {
    div.dataTables_wrapper div.dataTables_length,
    div.dataTables_wrapper div.dataTables_filter,
    div.dataTables_wrapper div.dataTables_info,
    div.dataTables_wrapper div.dataTables_paginate {
        float: none !important;
        text-align: left !important;
        padding: 6px 0 !important;
        display: block !important;
        width: 100%;
    }
    div.dataTables_wrapper div.dataTables_filter input {
        width: 100% !important;
        margin-left: 0 !important;
        display: block;
    }
    div.dataTables_wrapper div.dataTables_paginate .paginate_button {
        padding: 4px 8px !important;
        font-size: 12px !important;
    }
}

/* ══ AFFILIATE TOPBAR ICON ROW — FLEXIBLE ══════════════════════ */
/* The div containing balance + news + notifications + chat */
.topbar > div[style*="align-items:center"][style*="gap:8px"],
.topbar > div[style*="align-items: center"][style*="gap: 8px"] {
    flex-shrink: 1;
    overflow: visible;
}

/* ══ OFFER GRID & IN-HOUSE OFFER GRID — EQUAL COLUMNS, NO OVERFLOW ═ */
/*
 * Safari fix: auto-fill keeps empty ghost columns which shrink real cards.
 * auto-fit collapses empty columns so filled cards expand to fill the row.
 * The inline styles on #view-grid / #ih-view-grid already use auto-fit.
 * This block reinforces that and adds -webkit- prefix for older Safari.
 */
#view-grid,
#ih-view-grid {
    display: -webkit-grid;
    display: grid;
    -webkit-grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: 20px;
    align-items: start;
    /* Prevent the grid itself from overflowing its container in Safari */
    width: 100%;
    box-sizing: border-box;
}

/* Grid items: force containment so no child inflates the column */
#view-grid > .card,
#ih-view-grid > .card {
    min-width: 0;
    max-width: 100%;
    width: 100%;
    overflow: hidden;
    box-sizing: border-box;
}

/* Images inside offer cards: always fill card, never overflow */
#view-grid .card img,
#ih-view-grid .card img {
    max-width: 100%;
    width: 100%;
    display: block;
    height: auto;
}

/* iframes: clamp to card width in all browsers including Safari */
#view-grid .card iframe,
#ih-view-grid .card iframe {
    max-width: 100% !important;
    width: 100% !important;
    display: block;
}

/* Responsive: single column below 720px */
@media (max-width: 720px) {
    #view-grid,
    #ih-view-grid {
        -webkit-grid-template-columns: 1fr !important;
        grid-template-columns: 1fr !important;
    }
}

/* ══ SAFARI GRID ITEM CONTAINMENT (global) ══════════════════════ */
/*
 * Any CSS grid that uses repeat(auto-fit/fill, minmax(..., 1fr)) must have
 * its items contained to prevent intrinsic size leaking the column width.
 * Target all direct .card children of any grid-based layout container.
 */
.grid-2 > .card,
.grid-3 > .card,
.grid-4 > .card {
    min-width: 0;
    max-width: 100%;
}

/* ============================================================
   RESPONSIVE HARDENING — final pass
   Defensive rules that close every layout gap visible in the
   "squashed content on mobile" / "weird left-edge gradient
   strip" / "horizontal-scroll on small screens" bugs.
   Applied to ALL themes (Light / Dark).
   ============================================================ */

/* Lock horizontal overflow so a single overflowing child can't
   create a horizontal-scroll across the whole page. */
html, body { max-width: 100vw; overflow-x: hidden; }

/* Universal box-sizing so 100% widths never overflow their
   container because of padding/border. */
*, *::before, *::after { box-sizing: border-box; }

/* Allow flex/grid children to shrink below their content size
   instead of forcing a horizontal scroll. */
.main-content,
.page-body,
.card, .stat-card, .kpi-card, .chart-card, .fds-card, .panel { min-width: 0; }

/* ── ≤768px (phone / small tablet) — full mobile lockdown.
   Below this breakpoint the sidebar slides off-canvas, so
   .main-content must lose its gutter entirely.
   .app-layout drops flex so position:fixed sidebar never
   reserves a flex slot that squashes main-content. */
@media (max-width: 768px) {
    .app-layout    { display: block !important; }
    .sidebar       { flex: 0 0 0 !important; }
    .main-content  { margin-left: 0 !important; width: 100% !important; max-width: 100vw !important; flex: none !important; }
    .page-body     { padding: 14px !important; }

    /* Hero panel: never narrower than viewport, stack vertically. */
    .dash-header {
        width: 100% !important;
        margin: 0 0 16px !important;
        padding: 16px 14px !important;
        flex-direction: column !important;
        align-items: stretch !important;
        gap: 12px !important;
    }
    .dash-hdr-left  { width: 100%; }
    .dash-filters   { width: 100%; }
    .dash-period-tabs { width: 100%; flex-wrap: wrap; }
    .dash-period-tab  { flex: 1 1 calc(33.333% - 4px); min-width: 0; }

    /* Date inputs + selects: 2-up grid that never overflows. */
    .dash-filters > .dash-f-input,
    .dash-filters > input.dash-f-input,
    .dash-filters > select.dash-f-input { flex: 1 1 calc(50% - 4px) !important; min-width: 0 !important; }
    .dash-filters > span { display: none !important; }  /* "—" separator */
    .dash-btn-apply, .dash-btn-reset { flex: 1 1 calc(50% - 4px); justify-content: center; }

    /* Topbar — keep buttons compact, never push content out of view. */
    .topbar { padding: 0 10px !important; gap: 6px !important; }
    .topbar-actions { gap: 6px !important; flex-shrink: 0; }
    .topbar-title   { font-size: 14px; min-width: 0; }
    .user-menu      { padding: 6px 8px; gap: 4px; }
    .user-menu span { display: none; }

    /* Page header text + actions stack. */
    .page-header { flex-direction: column; align-items: flex-start; gap: 10px; }
    .page-header h1 { font-size: 20px; }
    .page-header .d-flex { flex-wrap: wrap; }

    /* Card padding tighter. */
    .card-body  { padding: 14px; }
    .card-header { padding: 12px 14px; flex-wrap: wrap; gap: 8px; }

    /* DataTables horizontal scroll — confined to the table, not the page. */
    .table-wrap, .dataTables_wrapper { overflow-x: auto; -webkit-overflow-scrolling: touch; }
    .dataTables_wrapper table { min-width: 480px; }
}

/* ── ≤640px (phone portrait) ── */
@media (max-width: 640px) {
    .page-body { padding: 12px !important; }
    .dash-hdr-title { font-size: 19px !important; }
    .dash-period-tab { flex: 1 1 calc(50% - 4px); font-size: 11px; padding: 6px 8px; }
    .kpi-grid { grid-template-columns: repeat(2,1fr) !important; gap: 10px; }
    .charts-2, .charts-3 { grid-template-columns: 1fr !important; }
}

/* ── ≤480px (small phone) ── */
@media (max-width: 480px) {
    .page-body { padding: 10px !important; }
    .dash-header { padding: 14px 12px !important; border-radius: 12px !important; }
    .dash-hdr-title { font-size: 17px !important; }
    .dash-hdr-label { font-size: 10px !important; }
    .dash-hdr-updated { font-size: 11px !important; }
    .dash-period-tab { flex: 1 1 calc(50% - 4px); }
    /* All inputs full width on tiny screens */
    .dash-filters > .dash-f-input,
    .dash-filters > input.dash-f-input,
    .dash-filters > select.dash-f-input { flex: 1 1 100% !important; }
    .kpi-grid { grid-template-columns: 1fr !important; gap: 10px; }
    .kpi-card { padding: 14px !important; }
    .topbar-title { display: none; }  /* free up space, hamburger remains */
}

/* ── ≤360px (very small phone) ── */
@media (max-width: 360px) {
    .page-body { padding: 8px !important; }
    .dash-header { padding: 12px 10px !important; }
    .dash-hdr-title { font-size: 16px !important; }
    .topbar { padding: 0 6px !important; }
    .topbar-actions { gap: 4px !important; }
}

/* ── Landscape phone tweaks ─────────────────────────────────
   On a landscape phone the viewport is wider but still
   ≤900px tall; switch the hero filters back to a single row
   so they don't dominate the screen vertically. */
@media (max-width: 900px) and (orientation: landscape) and (max-height: 500px) {
    .dash-header { flex-direction: row !important; flex-wrap: wrap; }
    .dash-filters { width: auto; }
    .dash-period-tab { flex: 0 1 auto; }
}

/* ── Sidebar: prevent a visible "gradient strip" between sidebar
   and main content on tablet/desktop. The strip is the body
   background's gradient leaking through the 1px gap between the
   sidebar's border-right and main-content. */
.sidebar { border-right: none !important; }
.main-content { border-left: none !important; }
@media (min-width: 769px) {
    .sidebar { box-shadow: inset -1px 0 0 var(--border, rgba(0,0,0,.06)); }
}

/* ============================================================
   CARD / FORM OVERFLOW HARDENING
   Cards and the forms inside them must never exceed the page
   body's width. Date inputs, selects, and chip rows wrap
   instead of forcing horizontal overflow.
   ============================================================ */
.card,
.fds-card,
.chart-card,
.stat-card,
.kpi-card {
    max-width: 100%;
    min-width: 0;
    box-sizing: border-box;
}
.card-body,
.fds-card .card-body,
.card-header { max-width: 100%; min-width: 0; }

/* Forms inside cards: every direct child shrinks instead of pushing. */
.card form,
.card form > *,
.card-body form,
.card-body form > * { min-width: 0; max-width: 100%; }
.card form { flex-wrap: wrap; }

/* Inputs/selects/dates inside cards: never wider than their container. */
.card input,
.card select,
.card textarea,
.card .form-control,
.card-body input,
.card-body select,
.card-body textarea,
.card-body .form-control { max-width: 100%; min-width: 0; }

/* Date-range picker chip row: wrap instead of pushing past the card edge. */
.drp-presets { flex-wrap: wrap; max-width: 100%; }

/* The page-body is the single source of horizontal bounds. */
.page-body { max-width: 100%; min-width: 0; overflow-x: hidden; }

/* On phones the page-body padding shrinks so cards have more room. */
@media (max-width: 640px) {
    .page-body { padding: 12px !important; }
    .card .card-body,
    .card > .card-body { padding: 12px !important; }
    .card form { gap: 8px !important; }
    .card form > * { flex: 1 1 100%; }   /* every form row stacks */
    .card form > div[style*="display:flex"] { width: 100%; }
    /* Date inputs: keep readable, but never wider than viewport */
    input[type="date"],
    input[type="datetime-local"],
    input[type="text"],
    input[type="email"],
    input[type="number"],
    select,
    textarea { max-width: 100%; }
    /* DataTables filter input goes full width */
    .dataTables_filter input { width: 100% !important; }
    /* Tables already scroll inside their wrapper; ensure they don't
       stretch the card itself horizontally. */
    .table-wrap, .dataTables_wrapper { overflow-x: auto !important; max-width: 100%; }
}

/* On very small phones, kill the gap between card-body inline padding
   and the card edge so date inputs and chips don't get clipped. */
@media (max-width: 480px) {
    .page-body { padding: 10px !important; }
    .card .card-body,
    .card > .card-body { padding: 10px !important; }
    .card-body[style*="padding:16px 20px"],
    .card-body[style*="padding: 16px 20px"] { padding: 10px !important; }
    /* Drp chip presets: 2 per row instead of overflowing */
    .drp-btn { flex: 1 1 calc(50% - 5px); text-align: center; }
}

/* ============================================================
   NEW COMPREHENSIVE MOBILE RESPONSIVE OVERHAUL
   Ensures absolute responsiveness for all tables, fonts, forms
   and grid layouts on mobile and tablet devices.
   ============================================================ */

/* 1. Global typography and readable form inputs on mobile */
@media (max-width: 768px) {
    /* Scale down large headers */
    h1, h2, h3, .page-header h1, .an-title, .dash-hdr-title { font-size: 1.25rem !important; }
    .card-title { font-size: 16px !important; }
    
    /* Buttons: tighter padding */
    .btn { padding: 8px 12px !important; font-size: 13px !important; }
    
    /* Inputs: force 16px to prevent iOS auto-zoom */
    input[type="text"], input[type="number"], input[type="email"], input[type="password"], 
    input[type="date"], input[type="datetime-local"], select, textarea, .form-control {
        font-size: 16px !important;
        min-height: 40px !important;
    }
}

/* 2. Strict Layout Grids */
@media (max-width: 768px) {
    .grid-2, .grid-3, .grid-4, .pb-grid-2, .an-kpi-grid, .stats-grid, .charts-2, .charts-3, .form-row.cols-2, .form-row.cols-3 {
        display: grid !important;
        grid-template-columns: 1fr !important;
        gap: 12px !important;
        width: 100% !important;
    }
    
    /* Force 2-columns only on extremely small grids where 1fr is too big, like preset chips */
    .drp-presets {
        display: grid !important;
        grid-template-columns: 1fr 1fr !important;
        gap: 6px !important;
    }
    .drp-btn { width: 100% !important; }
}

/* 3. Tables & Forms strictly confined */
@media (max-width: 768px) {
    /* Tables strictly scroll horizontally inside their container */
    .table-wrap, .dataTables_wrapper {
        display: block !important;
        width: 100% !important;
        max-width: 100vw !important;
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch !important;
    }
    
    /* DataTables specific fixes */
    .dataTables_wrapper .row {
        display: flex !important;
        flex-direction: column !important;
        width: 100% !important;
    }
    .dataTables_wrapper .col-sm-12, .dataTables_wrapper .col-md-6 {
        width: 100% !important;
        padding: 0 !important;
        margin-bottom: 10px !important;
    }
    
    /* Form groups always wrap and take full width */
    .form-group, .form-control {
        max-width: 100% !important;
    }
    form[style*="display:flex"], form[style*="display: flex"] {
        flex-direction: column !important;
        align-items: stretch !important;
    }
}

/* 4. Modals - Mobile view */
@media (max-width: 768px) {
    .modal-dialog {
        margin: 10px auto !important;
        width: calc(100% - 20px) !important;
        max-width: calc(100% - 20px) !important;
    }
    .modal-content {
        max-height: calc(100vh - 40px) !important;
        display: flex !important;
        flex-direction: column !important;
    }
    .modal-body {
        overflow-y: auto !important;
        padding: 15px !important;
    }
    .modal-header, .modal-footer {
        padding: 12px 15px !important;
    }
}

/* 5. Topbar and Navbar elements */
@media (max-width: 768px) {
    /* Prevent topbar overlap */
    .topbar {
        justify-content: space-between !important;
        padding: 8px 12px !important;
        height: auto !important;
        min-height: 60px !important;
        flex-wrap: wrap !important;
    }
    .topbar-actions {
        flex-wrap: wrap !important;
        justify-content: flex-end !important;
    }
    
    /* Sidebar hide logic */
    .sidebar {
        position: fixed !important;
        top: 0 !important;
        left: 0 !important;
        bottom: 0 !important;
        transform: translateX(-100%) !important;
        transition: transform 0.3s ease !important;
        z-index: 1040 !important;
    }
    .sidebar.open {
        transform: translateX(0) !important;
    }
    .main-content {
        margin-left: 0 !important;
        width: 100% !important;
    }
}

/* ── 3D Mesh Background Floating Animation ── */
@keyframes mesh-float {
    0% { background-position: 0% 0%, 100% 100%, 50% 50%; }
    25% { background-position: 30% 80%, 70% 20%, 20% 80%; }
    50% { background-position: 100% 100%, 0% 0%, 80% 20%; }
    75% { background-position: 70% 20%, 30% 80%, 80% 80%; }
    100% { background-position: 0% 0%, 100% 100%, 50% 50%; }
}

/* ── 3D Space Engine Settings Styles ── */
.galaxy-settings-btn {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    border: 1px solid var(--border);
    background: rgba(255, 255, 255, 0.7);
    color: var(--text);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.25s ease;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    padding: 0;
    outline: none;
    box-shadow: 0 2px 5px rgba(0,0,0,0.05);
}
.galaxy-settings-btn:hover {
    background: var(--primary);
    color: #FFFFFF;
    border-color: var(--primary);
    transform: rotate(30deg);
}
.galaxy-settings-panel {
    position: fixed;
    top: 75px;
    right: 20px;
    width: 290px;
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.6);
    border-radius: 14px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.08), 0 1px 3px rgba(0, 0, 0, 0.02);
    z-index: 1060;
    padding: 20px;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px) scale(0.95);
    transition: all 0.28s cubic-bezier(0.16, 1, 0.3, 1);
}
.galaxy-settings-panel.show {
    opacity: 1;
    visibility: visible;
    transform: translateY(0) scale(1);
}
.galaxy-settings-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
    border-bottom: 1px solid var(--border);
    padding-bottom: 10px;
}
.galaxy-settings-header h3 {
    font-size: 15px;
    font-weight: 700;
    color: var(--text);
    margin: 0;
}
#galaxySettingsClose {
    background: transparent;
    border: none;
    font-size: 20px;
    color: var(--text-muted);
    cursor: pointer;
    line-height: 1;
    padding: 0 4px;
}
#galaxySettingsClose:hover {
    color: var(--danger);
}
.galaxy-setting-row {
    margin-bottom: 14px;
}
.galaxy-setting-row label {
    display: block;
    font-size: 12.5px;
    font-weight: 600;
    color: var(--text-muted);
    margin-bottom: 6px;
}
.galaxy-toggle-label {
    display: flex !important;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-size: 13px !important;
    color: var(--text) !important;
    margin: 0 !important;
}
.galaxy-toggle-label input {
    width: 16px;
    height: 16px;
    accent-color: var(--primary);
    cursor: pointer;
}
.galaxy-setting-row input[type="range"] {
    width: 100%;
    accent-color: var(--primary);
    cursor: pointer;
    height: 6px;
    background: var(--border);
    border-radius: 3px;
    outline: none;
}
.galaxy-glow-group {
    display: flex;
    gap: 6px;
    margin-top: 4px;
}
.galaxy-glow-btn {
    flex: 1;
    padding: 6px 0;
    font-size: 11px;
    font-weight: 700;
    border-radius: 6px;
    border: 1px solid var(--border);
    background: rgba(255, 255, 255, 0.6);
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.2s ease;
}
.galaxy-glow-btn:hover {
    background: rgba(255, 255, 255, 0.9);
}
.galaxy-glow-btn.active {
    background: var(--primary);
    color: #FFFFFF !important;
    border-color: var(--primary);
    box-shadow: 0 2px 4px rgba(124, 58, 237, 0.15);
}

/* Adjust topbar actions layout to accommodate settings btn */
.topbar-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

/* Dark theme overrides for settings panel */
html[data-theme="dark"] .galaxy-settings-panel {
    background: rgba(15, 10, 36, 0.85);
    border-color: rgba(255, 255, 255, 0.1);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
}
html[data-theme="dark"] .galaxy-settings-btn {
    background: rgba(15, 10, 36, 0.7);
    border-color: rgba(255, 255, 255, 0.1);
}
html[data-theme="dark"] .galaxy-glow-btn {
    background: rgba(15, 10, 36, 0.6);
    border-color: rgba(255, 255, 255, 0.1);
}
html[data-theme="dark"] .galaxy-glow-btn:hover {
    background: rgba(15, 10, 36, 0.8);
}

/* ══════════════════════════════════════════════════════════════════
   RESPONSIVE STAT GRIDS — Reusable column-count classes
   ══════════════════════════════════════════════════════════════════ */
.stat-grid-5 { display:grid; grid-template-columns:repeat(5,1fr); gap:16px; margin-bottom:24px; }
.stat-grid-6 { display:grid; grid-template-columns:repeat(6,1fr); gap:14px; margin-bottom:24px; }

@media (max-width: 900px) {
    .stat-grid-5 { grid-template-columns: repeat(3, 1fr); }
    .stat-grid-6 { grid-template-columns: repeat(3, 1fr); }
    .cr-stats    { grid-template-columns: repeat(3, 1fr) !important; }
}
@media (max-width: 640px) {
    .stat-grid-5 { grid-template-columns: repeat(2, 1fr); gap: 10px; }
    .stat-grid-6 { grid-template-columns: repeat(2, 1fr); gap: 10px; }
    .cr-stats    { grid-template-columns: repeat(2, 1fr) !important; gap: 10px !important; }
    .fds-kpi-grid { grid-template-columns: repeat(2, 1fr) !important; gap: 10px !important; }
}
@media (max-width: 360px) {
    .stat-grid-5,
    .stat-grid-6 { grid-template-columns: 1fr 1fr; gap: 8px; }
    .stat-grid-5 .card-body,
    .stat-grid-6 .card-body { padding: 12px 14px; }
    .stat-grid-5 .card-body div[style*="font-size:28px"],
    .stat-grid-5 .card-body div[style*="font-size:26px"],
    .stat-grid-5 .card-body div[style*="font-size:24px"],
    .stat-grid-6 .card-body div[style*="font-size:28px"],
    .stat-grid-6 .card-body div[style*="font-size:26px"],
    .stat-grid-6 .card-body div[style*="font-size:24px"] { font-size: 20px !important; }
    .cr-stats    { grid-template-columns: 1fr 1fr !important; gap: 8px !important; }
    .cr-stat .val { font-size: 18px !important; }
    .fds-kpi-grid { grid-template-columns: 1fr 1fr !important; gap: 8px !important; }
}

/* Page header: ensure export buttons wrap on mobile */
@media (max-width: 640px) {
    .page-header > div:last-child {
        flex-wrap: wrap;
        width: 100%;
    }
    .page-header > div:last-child .btn {
        flex: 1 1 auto;
        text-align: center;
    }
}

/* ══════════════════════════════════════════════════════════════════
   PREMIUM & USER-FRIENDLY RESPONSIVE FILTER CARDS
   ══════════════════════════════════════════════════════════════════ */
.filter-card {
    background: var(--card-bg, #ffffff);
    border: 1px solid var(--border, #e2e8f0);
    border-radius: 12px;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.03);
    overflow: hidden;
}

.filter-toggle-btn {
    display: none; /* hidden on desktop */
}

/* Ensure nothing peeks out when closed */
.card.filter-card:not(.filter-open) .card-body {
    display: none !important;
}

@media (max-width: 768px) {
    /* Sleek toggle bar header on mobile */
    .filter-toggle-btn {
        display: flex;
        align-items: center;
        justify-content: space-between;
        width: 100%;
        padding: 12px 16px;
        background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%);
        border: none;
        border-bottom: 1px solid var(--border, #e2e8f0);
        cursor: pointer;
        font-size: 13.5px;
        font-weight: 700;
        color: var(--text, #1e293b);
        letter-spacing: .01em;
        transition: background .15s;
    }
    .filter-card:not(.filter-open) .filter-toggle-btn {
        border-bottom: none;
    }
    .filter-toggle-btn:hover {
        background: #f1f5f9;
    }
    .filter-toggle-left {
        display: flex;
        align-items: center;
        gap: 8px;
        color: var(--primary, #7c3aed);
    }
    .filter-toggle-icon {
        width: 20px;
        height: 20px;
        display: flex;
        align-items: center;
        justify-content: center;
        border-radius: 50%;
        background: rgba(124, 58, 237, 0.1);
        color: var(--primary, #7c3aed);
        font-size: 10px;
        transition: transform .25s ease;
    }
    .filter-card.filter-open .filter-toggle-icon {
        transform: rotate(180deg);
    }

    .card.filter-card .card-body {
        padding: 14px 16px;
    }

    /* Date presets: horizontal pill scroll on mobile */
    .drp-presets {
        display: flex !important;
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
        flex-wrap: nowrap !important;
        gap: 6px !important;
        padding-bottom: 6px;
        margin-bottom: 12px !important;
        border-bottom: 1px dashed var(--border, #e2e8f0);
        padding-top: 2px;
    }
    .drp-presets::-webkit-scrollbar { display: none; }
    .drp-btn {
        flex-shrink: 0 !important;
        padding: 5px 12px !important;
        font-size: 12px !important;
        border-radius: 20px !important;
    }

    /* Filter form grid on mobile */
    .filter-card form.d-flex,
    .filter-card form[style*="display:flex"],
    .filter-card form.cr-filters {
        display: grid !important;
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 12px !important;
        align-items: end !important;
    }
    .filter-card form .drp-presets {
        grid-column: 1 / -1 !important;
    }
    .filter-card form .form-group,
    .filter-card form .form-group.mb-0 {
        margin-bottom: 0 !important;
        width: 100% !important;
        min-width: 0 !important;
    }
    .filter-card form .form-control {
        width: 100% !important;
        box-sizing: border-box !important;
        font-size: 13px !important;
        padding: 8px 10px !important;
        border-radius: 8px !important;
    }
    .filter-card form input[style*="width"],
    .filter-card form select[style*="width"] {
        width: 100% !important;
    }

    /* Submit / Reset button row */
    .filter-card form > div:last-child {
        grid-column: 1 / -1 !important;
        display: flex !important;
        gap: 8px !important;
        margin-top: 4px;
    }
    .filter-card form > div:last-child .btn {
        flex: 1 !important;
        justify-content: center !important;
        padding: 9px 14px !important;
        font-size: 13px !important;
    }
}

@media (max-width: 420px) {
    .filter-card form.d-flex,
    .filter-card form[style*="display:flex"],
    .filter-card form.cr-filters {
        grid-template-columns: 1fr !important;
    }
}

/* ══════════════════════════════════════════════════════════════════
   ANALYTICS DASHBOARD HEADER — RESPONSIVE MOBILE FILTER COLLAPSIBLE
   ══════════════════════════════════════════════════════════════════ */
.dash-filter-toggle-btn {
    display: none; /* hidden on desktop */
}

@media (max-width: 900px) {
    .dash-header, .an-header {
        position: relative !important;
        flex-direction: column !important;
        align-items: stretch !important;
        gap: 10px !important;
        padding: 16px 18px !important;
    }

    /* Glassmorphism toggle button on mobile */
    .dash-filter-toggle-btn {
        display: inline-flex !important;
        align-items: center !important;
        justify-content: space-between !important;
        gap: 8px !important;
        padding: 9px 16px !important;
        background: rgba(255, 255, 255, 0.22) !important;
        border: 1px solid rgba(255, 255, 255, 0.35) !important;
        border-radius: 30px !important;
        color: #ffffff !important;
        font-size: 13px !important;
        font-weight: 700 !important;
        cursor: pointer !important;
        backdrop-filter: blur(12px) !important;
        -webkit-backdrop-filter: blur(12px) !important;
        transition: all 0.2s ease !important;
        margin-top: 6px !important;
        width: max-content !important;
        align-self: flex-start !important;
        z-index: 2 !important;
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15) !important;
    }

    .dash-filter-toggle-btn:hover {
        background: rgba(255, 255, 255, 0.32) !important;
        border-color: rgba(255, 255, 255, 0.55) !important;
    }

    .dash-filter-toggle-btn .dash-toggle-chevron {
        font-size: 10px !important;
        transition: transform 0.25s ease !important;
        opacity: 0.85 !important;
        margin-left: 4px;
    }

    .dash-filter-toggle-btn.open .dash-toggle-chevron {
        transform: rotate(180deg) !important;
    }

    /* Hide filter options by default on mobile so it doesn't clutter screen */
    .dash-filters,
    .an-filters,
    #an-filter-bar {
        display: none !important;
    }

    /* Open state: glassmorphism drawer dropdown */
    .dash-filters.open,
    .an-filters.open,
    #an-filter-bar.open {
        display: grid !important;
        grid-template-columns: 1fr 1fr !important;
        gap: 10px !important;
        background: rgba(15, 10, 36, 0.65) !important;
        border: 1px solid rgba(255, 255, 255, 0.2) !important;
        border-radius: 14px !important;
        padding: 14px !important;
        margin-top: 8px !important;
        backdrop-filter: blur(20px) !important;
        -webkit-backdrop-filter: blur(20px) !important;
        box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25) !important;
        position: relative !important;
        z-index: 5 !important;
        width: 100% !important;
        box-sizing: border-box !important;
    }

    /* Period tabs inside filter dropdown: horizontal scroll */
    .dash-period-tabs,
    .an-period-tabs {
        grid-column: 1 / -1 !important;
        display: flex !important;
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
        flex-wrap: nowrap !important;
        gap: 6px !important;
        padding-bottom: 6px !important;
        width: 100% !important;
        border-bottom: 1px dashed rgba(255, 255, 255, 0.2) !important;
        margin-bottom: 4px !important;
    }
    .dash-period-tabs::-webkit-scrollbar,
    .an-period-tabs::-webkit-scrollbar {
        display: none !important;
    }

    .dash-period-tab,
    .an-period-tab {
        flex-shrink: 0 !important;
        padding: 6px 12px !important;
        font-size: 11.5px !important;
        border-radius: 20px !important;
    }

    .dash-f-input,
    .an-filter-input {
        width: 100% !important;
        min-width: 0 !important;
        box-sizing: border-box !important;
        background: rgba(255, 255, 255, 0.15) !important;
        border: 1px solid rgba(255, 255, 255, 0.3) !important;
        color: #ffffff !important;
        font-size: 13px !important;
        padding: 9px 12px !important;
        border-radius: 8px !important;
    }

    .dash-filters.open > span,
    .an-filters.open > span {
        display: none !important;
    }

    #f-tz {
        grid-column: 1 / -1 !important;
    }

    .dash-btn-apply,
    .dash-btn-reset {
        padding: 10px 14px !important;
        font-size: 13px !important;
        border-radius: 8px !important;
        justify-content: center !important;
    }
}

@media (max-width: 480px) {
    .dash-filters.open,
    .an-filters.open,
    #an-filter-bar.open {
        grid-template-columns: 1fr !important;
    }
}

/* ══════════════════════════════════════════════════════════════════
   SMARTLINK CARD — MODERN STYLING
   ══════════════════════════════════════════════════════════════════ */
.smartlink-card {
    transition: transform 0.25s ease, box-shadow 0.25s ease, border-color 0.25s ease !important;
}
.smartlink-card:hover {
    transform: translateY(-4px) !important;
    box-shadow: 0 12px 30px -4px rgba(124, 58, 237, 0.16), 0 4px 12px -2px rgba(0, 0, 0, 0.05) !important;
    border-color: rgba(124, 58, 237, 0.35) !important;
}

html[data-theme="dark"] .smartlink-card {
    background: rgba(15, 23, 42, 0.75) !important;
    border-color: rgba(255, 255, 255, 0.12) !important;
}

/* ══════════════════════════════════════════════════════════════════
   OFFERS SECTION — ADVANCED & BEAUTIFUL RESPONSIVE STYLING
   ══════════════════════════════════════════════════════════════════ */
#tbl-offers, table.dataTable {
    border-collapse: separate !important;
    border-spacing: 0 !important;
    border-radius: 12px;
}

/* Modern ID badge style */
span[style*="OFF-"] {
    background: linear-gradient(135deg, #eff6ff 0%, #dbeafe 100%) !important;
    color: #1d4ed8 !important;
    border: 1px solid #bfdbfe !important;
    border-radius: 6px !important;
    padding: 3px 8px !important;
    font-size: 11px !important;
    font-weight: 700 !important;
    font-family: monospace !important;
    display: inline-block !important;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.03) !important;
}

/* Modern Details, Preview, and T&C action buttons */
button[onclick*="showOfferDetailsModal"],
button[onclick*="toggleListTerms"],
a[href*="preview_url"] {
    border-radius: 8px !important;
    font-size: 11.5px !important;
    font-weight: 700 !important;
    padding: 4px 10px !important;
    transition: all 0.15s ease !important;
}

button[onclick*="showOfferDetailsModal"]:hover {
    background: #4f46e5 !important;
    color: #ffffff !important;
    border-color: #4f46e5 !important;
}

/* ══════════════════════════════════════════════════════════════════
   3D OFFER CARD — ADVANCED 3D ELEVATION & HOVER STYLING
   ══════════════════════════════════════════════════════════════════ */
.offer-3d-card {
    transition: transform 0.28s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.28s ease, border-color 0.28s ease !important;
    position: relative !important;
}

.offer-3d-card:hover {
    transform: translateY(-7px) scale(1.015) !important;
    box-shadow: 0 22px 40px -10px rgba(124, 58, 237, 0.2), 0 14px 20px -8px rgba(0, 0, 0, 0.07), inset 0 1px 0 rgba(255, 255, 255, 0.95) !important;
    border-color: rgba(124, 58, 237, 0.4) !important;
    z-index: 2 !important;
}

.offer-3d-card button.btn-primary,
.offer-3d-card .btn-primary {
    transition: transform 0.18s ease, box-shadow 0.18s ease, background 0.18s ease !important;
}

.offer-3d-card button.btn-primary:hover,
.offer-3d-card .btn-primary:hover {
    transform: translateY(-2px) !important;
    box-shadow: 0 8px 22px rgba(124, 58, 237, 0.5), inset 0 1px 0 rgba(255, 255, 255, 0.4) !important;
}

.offer-3d-card button.btn-primary:active,
.offer-3d-card .btn-primary:active {
    transform: translateY(1px) !important;
    box-shadow: 0 3px 10px rgba(124, 58, 237, 0.3) !important;
}

html[data-theme="dark"] .offer-3d-card {
    background: linear-gradient(145deg, rgba(15, 23, 42, 0.9), rgba(30, 41, 59, 0.85)) !important;
    border-color: rgba(255, 255, 255, 0.12) !important;
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.4) !important;
}

html[data-theme="dark"] .offer-3d-card:hover {
    box-shadow: 0 22px 40px -10px rgba(124, 58, 237, 0.35), 0 14px 20px -8px rgba(0, 0, 0, 0.5) !important;
    border-color: rgba(167, 139, 250, 0.5) !important;
}

/* ══════════════════════════════════════════════════════════════════
   3D GLASSMORPHISM MODAL ANIMATION & ELEVATION
   ══════════════════════════════════════════════════════════════════ */
@keyframes modalFadeIn {
    0% { opacity: 0; }
    100% { opacity: 1; }
}

@keyframes modalPop3D {
    0% {
        opacity: 0;
        transform: scale(0.92) translateY(24px) rotateX(-6deg);
    }
    100% {
        opacity: 1;
        transform: scale(1) translateY(0) rotateX(0deg);
    }
}

.modal-content, .modal-3d-box {
    border-radius: 20px !important;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.28), 0 12px 24px -8px rgba(124, 58, 237, 0.2), inset 0 1px 0 rgba(255, 255, 255, 0.95) !important;
    border: 1px solid rgba(226, 232, 240, 0.85) !important;
}

html[data-theme="dark"] .modal-content,
html[data-theme="dark"] .modal-3d-box {
    background: linear-gradient(145deg, rgba(15, 23, 42, 0.96), rgba(30, 41, 59, 0.92)) !important;
    border-color: rgba(255, 255, 255, 0.15) !important;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.6), 0 12px 24px -8px rgba(124, 58, 237, 0.4) !important;
}

/* ══════════════════════════════════════════════════════════════════
   GLOBAL 3D EFFECT DESIGN SYSTEM & RESPONSIVE UI ENGINE
   ══════════════════════════════════════════════════════════════════ */
.card, .stat-card, .kpi-card, .chart-card, .metric-card, .info-card, .data-card, .widget-card, .dashboard-card, .summary-card, .report-card, .panel, .box {
    border-radius: 20px !important;
    border: 1px solid rgba(226, 232, 240, 0.85) !important;
    border-top: 1.5px solid rgba(255, 255, 255, 0.95) !important;
    box-shadow: 0 14px 30px -8px rgba(99, 102, 241, 0.08), 0 4px 12px -2px rgba(0, 0, 0, 0.03), inset 0 1px 0 rgba(255, 255, 255, 0.95) !important;
    transition: transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.25s ease, border-color 0.25s ease !important;
    backdrop-filter: blur(20px) !important;
    -webkit-backdrop-filter: blur(20px) !important;
}

.card:hover, .stat-card:hover, .kpi-card:hover, .chart-card:hover, .metric-card:hover {
    transform: translateY(-5px) scale(1.01) !important;
    box-shadow: 0 22px 40px -10px rgba(99, 102, 241, 0.22), inset 0 1px 0 rgba(255, 255, 255, 1) !important;
    border-color: rgba(99, 102, 241, 0.4) !important;
}

.stat-icon, .kpi-icon {
    border-radius: 14px !important;
    box-shadow: 0 6px 16px -2px rgba(99, 102, 241, 0.2), inset 0 1px 0 rgba(255, 255, 255, 0.8) !important;
    transition: transform 0.25s ease !important;
}
.stat-card:hover .stat-icon, .kpi-card:hover .kpi-icon {
    transform: scale(1.12) rotate(4deg) !important;
}

.btn, .btn-primary, .btn-secondary, .btn-outline {
    border-radius: 14px !important;
    font-weight: 700 !important;
    transition: all 0.2s cubic-bezier(0.34, 1.56, 0.64, 1) !important;
    box-shadow: 0 4px 14px -2px rgba(99, 102, 241, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.35) !important;
}

.btn-primary {
    background: linear-gradient(135deg, #6366F1 0%, #4F46E5 100%) !important;
    border: 1px solid rgba(255, 255, 255, 0.3) !important;
    color: #ffffff !important;
}

.btn-primary:hover {
    transform: translateY(-2px) scale(1.02) !important;
    box-shadow: 0 8px 22px -4px rgba(99, 102, 241, 0.5), inset 0 1px 0 rgba(255, 255, 255, 0.5) !important;
}

.btn-primary:active {
    transform: translateY(1px) scale(0.98) !important;
    box-shadow: 0 2px 8px rgba(99, 102, 241, 0.3) !important;
}

.drp-btn, .pill-btn, .filter-pill, .seg-btn {
    border-radius: 14px !important;
    font-weight: 700 !important;
    border: 1px solid rgba(226, 232, 240, 0.9) !important;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.04) !important;
    transition: all 0.2s ease !important;
}

.drp-btn-active, .pill-btn.active, .filter-pill.active, .seg-btn.active {
    background: linear-gradient(135deg, #6366F1 0%, #4F46E5 100%) !important;
    color: #ffffff !important;
    border-color: rgba(255, 255, 255, 0.4) !important;
    box-shadow: 0 6px 18px -2px rgba(99, 102, 241, 0.45), inset 0 1px 0 rgba(255, 255, 255, 0.4) !important;
}

.table-wrap, table {
    border-radius: 16px !important;
    overflow: hidden !important;
}
thead tr {
    background: linear-gradient(135deg, #EEF2FF 0%, #E0E7FF 100%) !important;
}
thead th {
    border-bottom: 2px solid #C7D2FE !important;
    font-weight: 800 !important;
    letter-spacing: 0.08em !important;
}

@media (max-width: 768px) {
    .stats-grid {
        grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)) !important;
        gap: 10px !important;
    }
    .stat-card {
        padding: 14px !important;
        border-radius: 16px !important;
    }
    .stat-value {
        font-size: 22px !important;
    }
}
