/* ============================================================
   URLuj — Nexus Design System v5.0
   Professional | Mobile-First | Overflow-Free
   ============================================================ */

/* ── Google Fonts ── */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800;900&display=swap');
@import url('responsive.css');

/* ── Design Tokens ── */
:root {
    --brand: #10b981;
    --brand-light: #34d399;
    --brand-dark: #059669;
    --brand-xlight: #d1fae5;
    --brand-surface: #f0fdf4;

    --bg: #f9fafb;
    --surface: #ffffff;
    --surface-2: #f8fafc;
    --border: #e5e7eb;
    --border-strong: #d1d5db;

    --text-1: #111827;
    --text-2: #374151;
    --text-3: #6b7280;
    --text-4: #9ca3af;

    --danger: #ef4444;
    --danger-surface: #fef2f2;
    --danger-border: #fecaca;
    --warn: #f59e0b;
    --info: #3b82f6;

    --r-sm: 8px;
    --r-md: 12px;
    --r-lg: 16px;
    --r-xl: 24px;
    --r-pill: 100px;

    --shadow-sm: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.06), 0 2px 6px rgba(0,0,0,0.04);
    --shadow-lg: 0 10px 30px rgba(0,0,0,0.06), 0 4px 12px rgba(0,0,0,0.04);

    --sidebar-w: 240px;
    --header-h: 60px;
    --transition: 0.2s ease;

    /* ── Backward-compatibility aliases (for older pages) ── */
    --primary: #10b981;
    --primary-light: #34d399;
    --primary-dark: #059669;
    --primary-alt: #d1fae5;
    --primary-gradient: linear-gradient(135deg, #10b981, #059669);
    --secondary: #6366f1;
    --secondary-gradient: linear-gradient(135deg, #6366f1, #4f46e5);
    --danger: #ef4444;
    --bg-deep: #f9fafb;
    --bg-card: #ffffff;
    --bg-sidebar: #ffffff;
    --text-main: #111827;
    --text-muted: #6b7280;
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --shadow-premium: 0 4px 12px rgba(0,0,0,0.06);
    --surface-2: #f8fafc;
}

/* ── ABSOLUTE OVERFLOW-PROOF BASE RESET ── */
*, *::before, *::after {
    box-sizing: border-box !important;
    margin: 0;
    padding: 0;
    max-width: 100% !important;
    min-width: 0 !important;
    word-wrap: break-word !important;
    overflow-wrap: break-word !important;
    word-break: break-word !important;
}

html {
    font-size: 16px;
    -webkit-text-size-adjust: 100%;
    overflow-x: hidden !important;
    width: 100vw !important;
    max-width: 100vw !important;
}

body {
    font-family: 'Inter', 'Outfit', system-ui, sans-serif;
    background: var(--bg);
    color: var(--text-2);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    overflow-x: hidden !important;
    width: 100vw !important;
    max-width: 100vw !important;
    min-width: 0 !important;
}



/* Icon font fix */
i, [class*="fa-"] { font-family: "Font Awesome 6 Free", "Font Awesome 6 Brands" !important; }

.no-overflow { overflow-x: hidden !important; }

/* ── Scrollbar ── */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--brand); border-radius: 10px; }

/* ── Pulse Animation ── */
@keyframes signal-pulse {
    0% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.4); }
    70% { transform: scale(1); box-shadow: 0 0 0 10px rgba(16, 185, 129, 0); }
    100% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(16, 185, 129, 0); }
}

.live-indicator {
    width: 8px; height: 8px;
    background: var(--brand);
    border-radius: 50%;
    display: inline-block;
    animation: signal-pulse 2s infinite;
}



/* ============================================================
   LAYOUT — Admin Shell
   ============================================================ */

/* Mobile top bar */
.mobile-header {
    display: none;
    position: fixed;
    top: 0; left: 0; right: 0;
    height: var(--header-h);
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    padding: 0 1.2rem;
    align-items: center;
    justify-content: space-between;
    z-index: 1100;
}

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

.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.4);
    backdrop-filter: blur(4px);
    z-index: 999;
}

