/* ============================================
   AFFILIATE TRACKER - PREMIUM STYLESHEET
   ============================================ */

:root {
    --sidebar-width: 260px;
    --sidebar-collapsed: 72px;
    --topbar-height: 60px;
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --primary-light: #eff6ff;
    --primary-rgb: 37, 99, 235;
    --success: #059669;
    --warning: #d97706;
    --danger: #dc2626;
    --info: #0891b2;
    --text-primary: #111827;
    --text-secondary: #4b5563;
    --text-muted: #6b7280;
    --bg-body: #f5f7fb;
    --bg-card: #ffffff;
    --bg-soft: #f9fafb;
    --border-color: #e5e7eb;
    --border-strong: #d1d5db;
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.04);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.06);
    --shadow-lg: 0 8px 24px rgba(0,0,0,0.08);
    --shadow-xl: 0 20px 40px rgba(0,0,0,0.1);
    --radius-sm: 6px;
    --radius-md: 8px;
    --radius-lg: 10px;
    --radius-xl: 12px;
    --transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Dark Mode */
[data-bs-theme="dark"] {
    --text-primary: #f1f5f9;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    --bg-body: #0f172a;
    --bg-card: #1e293b;
    --bg-soft: #111827;
    --border-color: #334155;
    --border-strong: #475569;
    --primary-light: #1e1b4b;
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.2);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.3);
    --shadow-lg: 0 8px 24px rgba(0,0,0,0.35);
}

