:root {
    --gold: #D4AF37;
    --gold-dark: #B8941F;
    --gold-light: #E5C158;
    --bg-primary: #0a0a0a;
    --bg-secondary: #111111;
    --bg-card: #161616;
    --bg-hover: #1a1a1a;
    --text-primary: #ffffff;
    --text-secondary: rgba(255,255,255,0.7);
    --text-muted: rgba(255,255,255,0.5);
    --border: rgba(212,175,55,0.15);
    --border-hover: rgba(212,175,55,0.3);
    --danger: #e50914;
    --success: #00d27a;
    --warning: #ffc107;
    --info: #4a9eff;
    --sidebar-width: 210px;
    --sidebar-collapsed: 70px;
}

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

body {
    font-family: 'Outfit', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    font-size: 14px;
    min-height: 100vh;
}

/* Global scrollbar */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: var(--bg-secondary); }
::-webkit-scrollbar-thumb { background: rgba(212,175,55,0.15); border-radius: 10px; }
::-webkit-scrollbar-thumb:hover { background: rgba(212,175,55,0.3); }

/* ===== LOGIN PAGE ===== */
.login-wrapper {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: radial-gradient(ellipse at center, #1a1000 0%, #0a0a0a 70%);
    padding: 20px;
}

.login-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 40px;
    width: 100%;
    max-width: 420px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.5), 0 0 40px rgba(212,175,55,0.05);
}

.login-logo {
    text-align: center;
    margin-bottom: 30px;
}

.login-logo svg { margin-bottom: 12px; }

.login-logo h1 {
    font-size: 1.5rem;
    font-weight: 800;
    color: var(--gold);
    letter-spacing: 2px;
}

.login-logo p {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 4px;
}

.form-group {
    margin-bottom: 20px;
}

.form-label {
    display: block;
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-bottom: 6px;
    font-weight: 500;
}

.form-control, .form-select, .form-textarea {
    width: 100%;
    padding: 10px 14px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text-primary);
    font-size: 0.9rem;
    transition: all 0.2s;
}

.form-control:focus, .form-select:focus, .form-textarea:focus {
    outline: none;
    border-color: var(--gold);
    box-shadow: 0 0 0 3px rgba(212,175,55,0.12);
    background: #141414;
}

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

textarea.form-control { min-height: 100px; resize: vertical; }

/* ---- Settings page grid layout ---- */
.settings-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 18px 24px;
}
.setting-item {
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.setting-label {
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
}
.setting-key {
    font-size: 0.68rem;
    color: var(--text-muted);
    background: rgba(255,255,255,0.04);
    padding: 1px 6px;
    border-radius: 4px;
    font-weight: 400;
}
.setting-toggle {
    justify-content: center;
}
.setting-toggle-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 10px 14px;
}
.setting-toggle-row .setting-label {
    margin: 0;
    font-size: 0.85rem;
}
.setting-color-picker {
    width: 44px;
    height: 38px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: transparent;
    cursor: pointer;
    flex-shrink: 0;
}
.setting-color-text {
    max-width: 180px;
}
@media (max-width: 768px) {
    .settings-grid { grid-template-columns: 1fr; }
}

.btn {
    padding: 10px 20px;
    border: none;
    border-radius: 8px;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    text-decoration: none;
}

.btn-gold {
    background: linear-gradient(135deg, var(--gold-dark), var(--gold));
    color: #000;
}

.btn-gold:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 20px rgba(212,175,55,0.3);
    background: linear-gradient(135deg, var(--gold), var(--gold-light));
}

.btn-outline {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-primary);
}

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

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

.btn-sm { padding: 6px 12px; font-size: 0.78rem; }
.btn-block { width: 100%; justify-content: center; }

.alert {
    padding: 12px 16px;
    border-radius: 8px;
    margin-bottom: 20px;
    font-size: 0.85rem;
}

.alert-danger {
    background: rgba(229,9,20,0.1);
    border: 1px solid rgba(229,9,20,0.3);
    color: #ff6b6b;
}

.alert-success {
    background: rgba(0,210,122,0.1);
    border: 1px solid rgba(0,210,122,0.3);
    color: var(--success);
}