body.sidebar-active .sidebar-overlay { display: block; }
body.sidebar-active { overflow: hidden; }

/* Nav links */
.sidebar-label {
    font-size: 10px;
    font-weight: 700;
    color: var(--text-4);
    text-transform: uppercase;
    letter-spacing: 1.5px;
    padding: 1.2rem 0.6rem 0.5rem;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 0.6rem 0.8rem;
    border-radius: var(--r-md);
    color: var(--text-3);
    font-size: 0.875rem;
    font-weight: 500;
    text-decoration: none;
    transition: var(--transition);
    margin-bottom: 2px;
    white-space: nowrap;
    overflow: hidden;
}

.nav-link i {
    width: 20px;
    text-align: center;
    font-size: 1rem;
    flex-shrink: 0;
    opacity: 0.7;
    transition: var(--transition);
}

.nav-link:hover {
    background: var(--brand-surface);
    color: var(--brand);
}

.nav-link:hover i { opacity: 1; }

.nav-link.active {
    background: var(--brand);
    color: #fff;
    font-weight: 600;
}

.nav-link.active i { opacity: 1; }

/* Sidebar user */
.sidebar-user {
    margin-top: auto;
    padding-top: 1rem;
    border-top: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 10px;
    overflow: hidden;
}

.user-avatar {
    width: 36px;
    height: 36px;
    min-width: 36px;
    border-radius: var(--r-md);
    background: var(--brand-surface);
    color: var(--brand);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    font-size: 0.9rem;
}

.user-name { display: block; font-size: 0.8rem; font-weight: 600; color: var(--text-1); }
.user-email {
    display: block;
    font-size: 0.7rem;
    color: var(--text-3);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 130px;
}

/* Main content — 100% OVERFLOW-PROOF */
.main-content {
    margin-left: var(--sidebar-w);
    padding: 2.5rem 2rem;
    min-height: 100vh;
    width: auto !important;
    max-width: 100vw !important;
    box-sizing: border-box !important;
    overflow-x: hidden !important;
    overflow-y: auto !important;
    transition: var(--transition);
}

/* ── Collapsed sidebar at medium screens ── */
@media (max-width: 1280px) and (min-width: 769px) {
    .sidebar {
        width: 64px;
        padding: 1.5rem 0.5rem;
        align-items: center;
    }

    .sidebar .text,
    .sidebar h2,
    .sidebar .sidebar-label,
    .sidebar-user .user-meta { display: none !important; }

    .nav-link { justify-content: center; padding: 0.7rem; }
    .nav-link i { margin: 0; }
    .sidebar-user { justify-content: center; }

    .main-content {
        margin-left: 64px;
        width: auto !important;
        max-width: calc(100vw - 64px) !important;
    }
}



/* ============================================================
   CARDS
   ============================================================ */

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 1.75rem;
    box-shadow: 0 2px 12px rgba(0,0,0,0.05);
    overflow: hidden;
    position: relative;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    transition: all 0.3s ease;
}

.card:hover {
    box-shadow: 0 6px 20px rgba(0,0,0,0.08);
}

/* Universal Auto-Responsive Grid System */
.auto-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 1.25rem;
    width: 100%;
    box-sizing: border-box;
    overflow-x: hidden !important;
}

/* Stat cards */
.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1.25rem;
    margin-bottom: 2rem;
    width: 100%;
    box-sizing: border-box;
    overflow-x: hidden !important;
}

.stat-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 1.5rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    box-shadow: 0 2px 8px rgba(0,0,0,0.04);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    overflow: hidden;
    min-width: 0;
    box-sizing: border-box;
}

.stat-card:hover {
    border-color: var(--brand-light);
    box-shadow: 0 8px 24px rgba(0,0,0,0.08);
    transform: translateY(-4px);
}

.stat-card-active {
    border-color: var(--brand);
    box-shadow: 0 4px 16px rgba(16, 185, 129, 0.15);
}

.stat-icon {
    width: 52px;
    height: 52px;
    min-width: 52px;
    background: var(--brand-surface);
    color: var(--brand);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    transition: all 0.2s ease;
}