[data-bs-theme="dark"] body { background-color: var(--bg-body); }
[data-bs-theme="dark"] .sidebar { background: #1e293b; border-color: #334155; }
[data-bs-theme="dark"] .topbar { background: #1e293b !important; border-color: #334155 !important; }
[data-bs-theme="dark"] .stat-card { background: #1e293b; border-color: #334155; }
[data-bs-theme="dark"] .stat-card .stat-value { color: #f1f5f9; }
[data-bs-theme="dark"] .card { background: #1e293b; border-color: #334155; }
[data-bs-theme="dark"] .card-header { border-color: #334155; }
[data-bs-theme="dark"] .table { color: #e2e8f0; }
[data-bs-theme="dark"] .table th { color: #94a3b8; border-color: #334155; }
[data-bs-theme="dark"] .table td { border-color: #334155; }
[data-bs-theme="dark"] .filter-bar { background: #1e293b; border-color: #334155; }
[data-bs-theme="dark"] .tracking-link { background: #0f172a; border-color: #334155; color: #e2e8f0; }
[data-bs-theme="dark"] .auth-card { background: #1e293b; }
[data-bs-theme="dark"] .auth-card h2 { color: #f1f5f9; }
[data-bs-theme="dark"] .sidebar-link { color: #94a3b8; }
[data-bs-theme="dark"] .sidebar-link:hover { color: #c7d2fe; background: rgba(99,102,241,0.1); }
[data-bs-theme="dark"] .form-control, [data-bs-theme="dark"] .form-select { background: #0f172a; border-color: #334155; color: #e2e8f0; }
[data-bs-theme="dark"] .dropdown-menu { background: #1e293b; border-color: #334155; }
[data-bs-theme="dark"] .dropdown-item { color: #e2e8f0; }
[data-bs-theme="dark"] .dropdown-item:hover { background: #334155; }
[data-bs-theme="dark"] .modal-content { background: #1e293b; border-color: #334155; }
[data-bs-theme="dark"] .nav-tabs .nav-link { color: #94a3b8; }
[data-bs-theme="dark"] .nav-tabs .nav-link.active { color: #c7d2fe; background: transparent; border-color: #334155 #334155 #1e293b; }

/* ---- Global ---- */
* { box-sizing: border-box; }

html {
    min-height: 100%;
    overflow-x: hidden;
}

body {
    font-family: 'Inter', 'Segoe UI', system-ui, -apple-system, sans-serif;
    background-color: var(--bg-body);
    color: var(--text-primary);
    margin: 0;
    min-height: 100%;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

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

::selection { background: rgba(var(--primary-rgb), 0.15); }

/* Scrollbar */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #94a3b8; }

/* ---- Auth Pages ---- */
.auth-wrapper {
    min-height: 100vh;
    min-height: 100svh;
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: #111827;
    position: relative;
    overflow-x: hidden;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    gap: 0.75rem;
    padding: max(1rem, env(safe-area-inset-top)) max(1rem, env(safe-area-inset-right)) max(1rem, env(safe-area-inset-bottom)) max(1rem, env(safe-area-inset-left));
}

.auth-card {
    width: min(100%, 460px);
    max-width: 460px;
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    padding: 2.5rem;
    box-shadow: var(--shadow-xl);
    position: relative;
    z-index: 1;
    animation: authSlideUp 0.5s ease-out;
    border: 1px solid rgba(255,255,255,0.22);
}

@keyframes authSlideUp {
    from { opacity: 0; transform: translateY(30px); }
    to { opacity: 1; transform: translateY(0); }
}

.auth-card h2 {
    font-weight: 800;
    color: var(--text-primary);
    letter-spacing: 0;
    font-size: clamp(1.35rem, 4vw, 1.75rem);
    line-height: 1.2;
}

.auth-logo {
    width: 56px;
    height: 56px;
    background: linear-gradient(135deg, var(--primary), var(--info));
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 1.5rem;
    margin: 0 auto 1rem;
    box-shadow: 0 8px 16px rgba(var(--primary-rgb), 0.24);
}

.auth-brand-logo {
    display: block;
    width: min(230px, 72%);
    height: auto;
    max-height: 72px;
    object-fit: contain;
    margin: 0 auto 1rem;
}

/* ---- Sidebar ---- */
.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: var(--sidebar-width);
    height: 100vh;
    background: var(--bg-card);
    border-right: 1px solid var(--border-color);
    z-index: 1040;
    transition: var(--transition);
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    overflow-x: hidden;
}

.sidebar-header {
    padding: 1rem 1.1rem;
    border-bottom: 1px solid var(--border-color);
    flex-shrink: 0;
}

.sidebar-brand-logo {
    display: block;
    width: 100%;
    max-width: 205px;
    height: 54px;
    object-fit: contain;
    object-position: left center;
}

.sidebar-header h5 {
    background: linear-gradient(135deg, var(--primary), var(--info));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    font-weight: 800;
    font-size: 1.15rem;
    letter-spacing: 0;
}

.sidebar-nav {
    flex: 1;
    padding: 0.7rem;
    overflow-y: auto;
}

.sidebar-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 9px 12px;
    color: var(--text-secondary);
    border-radius: 7px;
    text-decoration: none;
    font-size: 0.875rem;
    font-weight: 500;
    margin-bottom: 2px;
    transition: var(--transition);
    position: relative;
}

.sidebar-link:hover {
    background: var(--primary-light);
    color: var(--primary);
}

.sidebar-link.active {
    background: var(--primary);
    color: #fff;
    box-shadow: 0 3px 10px rgba(var(--primary-rgb), 0.2);
}

.sidebar-link.active:hover { transform: none; }

.sidebar-link i {
    font-size: 1.15rem;
    width: 22px;
    text-align: center;
    flex-shrink: 0;
}

.sidebar-section {
    font-size: 0.65rem;
    text-transform: uppercase;
    letter-spacing: 1.2px;
    color: var(--text-muted);
    padding: 0.95rem 12px 0.35rem;
    font-weight: 700;
}

.sidebar-footer {
    padding: 1rem 1.25rem;
    border-top: 1px solid var(--border-color);
    flex-shrink: 0;
}

/* ---- Main Content ---- */
.main-content {
    margin-left: var(--sidebar-width);
    min-height: 100vh;
    min-width: 0;
    width: calc(100% - var(--sidebar-width));
    transition: var(--transition);
}

.content-area {
    padding: 1.5rem;
    max-width: 1500px;
    width: 100%;
    overflow-x: clip;
}

/* ---- Topbar ---- */
.topbar {
    position: sticky;
    top: 0;
    z-index: 1030;
    background: var(--bg-card) !important;
    border-bottom: 1px solid var(--border-color) !important;
    backdrop-filter: blur(14px);
    height: var(--topbar-height);
    box-shadow: 0 1px 0 rgba(17, 24, 39, 0.02);
}

.topbar h5 {
    font-weight: 700;
    font-size: 1rem;
    letter-spacing: 0;
}

.topbar-brand-logo {
    width: 86px;
    height: 28px;
    object-fit: contain;
    object-position: left center;
}

.topbar-search .input-group {
    min-width: 0;
}

.topbar-search .form-control {
    min-width: 0;
}

.topbar-search .btn {
    width: 34px;
    padding-left: 0;
    padding-right: 0;
}

/* ---- Stat Cards ---- */
.stat-card {
    background: var(--bg-card);
    border-radius: var(--radius-md);
    padding: 1rem 1.1rem;
    border: 1px solid var(--border-color);
    transition: var(--transition);
    position: relative;
    overflow: hidden;
    box-shadow: var(--shadow-sm);
}

.stat-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, var(--primary), var(--info));
    opacity: 0;
    transition: var(--transition);
}

@media (hover: hover) {
    .stat-card:hover { box-shadow: var(--shadow-md); transform: translateY(-1px); }
}

.stat-card:hover::before { opacity: 1; }

.stat-card .stat-icon {
    width: 48px;
    height: 48px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.3rem;
}

.stat-card .stat-value {
    font-size: 1.45rem;
    font-weight: 800;
    color: var(--text-primary);
    letter-spacing: 0;
    line-height: 1.2;
}

.stat-card .stat-label {
    font-size: 0.72rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.4px;
    font-weight: 600;
    margin-bottom: 4px;
}

.stat-card .stat-change {
    font-size: 0.75rem;
    font-weight: 600;
    margin-top: 4px;
}

.stat-card .stat-change.up { color: var(--success); }
.stat-card .stat-change.down { color: var(--danger); }

/* ---- Cards ---- */
.card {
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    background: var(--bg-card);
    transition: var(--transition);
}

.card:hover { box-shadow: var(--shadow-sm); }

.card-header {
    background: var(--bg-soft);
    border-bottom: 1px solid var(--border-color);
    padding: 0.85rem 1rem;
    font-weight: 600;
}

.card-header h6 {
    font-weight: 700;
    letter-spacing: 0;
}

/* ---- Tables ---- */
.table { margin-bottom: 0; --bs-table-bg: transparent; }

.table th {
    font-size: 0.68rem;
    text-transform: uppercase;
    letter-spacing: 0.45px;
    color: var(--text-muted);
    font-weight: 700;
    border-bottom-width: 1px;
    padding: 0.68rem 0.85rem;
    white-space: nowrap;
    background: var(--bg-soft);
}

[data-bs-theme="dark"] .table th { background: rgba(15, 23, 42, 0.3); }

.table td {
    vertical-align: middle;
    font-size: 0.84rem;
    padding: 0.62rem 0.85rem;
    color: var(--text-secondary);
}

.table-hover tbody tr {
    transition: var(--transition);
}

.table-hover tbody tr:hover { background-color: rgba(var(--primary-rgb), 0.045) !important; }

.table a { font-weight: 600; }

/* ---- Badges ---- */
.badge {
    font-weight: 600;
    padding: 0.34em 0.62em;
    font-size: 0.7rem;
    border-radius: 5px;
    letter-spacing: 0;
}

/* ---- Buttons ---- */
.btn { font-weight: 600; font-size: 0.86rem; border-radius: var(--radius-sm); transition: var(--transition); }
.btn:active { transform: scale(0.97); }

.btn-primary {
    background: var(--primary);
    border-color: var(--primary);
    box-shadow: 0 2px 6px rgba(var(--primary-rgb), 0.18);
}

.btn-primary:hover {
    background: var(--primary-dark);
    border-color: var(--primary-dark);
    box-shadow: 0 3px 10px rgba(var(--primary-rgb), 0.24);
}

.btn-outline-primary { border-color: var(--primary); color: var(--primary); }
.btn-outline-primary:hover { background: var(--primary); border-color: var(--primary); }

.btn-group-sm .btn { border-radius: 6px; }

/* ---- Forms ---- */
.form-control, .form-select {
    border-radius: var(--radius-sm);
    border-color: var(--border-color);
    font-size: 0.875rem;
    padding: 0.55rem 0.75rem;
    transition: var(--transition);
}

.form-control:focus, .form-select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(var(--primary-rgb), 0.1);
}

.form-label {
    font-weight: 600;
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-bottom: 0.35rem;
}

.input-group-text {
    border-color: var(--border-color);
    background: var(--bg-soft);
    font-size: 0.875rem;
}

[data-bs-theme="dark"] .input-group-text { background: #0f172a; border-color: #334155; color: #94a3b8; }

/* ---- Charts ---- */
.chart-container {
    position: relative;
    height: 320px;
    padding: 0.5rem;
}

/* ---- Pagination ---- */
.pagination .page-link {
    border-radius: var(--radius-sm);
    margin: 0 2px;
    font-size: 0.85rem;
    font-weight: 600;
    border-color: var(--border-color);
    color: var(--text-secondary);
    transition: var(--transition);
}

.pagination .page-item.active .page-link {
    background: var(--primary);
    border-color: var(--primary);
}

/* ---- Copy button ---- */
.copy-btn {
    cursor: pointer;
    opacity: 0.6;
    transition: var(--transition);
    border-radius: 6px;
}

.copy-btn:hover { opacity: 1; transform: scale(1.05); }

/* ---- Tracking link ---- */
.tracking-link {
    background: #f1f5f9;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 10px 14px;
    font-family: 'JetBrains Mono', 'Fira Code', monospace;
    font-size: 0.8rem;
    word-break: break-all;
    line-height: 1.4;
}

/* ---- Filter bar ---- */
.filter-bar {
    background: var(--bg-card);
    border-radius: var(--radius-md);
    padding: 0.85rem 1rem;
    border: 1px solid var(--border-color);
    margin-bottom: 1rem;
    box-shadow: var(--shadow-sm);
}

/* ---- Empty state ---- */
.empty-state {
    text-align: center;
    padding: 3rem 1.5rem;
    color: var(--text-muted);
}

.empty-state i {
    font-size: 3.5rem;
    margin-bottom: 1rem;
    opacity: 0.4;
}

.empty-state p { font-size: 0.95rem; }

/* ---- Alerts ---- */
.alert {
    border-radius: var(--radius-md);
    font-size: 0.875rem;
    font-weight: 500;
    border: none;
    animation: alertSlide 0.3s ease-out;
}

@keyframes alertSlide {
    from { opacity: 0; transform: translateY(-10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ---- Nav Tabs ---- */
.nav-tabs {
    border-bottom: 2px solid var(--border-color);
}

.nav-tabs .nav-link {
    font-weight: 600;
    font-size: 0.85rem;
    color: var(--text-muted);
    border: none;
    padding: 0.75rem 1.25rem;
    position: relative;
    transition: var(--transition);
}

.nav-tabs .nav-link:hover { color: var(--primary); border: none; }

.nav-tabs .nav-link.active {
    color: var(--primary);
    background: transparent;
    border: none;
}

.nav-tabs .nav-link.active::after {
    content: '';
    position: absolute;
    bottom: -2px;
    left: 0;
    right: 0;
    height: 2px;
    background: var(--primary);
    border-radius: 2px;
}

/* ---- Modal ---- */
.modal-content {
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-xl);
}

.modal-header { border-bottom: 1px solid var(--border-color); }
.modal-footer { border-top: 1px solid var(--border-color); }

/* ---- Tooltips ---- */
.tooltip-inner { border-radius: 6px; font-size: 0.75rem; }

/* ---- Loading spinner ---- */
.spinner-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255,255,255,0.9);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    backdrop-filter: blur(4px);
}

/* ---- Theme Toggle ---- */
.theme-toggle {
    cursor: pointer;
    width: 36px;
    height: 36px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
    border: 1px solid var(--border-color);
    background: transparent;
    color: var(--text-secondary);
}

.theme-toggle:hover { background: var(--primary-light); color: var(--primary); }

/* ---- Responsive app polish ---- */
.content-area > .d-flex:first-child h4,
.content-area > .d-flex:first-child h5 {
    font-weight: 800;
    letter-spacing: 0;
}

.content-area > .d-flex:first-child .text-muted {
    color: var(--text-muted) !important;
}

.card-header {
    min-height: 48px;
}

.card-header.d-flex {
    gap: 0.75rem;
}

.card-header .btn,
.card-header .btn-group {
    flex-shrink: 0;
}

.filter-bar .form-control,
.filter-bar .form-select,
.card form .form-control,
.card form .form-select {
    min-width: 0;
}

.btn {
    white-space: nowrap;
}

.topbar .dropdown-menu {
    max-width: calc(100vw - 1.5rem);
}

.table-responsive {
    border-radius: var(--radius-md);
    background:
        linear-gradient(to right, var(--bg-card), var(--bg-card)) left / 16px 100% no-repeat,
        linear-gradient(to left, var(--bg-card), var(--bg-card)) right / 16px 100% no-repeat,
        linear-gradient(to right, rgba(15, 23, 42, 0.08), transparent) left / 18px 100% no-repeat,
        linear-gradient(to left, rgba(15, 23, 42, 0.08), transparent) right / 18px 100% no-repeat;
    background-attachment: local, local, scroll, scroll;
}

.table td,
.table th {
    max-width: 360px;
}

.table td {
    overflow-wrap: anywhere;
}

.table .btn,
.table .btn-group {
    white-space: nowrap;
}

.reports-table-wrap table {
    min-width: 760px;
}

.reports-tabs-bar {
    min-width: 0;
}

.reports-tabs-bar .nav-tabs {
    min-width: 0;
    flex: 1 1 auto;
}

.reports-actions {
    flex: 0 0 auto;
}

/* ---- Operational UI polish ---- */
.topbar .dropdown-menu {
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md) !important;
    box-shadow: var(--shadow-lg) !important;
}

.topbar .dropdown-item,
.topbar .dropdown-item-text {
    font-size: 0.86rem;
}

.table-responsive {
    scrollbar-width: thin;
}

.table-sm > :not(caption) > * > * {
    padding: 0.55rem 0.75rem;
}

.card .card {
    box-shadow: none;
}

.content-area > .card,
.content-area > .row,
.content-area > form.card,
.content-area > .alert {
    max-width: 100%;
}

.form-text {
    color: var(--text-muted);
    font-size: 0.75rem;
}

code.small,
.table code {
    background: var(--bg-soft);
    border: 1px solid var(--border-color);
    border-radius: 5px;
    padding: 0.12rem 0.28rem;
    color: var(--text-secondary);
}

.modal-header,
.modal-footer {
    padding: 0.9rem 1rem;
}

.modal-body {
    padding: 1rem;
}

/* ---- Quick Stats Row ---- */
.quick-stats {
    display: flex;
    gap: 1rem;
    padding: 0.75rem 0;
}

.quick-stat-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.8rem;
    color: var(--text-muted);
}

.quick-stat-item strong { color: var(--text-primary); }

/* ---- Offer Cards ---- */
.offer-card {
    transition: var(--transition);
    border: 1px solid var(--border-color);
}

.offer-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-lg);
    border-color: rgba(var(--primary-rgb), 0.3);
}

/* ---- Page transitions ---- */
.content-area {
    animation: pageIn 0.3s ease-out;
}

@keyframes pageIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ---- Responsive ---- */
@media (max-width: 991.98px) {
    .sidebar {
        transform: translateX(-100%);
        width: min(86vw, 300px);
    }

    .sidebar.show {
        transform: translateX(0);
        box-shadow: var(--shadow-xl);
    }

    .main-content {
        margin-left: 0;
        width: 100%;
    }

    .sidebar-overlay {
        display: none;
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(0,0,0,0.5);
        z-index: 1035;
        backdrop-filter: blur(2px);
    }

    .sidebar-overlay.show {
        display: block;
        animation: fadeIn 0.2s ease;
    }

    .content-area { padding: 1rem; }

    .stat-card { padding: 1rem; }
    .stat-card .stat-value { font-size: 1.25rem; }

    .chart-container { height: 280px; }

    .topbar {
        height: 58px;
    }

    .nav-tabs {
        flex-wrap: nowrap;
        overflow-x: auto;
        overflow-y: hidden;
        scrollbar-width: thin;
    }

    .nav-tabs .nav-link {
        white-space: nowrap;
    }
}

@media (max-width: 700px) {
    .auth-card { max-width: 350px; }

    .filter-bar {
        display: flex;
        flex-direction: column;
        align-items: stretch !important;
        gap: 0.65rem !important;
    }

    .filter-bar > *,
    .filter-bar .form-control,
    .filter-bar .form-select,
    .filter-bar .btn {
        width: 100% !important;
        min-width: 0 !important;
    }

    .content-area > form.card .row > [class*="col-"],
    .content-area > .card form .row > [class*="col-"] {
        width: 100%;
    }

    .content-area > .d-flex:first-child {
        align-items: stretch !important;
        flex-direction: column;
        flex-wrap: wrap;
    }

    .content-area > .d-flex:first-child > * {
        width: 100%;
    }
}

@media (max-width: 575.98px) {
    .auth-wrapper {
        justify-content: flex-start;
        padding-top: max(0.9rem, env(safe-area-inset-top));
        padding-bottom: max(0.9rem, env(safe-area-inset-bottom));
    }

    .auth-card {
        width: min(100%, 360px);
        margin: 0 auto;
        padding: 1.35rem;
    }

    .auth-brand-logo { width: min(138px, 52%); max-height: 42px; margin-bottom: 0.65rem; }
    .topbar-brand-logo { width: 58px; height: 22px; }
    .topbar h5 { font-size: 0.95rem; }
    .topbar { padding-left: 0.75rem !important; padding-right: 0.75rem !important; }
    .theme-toggle { width: 34px; height: 34px; }
    .topbar .dropdown-menu { min-width: min(340px, calc(100vw - 1.5rem)) !important; }
    .btn-group { flex-wrap: wrap; }
    .table th, .table td { padding-left: 0.65rem; padding-right: 0.65rem; }

    body {
        background: linear-gradient(180deg, #eef4ff 0, var(--bg-body) 220px);
    }

    [data-bs-theme="dark"] body {
        background: linear-gradient(180deg, #111827 0, var(--bg-body) 220px);
    }

    .content-area {
        padding: 0.75rem;
    }

    .card {
        border-radius: 10px;
    }

    .card-header {
        padding: 0.75rem 0.85rem;
        flex-wrap: wrap;
    }

    .card-body {
        padding: 0.85rem;
    }

    .stat-card {
        min-height: 94px;
        padding: 0.85rem;
    }

    .stat-card .stat-icon {
        width: 40px;
        height: 40px;
        font-size: 1.05rem;
    }

    .stat-card .stat-value {
        font-size: 1.12rem;
        word-break: break-word;
    }

    .stat-card .stat-label {
        font-size: 0.66rem;
    }

    .chart-container {
        height: 230px;
        padding: 0.25rem;
    }

    .btn,
    .form-control,
    .form-select {
        min-height: 38px;
    }

    .form-control,
    .form-select {
        font-size: 16px;
    }

    .btn {
        white-space: normal;
        line-height: 1.25;
    }

    .btn-group {
        display: flex;
        width: 100%;
    }

    .btn-group > .btn {
        flex: 1 1 auto;
    }

    .pagination {
        flex-wrap: wrap;
        gap: 0.25rem;
    }

    .report-filter-card .card-body {
        padding: 0.8rem;
    }

    .report-filter-card .row {
        --bs-gutter-y: 0.6rem;
    }

    .report-chart-head .btn-group {
        width: 100%;
    }

    .reports-tabs-bar {
        align-items: stretch !important;
        flex-direction: column;
    }

    .reports-tabs-bar .nav-tabs {
        width: 100%;
    }

    .reports-actions {
        display: grid !important;
        grid-template-columns: 1fr;
        width: 100%;
    }

    .reports-actions .btn {
        width: 100%;
    }

    .mobile-card-table {
        overflow: visible;
    }

    .mobile-card-table table,
    .mobile-card-table thead,
    .mobile-card-table tbody,
    .mobile-card-table tr,
    .mobile-card-table th,
    .mobile-card-table td {
        display: block;
        width: 100%;
    }

    .mobile-card-table thead {
        display: none;
    }

    .mobile-card-table tbody {
        padding: 0.15rem;
    }

    .mobile-card-table tbody tr {
        background: var(--bg-card);
        border: 1px solid var(--border-color);
        border-radius: 10px;
        box-shadow: var(--shadow-sm);
        margin: 0.7rem 0;
        overflow: hidden;
    }

    .mobile-card-table tbody tr:hover {
        background: var(--bg-card) !important;
    }

    .mobile-card-table td {
        border: 0 !important;
        border-bottom: 1px solid var(--border-color) !important;
        display: grid;
        grid-template-columns: minmax(88px, 38%) minmax(0, 1fr);
        gap: 0.75rem;
        align-items: start;
        padding: 0.72rem 0.85rem !important;
        font-size: 0.82rem;
        max-width: none;
    }

    .mobile-card-table td:last-child {
        border-bottom: 0 !important;
    }

    .mobile-card-table td::before {
        content: attr(data-label);
        color: var(--text-muted);
        font-size: 0.66rem;
        font-weight: 800;
        text-transform: uppercase;
        letter-spacing: 0.35px;
        line-height: 1.25;
    }

    .mobile-card-table td:not([data-label]) {
        display: block;
    }

    .mobile-card-table td:not([data-label])::before {
        content: none;
    }

    .mobile-card-table td[colspan] {
        display: block;
        text-align: center !important;
    }

    .mobile-card-table td[colspan]::before {
        content: none;
    }

    .mobile-card-table td .btn,
    .mobile-card-table td .btn-group,
    .mobile-card-table td form {
        max-width: 100%;
    }

    .mobile-card-table td .btn-group {
        display: inline-flex;
        width: auto;
        flex-wrap: wrap;
        gap: 0.25rem;
    }

    .reports-table-wrap {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .reports-table-wrap.mobile-card-table {
        overflow-x: auto;
    }

    .reports-table-wrap.mobile-card-table table {
        display: table;
        width: max-content;
        min-width: 760px;
    }

    .reports-table-wrap.mobile-card-table thead {
        display: table-header-group;
    }

    .reports-table-wrap.mobile-card-table tbody {
        display: table-row-group;
        padding: 0;
    }

    .reports-table-wrap.mobile-card-table tfoot {
        display: table-footer-group;
    }

    .reports-table-wrap.mobile-card-table tr {
        display: table-row;
        width: auto;
        margin: 0;
        border: 0;
        border-radius: 0;
        box-shadow: none;
    }

    .reports-table-wrap.mobile-card-table th,
    .reports-table-wrap.mobile-card-table td,
    .reports-table-wrap.mobile-card-table td:not([data-label]),
    .reports-table-wrap.mobile-card-table td[colspan] {
        display: table-cell;
        width: auto;
        border-bottom: 1px solid var(--border-color) !important;
        padding: 0.52rem 0.6rem !important;
        font-size: 0.78rem;
        max-width: 210px;
        white-space: nowrap;
    }

    .reports-table-wrap.mobile-card-table td::before,
    .reports-table-wrap.mobile-card-table td:not([data-label])::before,
    .reports-table-wrap.mobile-card-table td[colspan]::before {
        content: none;
    }

    .topbar .btn.rounded-pill {
        padding-left: 0.35rem !important;
        padding-right: 0.35rem !important;
    }

    .topbar .d-flex.align-items-center.gap-2 {
        gap: 0.35rem !important;
    }
}

@media (max-width: 575.98px) and (max-height: 720px) {
    .auth-wrapper {
        padding-top: max(0.85rem, env(safe-area-inset-top));
        padding-bottom: max(0.85rem, env(safe-area-inset-bottom));
    }

    .auth-card {
        padding: 1.15rem;
    }

    .auth-brand-logo {
        width: min(132px, 52%);
        max-height: 40px;
        margin-bottom: 0.55rem;
    }

    .auth-card h2 {
        font-size: 1.08rem;
    }
}

@supports not (min-height: 100dvh) {
    @supports (-webkit-touch-callout: none) {
        .auth-wrapper {
            min-height: -webkit-fill-available;
        }
    }
}

@media (max-width: 380px) {
    .topbar-brand-logo {
        display: none !important;
    }

    .topbar h5 {
        max-width: 44vw;
    }
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* ---- Utility animations ---- */
.animate-fade-in { animation: fadeIn 0.3s ease; }
.animate-slide-up { animation: authSlideUp 0.4s ease-out; }

/* ---- Print styles ---- */
@media print {
    .sidebar, .topbar, .sidebar-overlay, .btn, .filter-bar { display: none !important; }
    .main-content { margin-left: 0 !important; }
    .stat-card { break-inside: avoid; }
}