/* ===== ADMIN LAYOUT ===== */
.admin-layout {
    display: flex;
    min-height: 100vh;
}

/* Sidebar */
.sidebar {
    width: var(--sidebar-width);
    background: linear-gradient(180deg, #0d0d0d 0%, #111 100%);
    border-right: 1px solid var(--border);
    position: fixed;
    top: 0; left: 0; bottom: 0;
    overflow-y: auto;
    overflow-x: hidden;
    z-index: 1000;
    transition: transform 0.3s;
    display: flex;
    flex-direction: column;
}

/* Custom scrollbar */
.sidebar::-webkit-scrollbar { width: 5px; }
.sidebar::-webkit-scrollbar-track { background: transparent; }
.sidebar::-webkit-scrollbar-thumb { background: rgba(212,175,55,0.15); border-radius: 10px; }
.sidebar::-webkit-scrollbar-thumb:hover { background: rgba(212,175,55,0.3); }

.sidebar-header {
    padding: 18px 20px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
}

.sidebar-header h2 {
    font-size: 1.1rem;
    font-weight: 800;
    color: var(--gold);
    letter-spacing: 1px;
}

.sidebar-header span {
    font-size: 0.65rem;
    color: var(--text-muted);
    display: block;
}

.sidebar-nav {
    padding: 12px 0;
    flex: 1;
    overflow-y: auto;
}

.sidebar-nav::-webkit-scrollbar { width: 4px; }
.sidebar-nav::-webkit-scrollbar-track { background: transparent; }
.sidebar-nav::-webkit-scrollbar-thumb { background: rgba(212,175,55,0.1); border-radius: 10px; }

.sidebar-nav a {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 9px 20px;
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.83rem;
    transition: all 0.2s;
    border-left: 3px solid transparent;
    position: relative;
}

.sidebar-nav a:hover {
    background: rgba(212,175,55,0.04);
    color: var(--gold);
    padding-left: 24px;
}

.sidebar-nav a.active {
    background: rgba(212,175,55,0.08);
    color: var(--gold);
    border-left-color: var(--gold);
    font-weight: 600;
}

.sidebar-nav a i { width: 20px; text-align: center; font-size: 0.95rem; opacity: 0.8; }
.sidebar-nav a.active i { opacity: 1; }

.sidebar-section {
    padding: 14px 20px 4px;
    font-size: 0.62rem;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    color: var(--text-muted);
    font-weight: 700;
}

/* Sidebar footer */
.sidebar-footer {
    padding: 14px 20px;
    border-top: 1px solid var(--border);
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.sidebar-site-link, .sidebar-logout {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    border-radius: 8px;
    font-size: 0.78rem;
    text-decoration: none;
    transition: all 0.2s;
}

.sidebar-site-link {
    color: var(--text-secondary);
    background: rgba(255,255,255,0.03);
}
.sidebar-site-link:hover { color: var(--gold); background: rgba(212,175,55,0.06); }

.sidebar-logout {
    color: #ff6b6b;
    background: rgba(229,9,20,0.05);
}
.sidebar-logout:hover { background: rgba(229,9,20,0.12); }

/* Main content */
.main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    padding: 0;
}

/* Topbar */
.topbar {
    background: rgba(13,13,13,0.95);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--border);
    padding: 14px 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 999;
}

.topbar-title {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text-primary);
}

.topbar-right {
    display: flex;
    align-items: center;
    gap: 16px;
}

.topbar-user {
    display: flex;
    align-items: center;
    gap: 10px;
}

.topbar-user-info {
    text-align: right;
}

.topbar-user-name {
    font-size: 0.85rem;
    font-weight: 600;
}

.topbar-user-role {
    font-size: 0.7rem;
    color: var(--text-muted);
}

.user-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--gold-dark), var(--gold));
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    color: #000;
    font-size: 0.85rem;
    box-shadow: 0 0 12px rgba(212,175,55,0.15);
}

/* Content area */
.content-area {
    padding: 24px;
    background: var(--bg-primary);
    min-height: calc(100vh - 60px);
}