.stat-card:hover .stat-icon {
    transform: scale(1.05);
}

.stat-info { flex: 1; min-width: 0; overflow: hidden; }

.stat-value {
    display: block;
    font-size: 1.85rem;
    font-weight: 800;
    color: var(--text-1);
    line-height: 1.1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    letter-spacing: -0.5px;
}

.stat-label {
    font-size: 0.82rem;
    color: var(--text-3);
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-top: 4px;
}

.stat-card h3 {
    font-size: 2.5rem;
    font-weight: 800;
    letter-spacing: -1px;
    color: var(--text-1);
    margin-top: 8px;
}

/* ============================================================
   BUTTONS
   ============================================================ */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 0.6rem 1.2rem;
    border-radius: var(--r-md);
    font-weight: 600;
    font-size: 0.8rem;
    cursor: pointer;
    transition: var(--transition);
    border: 1px solid transparent;
    text-decoration: none;
    white-space: nowrap;
    letter-spacing: 0.3px;
    line-height: 1;
}

.btn-primary {
    background: var(--brand);
    color: #fff;
    border-color: var(--brand);
}

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

.btn-secondary {
    background: var(--surface-2);
    color: var(--text-2);
    border-color: var(--border);
}

.btn-secondary:hover { background: var(--border); }

.btn-danger {
    background: var(--danger-surface);
    color: var(--danger);
    border-color: var(--danger-border);
}

.btn-danger:hover { background: var(--danger); color: #fff; }

.btn-outline-danger {
    background: var(--danger-surface);
    color: var(--danger);
    border: 1px solid var(--danger-border);
}

.btn-sm { padding: 0.4rem 0.8rem; font-size: 0.75rem; }
.btn-lg { padding: 0.8rem 1.8rem; font-size: 0.9rem; }
.btn-icon {
    width: 34px; height: 34px;
    min-width: 34px;
    padding: 0;
    border-radius: 50%;
}

@media (max-width: 768px) {
    .btn-block { width: 100%; }
}

/* ============================================================
   FORMS
   ============================================================ */

input, textarea, select {
    background: var(--surface) !important;
    border: 1px solid var(--border) !important;
    color: var(--text-1) !important;
    padding: 0.7rem 1rem !important;
    border-radius: var(--r-md) !important;
    width: 100% !important;
    font-size: 0.9rem;
    font-weight: 500;
    transition: var(--transition);
    display: block;
    min-width: 0;
    max-width: 100% !important;
    line-height: 1.5;
    font-family: inherit !important;
}

input:focus, textarea:focus, select:focus {
    border-color: var(--brand) !important;
    outline: none;
    box-shadow: 0 0 0 3px rgba(16,185,129,0.12) !important;
}

label {
    display: block;
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--text-3);
    text-transform: uppercase;
    letter-spacing: 0.8px;
    margin-bottom: 6px;
}

.form-group { margin-bottom: 1.2rem; }

/* ============================================================
   TABLE SYSTEM — Mobile-first, No Overflow
   ============================================================ */

.table-container {
    width: 100%;
    max-width: 100%;
    overflow-x: hidden !important; /* No horizontal scroll on desktop */
    border-radius: 12px;
    border: 1px solid var(--border);
    background: var(--surface);
    box-shadow: 0 1px 6px rgba(0,0,0,0.04);
    box-sizing: border-box;
}

.chart-container {
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    overflow: hidden !important;
    position: relative;
}

canvas {
    width: 100% !important;
    max-width: 100% !important;
    height: auto !important;
    display: block !important;
    box-sizing: border-box !important;
}

table {
    width: 100%;
    border-collapse: collapse;
    table-layout: fixed !important; /* Fix table width */
}

th {
    background: var(--surface-2);
    padding: 1rem 1.25rem;
    font-size: 0.75rem;
    font-weight: 800;
    color: var(--text-3);
    text-transform: uppercase;
    letter-spacing: 1px;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
    text-align: left;
}