/* Cards */
.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 20px;
    transition: all 0.25s;
    position: relative;
    overflow: hidden;
}

.stat-card:hover {
    border-color: var(--border-hover);
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(0,0,0,0.3);
}

.stat-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.3rem;
    margin-bottom: 14px;
}

.stat-value {
    font-size: 1.8rem;
    font-weight: 800;
    color: var(--text-primary);
}

.stat-label {
    font-size: 0.78rem;
    color: var(--text-muted);
    margin-top: 4px;
}

/* Table */
.data-table {
    width: 100%;
    border-collapse: collapse;
}

.data-table th {
    text-align: left;
    padding: 12px 16px;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border);
    font-weight: 700;
}

.data-table td {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    font-size: 0.85rem;
}

.data-table tr:hover td {
    background: rgba(212,175,55,0.03);
}

.table-wrap {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 14px;
    overflow: hidden;
}

.table-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: rgba(212,175,55,0.02);
}

.table-header h3 {
    font-size: 1rem;
    font-weight: 700;
}

/* Badges */
.badge {
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 0.7rem;
    font-weight: 600;
}

.badge-success { background: rgba(0,210,122,0.15); color: var(--success); }
.badge-danger { background: rgba(229,9,20,0.15); color: #ff6b6b; }
.badge-warning { background: rgba(255,193,7,0.15); color: var(--warning); }
.badge-info { background: rgba(74,158,255,0.15); color: var(--info); }
.badge-gold { background: rgba(212,175,55,0.15); color: var(--gold); }

/* Forms */
.form-row { display: flex; gap: 16px; flex-wrap: wrap; }
.form-col { flex: 1; min-width: 200px; }

.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 24px;
    margin-bottom: 20px;
}

.card-title {
    font-size: 1rem;
    font-weight: 700;
    margin-bottom: 20px;
    padding-bottom: 14px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 8px;
}

/* Image preview */
.img-preview {
    width: 120px;
    height: 120px;
    border-radius: 8px;
    border: 1px solid var(--border);
    object-fit: cover;
    margin-top: 8px;
}

/* Toggle switch */
.toggle {
    position: relative;
    width: 44px;
    height: 24px;
}

.toggle input { opacity: 0; width: 0; height: 0; }

.toggle-slider {
    position: absolute;
    inset: 0;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 24px;
    cursor: pointer;
    transition: 0.3s;
}

.toggle-slider::before {
    content: '';
    position: absolute;
    width: 18px;
    height: 18px;
    left: 2px;
    top: 2px;
    background: var(--text-muted);
    border-radius: 50%;
    transition: 0.3s;
}

.toggle input:checked + .toggle-slider {
    background: rgba(212,175,55,0.2);
    border-color: var(--gold);
}

.toggle input:checked + .toggle-slider::before {
    transform: translateX(20px);
    background: var(--gold);
}

/* Pagination */
.pagination {
    display: flex;
    gap: 4px;
    padding: 16px 20px;
    border-top: 1px solid var(--border);
    align-items: center;
    justify-content: space-between;
}

.pagination-info {
    font-size: 0.78rem;
    color: var(--text-muted);
}

.pagination-links {
    display: flex;
    gap: 4px;
}

.pagination-links a {
    padding: 6px 12px;
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.8rem;
    transition: all 0.2s;
}

.pagination-links a:hover, .pagination-links a.active {
    border-color: var(--gold);
    color: var(--gold);
    background: rgba(212,175,55,0.05);
}

/* Responsive */
@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
        transition: transform 0.3s;
        z-index: 1100;
        box-shadow: 4px 0 20px rgba(0,0,0,0.5);
    }
    .sidebar.open { transform: translateX(0); }
    .main-content { margin-left: 0; }
    .form-row { flex-direction: column; }
    .form-col { max-width: 100% !important; }
    .stat-card { padding: 14px; }
    .stat-value { font-size: 1.4rem; }
    .content-area { padding: 16px; }
    .data-table { font-size: 0.78rem; }
    .data-table th, .data-table td { padding: 8px 10px; }
    .topbar { padding: 10px 16px; }
    .topbar-user-info { display: none; }
    .topbar-title { font-size: 1rem; }
    .card { padding: 14px; }
    .card-title { font-size: 1rem; }
    .btn-sm { padding: 5px 10px; font-size: 0.75rem; }
    .pagination-links a { padding: 5px 10px; font-size: 0.78rem; }
    .alert { padding: 10px 14px; font-size: 0.82rem; }
    .table-wrap { overflow-x: auto; }
    .data-table { min-width: 600px; }
}

@media (max-width: 480px) {
    .sidebar-header h2 { font-size: 1.1rem; }
    .sidebar-header span { font-size: 0.65rem; }
    .sidebar-nav a { padding: 10px 16px; font-size: 0.82rem; }
    .sidebar-section { font-size: 0.65rem; padding: 14px 20px 4px; }
    .stat-card { padding: 10px; }
    .stat-value { font-size: 1.1rem; }
    .stat-label { font-size: 0.7rem; }
    .content-area { padding: 12px; }
    .topbar { padding: 8px 12px; }
    .topbar-title { font-size: 0.9rem; }
    .user-avatar { width: 32px; height: 32px; font-size: 0.85rem; }
    .form-control, .form-select { font-size: 0.85rem; padding: 8px 12px; }
    .form-label { font-size: 0.8rem; }
    .toggle { width: 38px; height: 20px; }
    .toggle-slider::before { width: 14px; height: 14px; }
    .data-table { font-size: 0.7rem; min-width: 500px; }
    .data-table th, .data-table td { padding: 6px 8px; }
    .badge { font-size: 0.6rem; padding: 3px 7px; }
}

.menu-toggle {
    display: none;
    background: transparent;
    border: none;
    color: var(--gold);
    font-size: 1.3rem;
    cursor: pointer;
}

@media (max-width: 768px) {
    .menu-toggle { display: block; }
}

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

.sidebar-overlay.active {
    display: block;
}

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

/* ===== ADDITIONAL RESPONSIVE FIXES ===== */

/* Nav tabs — scrollable on mobile */
.nav-tabs {
    flex-wrap: nowrap;
    overflow-x: auto;
    scrollbar-width: none;
    -ms-overflow-style: none;
}
.nav-tabs::-webkit-scrollbar { display: none; }
.nav-tabs .nav-item { flex-shrink: 0; }
.nav-tabs .nav-link {
    white-space: nowrap;
    padding: 8px 14px;
    font-size: 0.82rem;
}

/* Modal responsive */
.modal-dialog {
    margin: 10px auto;
}
.modal-content {
    border-radius: 14px;
}
@media (max-width: 576px) {
    .modal-dialog {
        margin: 8px;
        max-width: calc(100% - 16px);
    }
    .modal-body {
        padding: 16px;
        font-size: 0.85rem;
    }
    .modal-header,
    .modal-footer {
        padding: 12px 16px;
    }
    .modal-title {
        font-size: 1rem;
    }
}

/* Action button groups in tables — wrap on small screens */
.data-table td form[style*="display:inline"] {
    margin-right: 2px;
}

@media (max-width: 768px) {
    /* Override inline max-width on form-cols for mobile */
    .form-col[style*="max-width"] {
        max-width: 100% !important;
    }
    /* Form row inline flex gap */
    .form-row[style*="gap"] {
        gap: 12px !important;
    }
    /* Toggle row — wrap */
    .card > form > div[style*="display:flex;gap:16px"] {
        flex-wrap: wrap;
        gap: 10px !important;
    }
    /* Nav tabs smaller padding */
    .nav-tabs .nav-link {
        padding: 7px 10px;
        font-size: 0.78rem;
    }
    /* Table header — stack on mobile */
    .table-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }
    /* Stat cards — 2 columns on tablet */
    .row.g-3 > .col-lg-3 {
        flex: 0 0 50%;
        max-width: 50%;
    }
}