td {
    padding: 1rem 1.25rem;
    font-size: 0.9rem;
    color: var(--text-2);
    border-bottom: 1px solid #f1f5f9;
    vertical-align: middle;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 240px;
    box-sizing: border-box;
}

tr:last-child td { border-bottom: none; }
tbody tr { transition: all 0.2s ease; }
tbody tr:hover { background: #f8fafc; }

.col-id { font-weight: 700; color: var(--brand); width: 140px; }
.col-preview { width: 70px; text-align: center !important; overflow: visible; }
.col-route { color: var(--text-3); font-size: 0.8rem; max-width: 250px; }
.col-architect { width: 180px; font-weight: 600; }
.col-pulse { width: 110px; text-align: center !important; white-space: nowrap; }
.col-actions { width: 300px; text-align: right !important; overflow: visible; }

/* Mobile table → card-stacked view */
@media (max-width: 768px) {
    .table-container { border: none; border-radius: 0; background: transparent; box-shadow: none; }

    table { min-width: 0; }

    table, thead, tbody, th, td, tr { display: block !important; width: 100% !important; max-width: 100% !important; }

    thead tr { display: none !important; }

    tbody tr {
        background: var(--surface) !important;
        border: 1px solid var(--border) !important;
        border-radius: var(--r-lg) !important;
        padding: 1rem !important;
        margin-bottom: 1rem !important;
        box-shadow: var(--shadow-sm);
        white-space: normal !important;
    }

    tbody td {
        border: none !important;
        border-bottom: 1px solid var(--border) !important;
        display: flex !important;
        justify-content: space-between !important;
        align-items: center !important;
        padding: 0.75rem 0 !important;
        max-width: 100% !important;
        white-space: normal !important;
        word-break: break-word;
        text-overflow: clip !important;
        gap: 10px;
    }

    tbody td:last-child {
        border-bottom: none !important;
        flex-wrap: wrap;
        justify-content: flex-start !important;
        padding-top: 0.75rem !important;
        gap: 8px;
    }

    tbody td::before {
        content: attr(data-label);
        font-size: 0.68rem;
        font-weight: 700;
        text-transform: uppercase;
        letter-spacing: 0.8px;
        color: var(--brand);
        min-width: 70px;
        flex-shrink: 0;
    }

    .col-actions { width: 100% !important; }

    .btn { flex: 1; font-size: 0.75rem !important; padding: 0.55rem 0.8rem !important; }
    .btn-icon { flex: none; width: 36px; height: 36px; }
}

/* ============================================================
   REGISTRY CARD
   ============================================================ */

.registry-card {
    background: transparent !important;
    border: none !important;
    box-shadow: none !important;
    padding: 0 !important;
    margin: 0 !important;
    overflow: visible;
}

/* ============================================================
   PAGE HEADER
   ============================================================ */

.page-header { margin-bottom: 2rem; }
.page-header .eyebrow {
    font-size: 0.68rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 2px;
    color: var(--brand);
    margin-bottom: 0.4rem;
}

.page-header h1 {
    font-size: clamp(1.6rem, 4vw, 2.4rem);
    font-weight: 800;
    letter-spacing: -0.5px;
    color: var(--text-1);
    line-height: 1.15;
    margin-bottom: 0.4rem;
}

.page-header p {
    font-size: 0.9rem;
    color: var(--text-3);
    font-weight: 400;
}

/* ============================================================
   BADGES & PILLS
   ============================================================ */

.badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 0.25rem 0.7rem;
    border-radius: var(--r-pill);
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.5px;
    text-transform: uppercase;
}

.badge-success { background: var(--brand-xlight); color: var(--brand-dark); }
.badge-danger { background: var(--danger-surface); color: var(--danger); }
.badge-warn { background: #fffbeb; color: #92400e; }

/* Status badge */
.status-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 4px 10px;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.3px;
}

.badge-primary {
    background: var(--brand-surface);
    color: var(--brand-dark);
    border: 1px solid rgba(16, 185, 129, 0.2);
}

/* ============================================================
   ALERTS
   ============================================================ */