@media (max-width: 480px) {
    /* Stat cards — 1 column on mobile */
    .row.g-3 > .col-lg-3 {
        flex: 0 0 100%;
        max-width: 100%;
    }
    .row.g-3 > .col-md-6 {
        flex: 0 0 100%;
        max-width: 100%;
    }
    /* Nav tabs — icon only on very small screens */
    .nav-tabs .nav-link i.me-1 {
        margin-right: 0 !important;
    }
    .nav-tabs .nav-link {
        padding: 6px 8px;
        font-size: 0.72rem;
    }
    /* Action buttons — tighter */
    .btn-sm {
        padding: 4px 8px;
        font-size: 0.7rem;
    }
    /* Card padding tighter */
    .card {
        padding: 12px;
    }
    .card-title {
        font-size: 0.9rem;
        padding-bottom: 10px;
        margin-bottom: 14px;
    }
    /* Form labels smaller */
    .form-label {
        font-size: 0.75rem;
    }
    .form-control, .form-select, .form-textarea {
        font-size: 0.82rem;
        padding: 8px 10px;
    }
    /* Toggle row tighter */
    .card > form > div[style*="display:flex;gap:16px"] {
        gap: 8px !important;
    }
    .card > form > div[style*="display:flex;gap:16px"] > span {
        font-size: 0.78rem !important;
    }
    /* Pagination — stack */
    .pagination {
        flex-direction: column;
        gap: 10px;
        align-items: stretch;
    }
    .pagination-info {
        text-align: center;
    }
    .pagination-links {
        justify-content: center;
        flex-wrap: wrap;
    }
    /* Alerts tighter */
    .alert {
        padding: 8px 12px;
        font-size: 0.78rem;
    }
    /* Data table even tighter */
    .data-table {
        font-size: 0.65rem;
        min-width: 400px;
    }
    .data-table th, .data-table td {
        padding: 5px 6px;
    }
    .badge {
        font-size: 0.55rem;
        padding: 2px 5px;
    }
}

/* Bootstrap btn overrides for admin */
.btn-primary {
    background: var(--info);
    color: #fff;
}
.btn-primary:hover { opacity: 0.9; }
.btn-success {
    background: var(--success);
    color: #000;
}
.btn-success:hover { opacity: 0.9; }
.btn-warning {
    background: var(--warning);
    color: #000;
}
.btn-warning:hover { opacity: 0.9; }
.btn-secondary {
    background: rgba(255,255,255,0.08);
    color: var(--text-secondary);
    border: 1px solid var(--border);
}
.btn-secondary:hover {
    background: rgba(255,255,255,0.12);
}

/* Responsive images in forms */
.img-preview {
    max-width: 100%;
}

/* File upload input */
input[type="file"] {
    font-size: 0.82rem;
}

/* Textarea auto-height */
textarea.form-control {
    min-height: 80px;
    resize: vertical;
}

/* Checkbox/radio inline groups */
.checkbox-group, .radio-group {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
}
.checkbox-group label, .radio-group label {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.85rem;
    color: var(--text-secondary);
    cursor: pointer;
}

/* Select2 / custom select responsive */
.select2-container {
    width: 100% !important;
}

/* Dropdown menus */
.dropdown-menu {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 10px;
    box-shadow: 0 8px 30px rgba(0,0,0,0.4);
    padding: 6px;
}
.dropdown-item {
    color: var(--text-secondary);
    font-size: 0.83rem;
    padding: 8px 14px;
    border-radius: 6px;
    transition: all 0.2s;
}
.dropdown-item:hover {
    background: rgba(212,175,55,0.08);
    color: var(--gold);
}
.dropdown-divider {
    border-color: var(--border);
}

/* ============================================================
   COMPREHENSIVE MOBILE RESPONSIVE FIXES (ALL ADMIN PAGES)
   ============================================================ */

/* Prevent horizontal scroll on all admin pages */
html, body {
    overflow-x: hidden;
    max-width: 100vw;
}

.admin-layout {
    max-width: 100vw;
    overflow-x: hidden;
}