.alert-welcome {
    background: var(--brand-surface);
    border: 1px solid var(--brand-xlight);
    color: var(--brand-dark);
    padding: 0.875rem 1.2rem;
    border-radius: var(--r-md);
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    font-size: 0.875rem;
    font-weight: 500;
    gap: 10px;
    flex-wrap: wrap;
}

.alert-welcome .close-btn { cursor: pointer; opacity: 0.6; transition: var(--transition); font-size: 0.9rem; }
.alert-welcome .close-btn:hover { opacity: 1; }

/* ============================================================
   MODAL
   ============================================================ */

.modal {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    backdrop-filter: blur(6px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    padding: 1rem;
    overflow-y: auto;
}

.modal-content {
    background: var(--surface);
    width: 100%;
    max-width: 680px;
    border-radius: var(--r-xl);
    box-shadow: var(--shadow-lg);
    padding: 2rem;
    position: relative;
    animation: modalIn 0.25s ease;
    max-height: 90vh;
    overflow-y: auto;
}

@keyframes modalIn {
    from { opacity: 0; transform: scale(0.96) translateY(10px); }
    to { opacity: 1; transform: scale(1) translateY(0); }
}

@media (max-width: 768px) {
    .modal-content {
        padding: 1.25rem;
        border-radius: var(--r-lg);
        max-height: 95vh;
    }
}

/* ============================================================
   NODE LINK
   ============================================================ */

.node-link {
    color: var(--brand);
    font-weight: 700;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 0.9rem;
    transition: var(--transition);
}

.node-link:hover { color: var(--brand-dark); }

/* ============================================================
   DASHBOARD — Shorten Terminal
   ============================================================ */

.master-terminal {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-xl);
    padding: 2.5rem;
    position: relative;
    overflow: hidden;
    margin-bottom: 2rem;
    box-shadow: var(--shadow-sm);
}

.master-terminal::after {
    content: '';
    position: absolute;
    top: 0; right: 0;
    width: 200px; height: 200px;
    background: radial-gradient(circle at top right, rgba(16,185,129,0.06), transparent 70%);
    pointer-events: none;
}

.modern-terminal-field {
    display: flex;
    background: var(--surface-2);
    border: 1.5px solid var(--border);
    border-radius: var(--r-pill);
    padding: 6px;
    gap: 8px;
    transition: var(--transition);
    width: 100%;
    min-width: 0;
}

.modern-terminal-field:focus-within {
    border-color: var(--brand);
    box-shadow: 0 0 0 3px rgba(16,185,129,0.12);
}

.modern-terminal-field input {
    border: none !important;
    background: transparent !important;
    padding: 0.6rem 1rem !important;
    font-weight: 500 !important;
    flex: 1;
    border-radius: var(--r-pill) !important;
    min-width: 0 !important;
}

.modern-terminal-field input:focus { box-shadow: none !important; }

.adv-panel {
    display: none;
    margin-top: 1.5rem;
    padding: 1.5rem;
    border-radius: var(--r-lg);
    background: var(--surface-2);
    border: 1px dashed var(--border);
    animation: fadeSlide 0.3s ease;
}

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

.asset-preview {
    width: 100%;
    height: 140px;
    border-radius: var(--r-lg);
    background: var(--surface-2);
    border: 1.5px dashed var(--border);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.asset-preview img { width: 100%; height: 100%; object-fit: contain; }

@media (max-width: 768px) {
    .master-terminal { padding: 1.5rem; }
    .modern-terminal-field { flex-direction: column; border-radius: var(--r-xl); }
    .modern-terminal-field input { padding: 0.8rem 1rem !important; }
}

/* ============================================================
   UTILITY
   ============================================================ */

.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-1 { gap: 0.5rem; }
.gap-2 { gap: 1rem; }
.gap-3 { gap: 1.5rem; }
.flex-wrap { flex-wrap: wrap; }
.w-full { width: 100%; }
.min-w-0 { min-width: 0; }
.text-muted { color: var(--text-3); }
.text-brand { color: var(--brand); }
.fw-700 { font-weight: 700; }
.fw-800 { font-weight: 800; }
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.mb-3 { margin-bottom: 1.5rem; }
.mt-auto { margin-top: auto; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ============================================================
   TARGETED NO OVERFLOW FIX
   ============================================================ */

/* Base Fixes */
*, *::before, *::after {
    box-sizing: border-box !important;
}

html, body {
    overflow-x: hidden !important;
    width: 100% !important;
}

/* Main Content & Cards */
.main-content,
.card, .stat-card, .prog-card {
    width: 100% !important;
    max-width: 100% !important;
}

/* Chart & Table Containers */
.chart-container, .table-container {
    width: 100% !important;
    max-width: 100% !important;
    overflow: hidden !important;
}

/* Canvas & Images */
canvas, img, svg, video, audio {
    max-width: 100% !important;
    height: auto !important;
}

/* Ensure all images are responsive */
img {
  max-width: 100%;
  height: auto;
  display: block;
}

/* Make all charts and canvas elements responsive */
canvas,
.chart-container canvas,
[class*="chart"] canvas {
  max-width: 100% !important;
  width: 100% !important;
  height: auto !important;
}

/* Chart container wrapper for responsiveness */
.chart-container {
  width: 100%;
  max-width: 100%;
  overflow: hidden;
  position: relative;
  box-sizing: border-box;
  padding: 0.5rem 0;
}

/* Progress items */
.progress-item, .prog-item {
    margin-bottom: 1.5rem;
    width: 100% !important;
    box-sizing: border-box;
}

.progress-label, .prog-label {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--text-2);
    text-transform: none;
    letter-spacing: 0.3px;
    margin-bottom: 0.75rem;
    gap: 10px;
    width: 100% !important;
    box-sizing: border-box;
}

.progress-bar, .prog-bar-bg {
    height: 10px;
    background: var(--surface-2);
    border-radius: 999px;
    overflow: hidden;
    width: 100% !important;
    box-shadow: inset 0 1px 3px rgba(0,0,0,0.05);
}

.progress-fill, .prog-bar-fill {
    height: 100%;
    background: var(--primary-gradient);
    border-radius: 999px;
    transition: width 0.5s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 2px 8px rgba(16, 185, 129, 0.2);
}

/* All grid containers */
.grid-2, .grid-3, .grid-4,
[class*="grid-"] {
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
}

/* Fix any header/section elements */
.analytics-header,
.header,
.page-header {
  width: 100% !important;
  box-sizing: border-box !important;
  overflow: hidden;
}

/* Table fixes */
.table-container {
  width: 100%;
  box-sizing: border-box;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

table {
  display: block;
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

/* Text overflow fixes */
h1, h2, h3, h4, h5, h6, p, span, div {
  word-wrap: break-word;
  overflow-wrap: break-word;
}

/* Ensure all cards are responsive */
.card, .stat-card, .prog-card {
  box-sizing: border-box;
  width: 100%;
  overflow: hidden;
}

/* Main content overflow fix */
.main-content {
  overflow-x: hidden;
}

/* Responsive grid adjustments for mobile */
@media (max-width: 640px) {
  .grid-2, .grid-3, .grid-4 {
    grid-template-columns: 1fr !important;
  }
  
  .grid-2 { gap: 1rem; }
  .grid-3 { gap: 1rem; }
  .grid-4 { gap: 1rem; }
  
  .stat-card {
    padding: 1rem;
  }
}

/* Small screens (phones) */
@media (max-width: 480px) {
  .main-content {
    padding: calc(var(--header-h) + 1rem) 0.8rem 1.5rem !important;
  }
  
  .card, .stat-card {
    padding: 1rem;
  }
  
  .btn {
    padding: 0.5rem 0.9rem;
    font-size: 0.75rem;
  }
}

/* Large screens (desktop) */
@media (min-width: 1440px) {
  .main-content {
    padding: 3rem;
  }
}

/* PROGRESS BAR CLASSES */
.progress-item, .prog-item {
    margin-bottom: 1.25rem;
    width: 100% !important;
}

.progress-label, .prog-label {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--text-main);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 0.5rem;
    gap: 10px;
    width: 100% !important;
}

.progress-bar, .prog-bar-bg {
    height: 8px;
    background: #f1f5f9;
    border-radius: 999px;
    overflow: hidden;
    width: 100% !important;
}

.progress-fill, .prog-bar-fill {
    height: 100%;
    background: var(--primary-gradient);
    border-radius: 999px;
    transition: width 0.3s ease;
}

/* ============================================================
   ANALYTICS — Link Intel Page Styles
   ============================================================ */
.analytics-header {
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    margin-bottom: 2rem;
}

.nav-tabs {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
    border-bottom: 1px solid var(--border);
    padding-bottom: 0.5rem;
    margin-bottom: 1.5rem;
}

.tab-btn {
    padding: 0.75rem 1.25rem;
    border: none;
    background: transparent;
    color: var(--text-3);
    font-weight: 600;
    font-size: 0.85rem;
    cursor: pointer;
    border-radius: var(--r-md);
    transition: var(--transition);
    display: inline-flex;
    align-items: center;
    gap: 6px;
    text-decoration: none;
}

.tab-btn:hover {
    background: var(--surface-2);
    color: var(--text-2);
}

.tab-btn.active {
    background: var(--brand-surface);
    color: var(--brand);
    font-weight: 700;
}

.tab-content {
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
}

.prog-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    padding: 1.5rem;
    box-shadow: var(--shadow-sm);
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    overflow: hidden;
}

/* ============================================================
   GLOBAL OVERFLOW PREVENTION — FIXED, NO DISPLAY OVERRIDE
   ============================================================ */

/* FORCE NO HORIZONTAL OVERFLOW BUT PRESERVE DISPLAY PROPERTIES */
html, body {
    max-width: 100vw !important;
    width: 100% !important;
    box-sizing: border-box !important;
    overflow-x: hidden !important;
}

.sidebar {
    max-width: var(--sidebar-w) !important;
    box-sizing: border-box !important;
    overflow-x: hidden !important;
}

.mobile-header {
    max-width: 100% !important;
    box-sizing: border-box !important;
    overflow-x: hidden !important;
}

.main-content {
    max-width: 100vw !important;
    width: auto !important;
    box-sizing: border-box !important;
    overflow-x: hidden !important;
}

.main-content *,
.card, .stat-card, .prog-card,
.table-container, .chart-container,
[class*="grid"], [class*="grid-"],
.stat-grid,
.master-terminal,
.adv-panel,
.nav-tabs,
.tab-content,
.analytics-header,
div, section, article, aside, header, footer, nav {
    max-width: 100% !important;
    box-sizing: border-box !important;
    overflow-x: hidden !important;
}

/* PREVENT ANYTHING FROM BREAKING OUT OF MAIN-CONTENT */
.main-content > * {
    max-width: 100% !important;
    box-sizing: border-box !important;
    overflow-x: hidden !important;
    min-width: 0 !important;
}

/* All flex items and grid items get min-width:0 to prevent overflow */
.flex-item, .grid-item,
.flex > *, .grid > *,
[class*="stat-grid"] > *,
[class*="grid-"] > *,
.prog-card, .card, .stat-card {
    min-width: 0 !important;
    max-width: 100% !important;
    box-sizing: border-box !important;
}

/* Text elements can break words */
p, span, div, h1, h2, h3, h4, h5, h6, a, li, input, select, textarea {
    word-wrap: break-word !important;
    overflow-wrap: break-word !important;
    hyphens: auto !important;
    max-width: 100% !important;
}

/* Prevent tables from overflowing */
table {
    width: 100% !important;
    max-width: 100% !important;
    table-layout: auto !important;
}

/* All form elements stay contained */
input, select, textarea, button {
    max-width: 100% !important;
    box-sizing: border-box !important;
}

/* Prevent images/charts from overflowing */
img, canvas, svg, video, audio {
    max-width: 100% !important;
    height: auto !important;
    display: block !important;
}