/* ---- TABLET: 768px and below ---- */
@media (max-width: 768px) {
    /* Topbar — tighter, hide role text, keep avatar */
    .topbar {
        padding: 10px 14px;
        gap: 10px;
    }
    .topbar-title {
        font-size: 0.95rem;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        max-width: 50vw;
    }
    .topbar-user-info { display: none; }
    .topbar-right { gap: 8px; }

    /* Content area — comfortable padding */
    .content-area {
        padding: 16px 14px;
    }

    /* Cards — less padding */
    .card {
        padding: 16px;
        margin-bottom: 16px;
        border-radius: 12px;
    }
    .card-title {
        font-size: 0.95rem;
        flex-wrap: wrap;
        gap: 6px;
    }

    /* Stat cards — 2 columns */
    .row.g-3 > [class*="col-"] {
        flex: 0 0 50%;
        max-width: 50%;
    }

    /* Forms — stack everything */
    .form-row {
        flex-direction: column !important;
        gap: 12px !important;
    }
    .form-col {
        flex: 1 1 100% !important;
        min-width: 100% !important;
        max-width: 100% !important;
        width: 100% !important;
    }

    /* Override ALL inline flex gaps and widths in cards/forms */
    .card form > div[style*="display:flex"],
    .card > div[style*="display:flex"],
    .card-body > div[style*="display:flex"] {
        flex-wrap: wrap !important;
        gap: 10px !important;
    }
    .card form > div[style*="display:flex"] > div,
    .card > div[style*="display:flex"] > div {
        flex: 1 1 100% !important;
        min-width: 0 !important;
    }

    /* Tables — horizontal scroll wrapper */
    .table-wrap, .card:has(.data-table) {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    .data-table {
        min-width: 600px;
        font-size: 0.78rem;
    }
    .data-table th, .data-table td {
        padding: 8px 10px;
        white-space: nowrap;
    }

    /* Table header — stack */
    .table-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
        padding: 14px 16px;
    }
    .table-header > div,
    .table-header > form,
    .table-header > a,
    .table-header > button {
        width: 100%;
    }
    .table-header .btn { width: 100%; justify-content: center; }
    .table-header input, .table-header select { width: 100%; }

    /* Buttons — full width on mobile when stacked */
    .btn-block { width: 100%; }

    /* Pagination — stack */
    .pagination {
        flex-direction: column;
        gap: 10px;
        align-items: stretch;
        padding: 12px 16px;
    }
    .pagination-info { text-align: center; }
    .pagination-links {
        justify-content: center;
        flex-wrap: wrap;
    }

    /* Sidebar — off-canvas */
    .sidebar {
        transform: translateX(-100%);
        width: 260px;
        max-width: 85vw;
    }
    .sidebar.open { transform: translateX(0); }
    .main-content { margin-left: 0; }

    /* Dashboard welcome — stack */
    .dash-welcome {
        flex-direction: column !important;
        text-align: center;
        padding: 20px 18px;
        gap: 14px;
    }
    .dash-welcome-date { text-align: center; }
    .dash-welcome-date .day { font-size: 1.8rem; }

    /* Dashboard quick grid — 2 cols */
    .dash-quick-grid {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 10px;
    }

    /* Dashboard chart — shorter */
    .dash-chart-canvas-wrap { height: 200px; }
    .dash-chart-wrap, .dash-quick { padding: 16px; }

    /* Nav tabs — scrollable */
    .nav-tabs {
        flex-wrap: nowrap;
        overflow-x: auto;
        scrollbar-width: none;
    }
    .nav-tabs::-webkit-scrollbar { display: none; }
    .nav-tabs .nav-item { flex-shrink: 0; }
    .nav-tabs .nav-link {
        white-space: nowrap;
        padding: 8px 12px;
        font-size: 0.8rem;
    }

    /* Modals — full width */
    .modal-dialog {
        margin: 10px;
        max-width: calc(100% - 20px);
    }

    /* Images — responsive */
    .img-preview, img {
        max-width: 100%;
        height: auto;
    }

    /* Alert — tighter */
    .alert { padding: 10px 14px; font-size: 0.82rem; }

    /* Filter/search bars — stack */
    .card-body > div[style*="display:flex;gap"],
    form > div[style*="display:flex;gap"] {
        flex-wrap: wrap !important;
        gap: 10px !important;
    }
    form > div[style*="display:flex;gap"] > input,
    form > div[style*="display:flex;gap"] > select {
        flex: 1 1 100% !important;
        min-width: 0 !important;
    }

    /* Badges — slightly smaller */
    .badge { font-size: 0.68rem; padding: 3px 8px; }

    /* Fix any inline width:XXXpx on inputs */
    .form-control[style*="width"], .form-select[style*="width"] {
        width: 100% !important;
    }
}

/* ---- MOBILE: 480px and below ---- */
@media (max-width: 480px) {
    /* Topbar — minimal */
    .topbar { padding: 8px 12px; }
    .topbar-title {
        font-size: 0.88rem;
        max-width: 60vw;
    }
    .user-avatar { width: 32px; height: 32px; font-size: 0.8rem; }
    .topbar-right .btn-sm { padding: 5px 8px; }

    /* Content area — tight */
    .content-area { padding: 12px 10px; }

    /* Cards — tight */
    .card {
        padding: 12px;
        border-radius: 10px;
        margin-bottom: 12px;
    }
    .card-title {
        font-size: 0.88rem;
        padding-bottom: 10px;
        margin-bottom: 12px;
    }

    /* Stat cards — 1 column */
    .row.g-3 > [class*="col-"] {
        flex: 0 0 100%;
        max-width: 100%;
    }
    .stat-card { padding: 12px; }
    .stat-value { font-size: 1.3rem; }
    .stat-icon { width: 40px; height: 40px; font-size: 1.1rem; }
    .dash-stat { padding: 14px; }
    .dash-stat-value { font-size: 1.5rem; }
    .dash-stat-icon { width: 40px; height: 40px; font-size: 1.05rem; }

    /* Dashboard quick grid — 2 cols, tighter */
    .dash-quick-grid {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 8px;
    }
    .dash-quick-btn { padding: 14px 8px; font-size: 0.72rem; }
    .dash-quick-btn i { font-size: 1.2rem; }

    /* Dashboard welcome — tight */
    .dash-welcome { padding: 16px 14px; }
    .dash-welcome-text h2 { font-size: 1.2rem; }
    .dash-welcome-text p { font-size: 0.78rem; }
    .dash-welcome-date .day { font-size: 1.5rem; }

    /* Dashboard chart — shorter */
    .dash-chart-canvas-wrap { height: 180px; }
    .dash-chart-wrap { padding: 14px; }
    .dash-chart-header h3 { font-size: 0.9rem; }

    /* Forms — tight */
    .form-control, .form-select, .form-textarea {
        font-size: 0.85rem;
        padding: 9px 12px;
    }
    .form-label { font-size: 0.78rem; }
    .form-group { margin-bottom: 14px; }

    /* Buttons — touch-friendly */
    .btn {
        padding: 9px 14px;
        font-size: 0.8rem;
    }
    .btn-sm { padding: 6px 10px; font-size: 0.75rem; }

    /* Tables — tighter, allow scroll */
    .data-table {
        font-size: 0.7rem;
        min-width: 500px;
    }
    .data-table th, .data-table td {
        padding: 6px 8px;
    }

    /* Badges — tiny */
    .badge { font-size: 0.6rem; padding: 2px 6px; }

    /* Nav tabs — icon-only on tiny screens */
    .nav-tabs .nav-link {
        padding: 6px 10px;
        font-size: 0.72rem;
    }
    .nav-tabs .nav-link i.me-1 { margin-right: 0 !important; }

    /* Pagination — tight */
    .pagination-links a {
        padding: 5px 9px;
        font-size: 0.75rem;
    }

    /* Modals — tight */
    .modal-dialog { margin: 8px; max-width: calc(100% - 16px); }
    .modal-body { padding: 14px; font-size: 0.85rem; }
    .modal-header, .modal-footer { padding: 12px 14px; }
    .modal-title { font-size: 0.95rem; }

    /* Toggle switches — smaller */
    .toggle { width: 38px; height: 20px; }
    .toggle-slider::before { width: 14px; height: 14px; }

    /* Alerts — tight */
    .alert { padding: 8px 12px; font-size: 0.78rem; }

    /* Sidebar — slightly narrower */
    .sidebar { width: 240px; max-width: 80vw; }
    .sidebar-header { padding: 14px 16px; }
    .sidebar-header h2 { font-size: 1rem; }
    .sidebar-nav a { padding: 10px 16px; font-size: 0.8rem; }

    /* Image previews — smaller */
    .img-preview { width: 90px; height: 90px; }

    /* Dropdown items — touch-friendly */
    .dropdown-item { padding: 10px 14px; font-size: 0.82rem; }
}

/* ---- VERY SMALL: 360px and below ---- */
@media (max-width: 360px) {
    .topbar-title { font-size: 0.82rem; max-width: 55vw; }
    .content-area { padding: 10px 8px; }
    .card { padding: 10px; }
    .dash-quick-grid { grid-template-columns: 1fr !important; }
    .data-table { min-width: 400px; font-size: 0.65rem; }
    .data-table th, .data-table td { padding: 5px 6px; }
    .form-control, .form-select { font-size: 0.82rem; padding: 8px 10px; }
    .btn { padding: 8px 12px; font-size: 0.78rem; }
    .badge { font-size: 0.55rem; padding: 2px 5px; }
}

/* ---- Landscape phone fixes ---- */
@media (max-width: 768px) and (orientation: landscape) {
    .sidebar { width: 220px; }
    .topbar { padding: 8px 14px; }
    .content-area { padding: 14px; }
}

/* ---- Print-friendly (bonus) ---- */
@media print {
    .sidebar, .topbar, .sidebar-overlay, .menu-toggle { display: none !important; }
    .main-content { margin-left: 0 !important; }
    .content-area { padding: 0 !important; }
    body { background: #fff !important; color: #000 !important; }
    .card, .stat-card, .table-wrap { border: 1px solid #ccc !important; box-shadow: none !important; }
}

/* ---- Fix specific inline styles that break mobile ---- */
@media (max-width: 768px) {
    /* Any element with inline display:flex and fixed gap — allow wrap */
    [style*="display:flex"][style*="gap"] {
        flex-wrap: wrap;
    }
    /* Any element with inline min-width over 200px — relax */
    [style*="min-width:2"], [style*="min-width:3"], [style*="min-width:4"],
    [style*="min-width:5"], [style*="min-width:6"], [style*="min-width:7"],
    [style*="min-width:8"], [style*="min-width:9"] {
        min-width: 0 !important;
    }
    /* Any input/select with inline width over 200px — full width */
    input[style*="width:2"], input[style*="width:3"], input[style*="width:4"],
    select[style*="width:2"], select[style*="width:3"], select[style*="width:4"] {
        width: 100% !important;
    }
    /* Bootstrap row — always stack on mobile */
    .row { --bs-gutter-x: 0.75rem; }
    /* Fix any text-align:right that becomes awkward on mobile */
    .text-md-right { text-align: left !important; }
}

/* ---- Smooth scrolling for off-canvas sidebar ---- */
.sidebar { will-change: transform; }
.sidebar-overlay { transition: opacity 0.3s; }

/* ---- Better touch targets on mobile ---- */
@media (max-width: 768px) {
    .sidebar-nav a,
    .sidebar-site-link,
    .sidebar-logout,
    .btn,
    .dropdown-item,
    .pagination-links a,
    .nav-tabs .nav-link {
        min-height: 40px;
    }
}

/* ---- Prevent text overflow on long content ---- */
.data-table td,
.dash-top-title,
.dash-user-email,
.topbar-title {
    word-break: break-word;
    overflow-wrap: break-word;
}

/* ---- Responsive grid for dashboard sections ---- */
@media (max-width: 768px) {
    .row > .col-lg-8,
    .row > .col-lg-9,
    .row > .col-lg-7,
    .row > .col-lg-6 {
        flex: 0 0 100%;
        max-width: 100%;
    }
}

/* ---- Fix Bootstrap container width on mobile ---- */
@media (max-width: 768px) {
    .container, .container-fluid {
        padding-left: 0;
        padding-right: 0;
    }
}
