:root {
    /* Brand Colors - Sophisticated Indigo & Purple blend for premium feel */
    --primary-color: #4F46E5;
    --primary-hover: #4338CA;
    --secondary-color: #8B5CF6;

    /* Neutral Palette */
    --bg-color: #F8FAFC;
    --surface-color: #FFFFFF;
    --text-main: #0F172A;
    --text-muted: #64748B;
    --border-color: #E2E8F0;

    /* Semantic Colors */
    --success: #10B981;
    --warning: #F59E0B;
    --danger: #EF4444;
    --info: #3B82F6;

    /* Shadows & Transitions */
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -1px rgba(0, 0, 0, 0.03);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.05), 0 4px 6px -2px rgba(0, 0, 0, 0.025);
    --transition: all 0.3s ease;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Plus Jakarta Sans', sans-serif;
    background-color: var(--bg-color);
    color: var(--text-main);
    overflow-x: hidden;
    width: 100%;
    max-width: 100%;
}

html {
    overflow-x: hidden;
    width: 100%;
    max-width: 100%;
}

/* Typography */
h1,
h2,
h3,
h4,
h5,
h6 {
    font-family: 'Outfit', sans-serif;
    font-weight: 600;
}

/* Layout */
.app-container {
    display: flex;
    height: 100vh;
    overflow: hidden;
}

/* Sidebar */
.sidebar {
    width: 280px;
    background-color: var(--surface-color);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    z-index: 10;
    transition: var(--transition);
}

.sidebar-header {
    height: 80px;
    display: flex;
    align-items: center;
    padding: 0 24px;
    border-bottom: 1px solid var(--border-color);
    gap: 12px;
}

.logo {
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    width: 36px;
    height: 36px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
}

.sidebar-header h2 {
    font-size: 20px;
    letter-spacing: -0.5px;
    color: var(--primary-color);
}

.sidebar-nav {
    flex: 1;
    padding: 24px 16px;
    overflow-y: auto;
}

.nav-section {
    font-size: 11px;
    font-weight: 700;
    color: var(--text-muted);
    letter-spacing: 1px;
    margin-bottom: 12px;
    margin-left: 12px;
}

.mt-4 {
    margin-top: 24px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    color: var(--text-muted);
    text-decoration: none;
    border-radius: 10px;
    font-weight: 500;
    transition: var(--transition);
    margin-bottom: 4px;
}

.nav-item:hover,
.nav-item.active {
    background-color: #EEF2FF;
    color: var(--primary-color);
}

.nav-item.active i {
    color: var(--primary-color);
}

.nav-item i {
    width: 20px;
    height: 20px;
    transition: var(--transition);
}

.sidebar-footer {
    padding: 20px;
    border-top: 1px solid var(--border-color);
}

.user-profile {
    display: flex;
    align-items: center;
    gap: 12px;
}

.avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background-color: var(--border-color);
}

.user-info {
    display: flex;
    flex-direction: column;
}

.user-name {
    font-size: 14px;
    font-weight: 600;
}

.user-role {
    font-size: 12px;
    color: var(--text-muted);
}

/* Main Content */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    background-color: var(--bg-color);
}

/* Header */
.top-header {
    height: 80px;
    background-color: var(--surface-color);
    border-bottom: 1px solid var(--border-color);
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    padding: 0 40px;
    position: sticky;
    top: 0;
    z-index: 5;
}

.top-header::before {
    /* Empty spacer for grid alignment */
    content: '';
    display: block;
}

.search-bar {
    display: flex;
    align-items: center;
    background-color: var(--bg-color);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 10px 18px;
    width: 450px;
    margin: 0 auto;
    transition: var(--transition);
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.02);
}

.search-bar:focus-within {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

.search-bar i {
    color: var(--text-muted);
    width: 18px;
    height: 18px;
}

.search-bar input {
    border: none;
    background: transparent;
    padding: 6px 12px;
    outline: none;
    width: 100%;
    font-family: inherit;
    font-size: 14px;
}

.header-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 20px;
}

.icon-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    position: relative;
    padding: 8px;
    border-radius: 50%;
    transition: var(--transition);
}

.icon-btn:hover {
    background-color: var(--bg-color);
    color: var(--primary-color);
}

.notification-btn .badge {
    position: absolute;
    top: -2px;
    right: -2px;
    background-color: var(--danger);
    color: white;
    font-size: 10px;
    font-weight: bold;
    height: 18px;
    width: 18px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid var(--surface-color);
    z-index: 10;
    line-height: 1;
    padding: 0;
}

.primary-btn {
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 8px;
    font-family: inherit;
    font-weight: 600;
    font-size: 14px;
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    box-shadow: 0 4px 10px rgba(79, 70, 229, 0.2);
    transition: var(--transition);
}

.primary-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 15px rgba(79, 70, 229, 0.3);
}

.primary-btn i {
    width: 18px;
    height: 18px;
}

/* Dashboard Content */
.dashboard-content {
    padding: 40px;
    max-width: 1400px;
    margin: 0 auto;
    width: 100%;
}

.page-title-box {
    margin-bottom: 30px;
}

.page-title-box h1 {
    font-size: 28px;
    color: var(--text-main);
    margin-bottom: 8px;
}

.page-title-box p {
    color: var(--text-muted);
}

/* KPI Cards */
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 24px;
    margin-bottom: 30px;
}

.kpi-card {
    background-color: var(--surface-color);
    border-radius: 16px;
    padding: 24px;
    display: flex;
    align-items: center;
    gap: 20px;
    box-shadow: var(--shadow-sm);
    transition: var(--transition);
    position: relative;
    overflow: hidden;
}

.kpi-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-md);
}

.stats-gradient-1::before {
    background: linear-gradient(135deg, #4F46E5, #8B5CF6);
}

.stats-gradient-2::before {
    background: linear-gradient(135deg, #10B981, #059669);
}

.stats-gradient-3::before {
    background: linear-gradient(135deg, #F59E0B, #D97706);
}

.stats-gradient-4::before {
    background: linear-gradient(135deg, #EF4444, #B91C1C);
}

.kpi-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 4px;
    height: 100%;
}

.kpi-icon {
    width: 56px;
    height: 56px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.stats-gradient-1 .kpi-icon {
    background-color: #EEF2FF;
    color: #4F46E5;
}

.stats-gradient-2 .kpi-icon {
    background-color: #ECFDF5;
    color: #10B981;
}

.stats-gradient-3 .kpi-icon {
    background-color: #FFFBEB;
    color: #F59E0B;
}

.stats-gradient-4 .kpi-icon {
    background-color: #FEF2F2;
    color: #EF4444;
}

.kpi-details {
    display: flex;
    flex-direction: column;
}

.kpi-label {
    font-size: 13px;
    color: var(--text-muted);
    font-weight: 600;
    margin-bottom: 4px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.kpi-value {
    font-size: 26px;
    font-weight: 700;
    font-family: 'Outfit';
    color: var(--text-main);
}

.kpi-value small {
    font-size: 14px;
    color: var(--text-muted);
    font-weight: 500;
}

/* Charts Grid */
.charts-grid {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 24px;
    margin-bottom: 30px;
}

.chart-container {
    background-color: var(--surface-color);
    border-radius: 16px;
    padding: 24px;
    box-shadow: var(--shadow-sm);
    display: flex;
    flex-direction: column;
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
}

.card-header h3 {
    font-size: 18px;
    color: var(--text-main);
}

.minimal-select {
    border: 1px solid var(--border-color);
    background-color: var(--bg-color);
    padding: 6px 12px;
    border-radius: 6px;
    font-family: inherit;
    font-size: 13px;
    color: var(--text-muted);
    cursor: pointer;
    outline: none;
}

/* Tables Area */
.tables-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
}

.data-table-card {
    background-color: var(--surface-color);
    border-radius: 16px;
    padding: 24px;
    box-shadow: var(--shadow-sm);
}

.text-btn {
    background: none;
    border: none;
    color: var(--primary-color);
    font-weight: 600;
    font-size: 13px;
    cursor: pointer;
    transition: var(--transition);
}

.text-btn:hover {
    color: var(--primary-hover);
    text-decoration: underline;
}

.styled-table {
    width: 100%;
    border-collapse: collapse;
}

.styled-table th {
    text-align: left;
    padding: 12px 16px;
    font-size: 12px;
    text-transform: uppercase;
    color: var(--text-muted);
    letter-spacing: 0.5px;
    border-bottom: 1px solid var(--border-color);
}

.styled-table td {
    padding: 16px;
    font-size: 14px;
    color: var(--text-main);
    border-bottom: 1px solid var(--border-color);
    font-weight: 500;
}

.styled-table tr:last-child td {
    border-bottom: none;
}

/* Tag Badges */
.tag-badge {
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    display: inline-block;
    border: none;
    width: auto;
    height: auto;
}

.tag-badge.premium {
    background-color: #F3E8FF;
    color: #7E22CE;
}

.tag-badge.printed {
    background-color: #E0F2FE;
    color: #0369A1;
}

.tag-badge.plain {
    background-color: #F1F5F9;
    color: #475569;
}

span.status {
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
}

.status.pending {
    background-color: #FFFBEB;
    color: #D97706;
}

.status.confirmed {
    background-color: #EFF6FF;
    color: #2563EB;
}

.status.dispatched {
    background-color: #ECFDF5;
    color: #059669;
}

/* Animations */
.fade-in {
    animation: fadeIn 0.5s ease-in-out;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Responsiveness */
@media (max-width: 1024px) {

    .charts-grid,
    .tables-grid {
        grid-template-columns: 1fr;
    }
}

/* Modals & Forms */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(15, 23, 42, 0.6);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: var(--transition);
}

.modal-overlay.active {
    opacity: 1;
    visibility: visible;
}

.modal-content {
    background: var(--surface-color);
    border-radius: 16px;
    width: 600px;
    max-width: 90%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: var(--shadow-lg);
    transform: translateY(20px);
    transition: var(--transition);
}

.modal-overlay.active .modal-content {
    transform: translateY(0);
}

.modal-header {
    padding: 24px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h2 {
    font-size: 20px;
    color: var(--text-main);
}

.close-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    transition: var(--transition);
}

.close-btn:hover {
    color: var(--danger);
}

.modal-body {
    padding: 24px;
}

.form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.form-group.full {
    grid-column: 1 / -1;
}

.form-group label {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-muted);
}

.form-input {
    padding: 10px 14px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-family: inherit;
    font-size: 14px;
    background: var(--bg-color);
    transition: var(--transition);
}

.form-input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

.modal-footer {
    padding: 24px;
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: flex-end;
    gap: 12px;
}

.secondary-btn {
    background: var(--bg-color);
    color: var(--text-main);
    border: 1px solid var(--border-color);
    padding: 10px 20px;
    border-radius: 8px;
    font-family: inherit;
    font-weight: 600;
    font-size: 14px;
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    transition: var(--transition);
}

.secondary-btn i {
    width: 18px;
    height: 18px;
}

.secondary-btn:hover {
    background: var(--border-color);
    transform: translateY(-2px);
}

/* Specific Action buttons for tables */
.action-btn {
    background: none;
    border: none;
    padding: 6px;
    cursor: pointer;
    border-radius: 6px;
    color: var(--text-muted);
    transition: var(--transition);
}

.action-btn:hover {
    background: var(--bg-color);
}

.action-btn.edit {
    color: var(--primary-color);
}

.action-btn.delete {
    color: var(--danger);
}

.action-btn.view {
    color: var(--success);
}

/* Badges specifically for Customer Types */
.tag-badge.retail {
    background-color: #F1F5F9;
    color: #475569;
}

.tag-badge.wholesale {
    background-color: #E0F2FE;
    color: #0369A1;
}

.tag-badge.distributor {
    background-color: #FEF3C7;
    color: #B45309;
}

/* Mobile Responsive & Bottom Navigation Bar */
.mobile-logo {
    display: none;
}

.bottom-nav {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 65px;
    background: var(--surface-color);
    border-top: 1px solid var(--border-color);
    z-index: 1000;
    justify-content: space-around;
    align-items: center;
    padding: 0 5px;
    box-shadow: 0 -4px 12px rgba(0, 0, 0, 0.05);
}

.bottom-nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    text-decoration: none;
    font-size: 11px;
    width: 20%;
    transition: var(--transition);
}

.bottom-nav-item.active,
.bottom-nav-item:hover {
    color: var(--primary-color);
}

.bottom-nav-item i {
    width: 20px;
    height: 20px;
}

/* ================================================
   COMMON MOBILE HEADER BAR
   Hidden on desktop (>768px), visible only on mobile
   ================================================ */
.mobile-header-bar {
    display: none;
    /* Hidden by default on all screen sizes */
}

/* ================================================
   MOBILE SIDEBAR DRAWER
   Hidden at base level — only shown on mobile
   ================================================ */

/* Prevent scroll when drawer is open */
body.no-scroll {
    overflow: hidden;
}

/* Overlay backdrop */
.msd-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.45);
    z-index: 1100;
    opacity: 0;
    pointer-events: none;
    /* ← CRITICAL: don't block page interaction when invisible */
    transition: opacity 0.3s ease;
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
}

.msd-overlay.open {
    opacity: 1;
    pointer-events: auto;
    /* ← re-enable clicks on overlay to close drawer */
}

/* Drawer Panel */
.mobile-sidebar-drawer {
    display: none;
    position: fixed;
    top: 0;
    left: -280px;
    width: 272px;
    height: 100dvh;
    background: var(--surface-color);
    z-index: 1200;
    flex-direction: column;
    overflow-y: auto;
    transition: left 0.32s cubic-bezier(0.4, 0, 0.2, 1),
        box-shadow 0.32s ease;
    box-shadow: none;
    border-top-right-radius: 20px;
    border-bottom-right-radius: 20px;
}

.mobile-sidebar-drawer.open {
    left: 0;
    box-shadow: 6px 0 32px rgba(79, 70, 229, 0.15), 2px 0 8px rgba(0, 0, 0, 0.1);
}

/* Drawer Header */
.msd-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 18px 16px 14px;
    background: linear-gradient(135deg, #4F46E5 0%, #8B5CF6 100%);
    flex-shrink: 0;
}

.msd-close {
    background: rgba(255, 255, 255, 0.15);
    border: none;
    border-radius: 8px;
    width: 34px;
    height: 34px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: white;
    transition: background 0.2s;
}

.msd-close:hover {
    background: rgba(255, 255, 255, 0.28);
}

.msd-header .logo {
    background: rgba(255, 255, 255, 0.2);
    color: white;
}

.msd-header .logo i {
    color: white;
}

.msd-header [style*="color:var(--primary-color)"] {
    color: white !important;
}

/* User Profile Strip */
.msd-profile {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 16px;
    background: #F8FAFC;
    border-bottom: 1px solid var(--border-color);
    flex-shrink: 0;
}

.msd-avatar {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    border: 2px solid var(--primary-color);
    background: #EEF2FF;
    flex-shrink: 0;
}

.msd-user-name {
    font-weight: 700;
    font-size: 14px;
    color: var(--text-main);
}

.msd-user-role {
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 1px;
}

/* Navigation Area */
.msd-nav {
    flex: 1;
    padding: 12px 10px;
    overflow-y: auto;
}

.msd-section-label {
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 1px;
    color: var(--text-muted);
    padding: 6px 10px 4px;
    text-transform: uppercase;
}

/* Nav Link */
.msd-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 11px 12px;
    border-radius: 10px;
    text-decoration: none;
    color: var(--text-main);
    font-size: 14px;
    font-weight: 500;
    transition: background 0.18s, color 0.18s;
    margin-bottom: 2px;
}

.msd-link i {
    width: 18px;
    height: 18px;
    color: var(--text-muted);
    flex-shrink: 0;
    transition: color 0.18s;
}

.msd-link:hover {
    background: #EEF2FF;
    color: var(--primary-color);
}

.msd-link:hover i {
    color: var(--primary-color);
}

/* Active Page Link */
.msd-link.active {
    background: linear-gradient(135deg, #EEF2FF, #F5F3FF);
    color: var(--primary-color);
    font-weight: 700;
    box-shadow: 0 2px 6px rgba(79, 70, 229, 0.1);
}

.msd-link.active i {
    color: var(--primary-color);
}

/* Drawer Footer */
.msd-footer {
    padding: 12px 16px;
    display: flex;
    justify-content: space-between;
    font-size: 11px;
    color: var(--text-muted);
    border-top: 1px solid var(--border-color);
    background: #F8FAFC;
    flex-shrink: 0;
}

/* ── Hamburger Button ── */
.mh-hamburger {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 5px;
    width: 36px;
    height: 36px;
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 4px;
    border-radius: 8px;
    flex-shrink: 0;
    transition: background 0.2s;
}

.mh-hamburger:hover {
    background: rgba(79, 70, 229, 0.08);
}

.mh-hamburger span {
    display: block;
    width: 20px;
    height: 2px;
    background: var(--text-main);
    border-radius: 2px;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1),
        opacity 0.3s ease,
        width 0.3s ease;
    transform-origin: center;
}

/* Hamburger → X animation */
.mh-hamburger.is-open span:nth-child(1) {
    transform: translateY(7px) rotate(45deg);
}

.mh-hamburger.is-open span:nth-child(2) {
    opacity: 0;
    width: 0;
}

.mh-hamburger.is-open span:nth-child(3) {
    transform: translateY(-7px) rotate(-45deg);
}

/* Only show drawer elements on mobile */
@media (min-width: 769px) {

    .mobile-sidebar-drawer,
    .msd-overlay,
    .mh-hamburger {
        display: none !important;
    }
}

@media (max-width: 768px) {

    /* Show the custom mobile header */
    .mobile-header-bar {
        display: flex;
        flex-direction: row;
        flex-wrap: wrap;
        align-items: center;
        position: sticky;
        top: 0;
        left: 0;
        right: 0;
        z-index: 200;
        background: var(--surface-color);
        border-bottom: 1px solid var(--border-color);
        padding: 10px 14px 8px 14px;
        gap: 0;
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
    }

    /* Logo section (left) */
    .mh-logo {
        display: flex;
        align-items: center;
        gap: 8px;
        flex: 1;
    }

    /* Enable overlay and drawer on mobile */
    .msd-overlay {
        display: block;
        /* activates from display:none; opacity controls visibility */
    }

    .mobile-sidebar-drawer {
        display: flex;
        /* activates from display:none; left position controls slide */
    }



    .mh-brand {
        font-family: 'Outfit', sans-serif;
        font-size: 18px;
        font-weight: 700;
        color: var(--primary-color);
        letter-spacing: -0.3px;
    }

    /* Right action buttons */
    .mh-actions {
        display: flex;
        align-items: center;
        gap: 6px;
    }

    /* New Order button */
    .mh-new-order-btn {
        display: flex;
        align-items: center;
        gap: 5px;
        background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
        color: white;
        text-decoration: none;
        font-family: 'Plus Jakarta Sans', sans-serif;
        font-size: 12px;
        font-weight: 700;
        padding: 7px 12px;
        border-radius: 8px;
        white-space: nowrap;
        box-shadow: 0 3px 8px rgba(79, 70, 229, 0.25);
        transition: all 0.2s ease;
    }

    .mh-new-order-btn:hover,
    .mh-new-order-btn:active {
        transform: translateY(-1px);
        box-shadow: 0 4px 12px rgba(79, 70, 229, 0.35);
    }

    /* Search row (full width, second row) */
    .mh-search-row {
        width: 100%;
        margin-top: 8px;
    }

    .mh-search-bar {
        width: 100% !important;
        max-width: none !important;
        margin: 0 !important;
    }

    /* Bell button in mobile header */
    .mh-bell {
        color: var(--text-muted);
    }

    /* HIDE the original .top-header on mobile */
    .top-header {
        display: none !important;
    }

    /* Compensate page content for sticky mobile header height (~108px) */
    .main-content {
        padding-top: 0;
    }
}


@media (max-width: 768px) {

    /* Full-width containers — prevent card overflow on mobile */
    .app-container,
    .main-content,
    .dashboard-content {
        width: 100%;
        max-width: 100%;
        box-sizing: border-box;
    }

    /* All data cards fill screen width */
    .data-table-card {
        width: 100%;
        box-sizing: border-box;
        margin: 0 0 16px 0;
        padding: 12px;
        border-radius: 12px;
    }

    /* Status/filter selects go full width */
    .card-header select,
    .card-header .form-input {
        width: 100% !important;
        box-sizing: border-box;
    }


    .sidebar {
        display: none !important;
    }

    .app-container {
        flex-direction: column;
    }

    .main-content {
        padding: 12px;
        padding-bottom: 85px;
        /* Free space for bottom nav */
    }

    .bottom-nav {
        display: flex;
    }

    .page-title-box,
    .card-header,
    .form-grid {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }

    .charts-grid,
    .tables-grid {
        grid-template-columns: 1fr;
    }

    .kpi-grid {
        grid-template-columns: 1fr 1fr;
    }

    .page-title-box div {
        margin-bottom: 8px;
    }

    /* Mobile Spacing & Touch Usability */
    .primary-btn,
    .secondary-btn,
    .stock-action-btn,
    .report-btn {
        min-height: 44px;
        width: 100%;
        display: flex;
        justify-content: center;
        align-items: center;
    }

    .form-input {
        min-height: 44px;
    }

    /* Fix table overflows */
    .styled-table {
        min-width: unset;
        /* Remove forced min-width — cards don't need it */
    }

    .data-table-card div[style*="overflow-x: auto"] {
        width: 100%;
    }

    /* Modal adjustments */
    .modal-content {
        width: 95%;
        margin: 10px auto;
        max-height: 90vh;
        overflow-y: auto;
    }

    /* Settings Screen adjustments */
    .settings-container {
        flex-direction: column;
    }

    .settings-sidebar {
        width: 100%;
        display: flex;
        overflow-x: auto;
        border-right: none;
        border-bottom: 1px solid var(--border-color);
        padding: 10px;
    }

    .settings-nav-item {
        white-space: nowrap;
        border-right: none !important;
        border-bottom: 2px solid transparent;
    }

    .settings-nav-item.active {
        border-bottom: 2px solid var(--primary-color);
    }

    /* Inventory Management Mobile Fixes */
    .dashboard-content .page-title-box[style*="display: flex"] {
        flex-direction: column !important;
        align-items: stretch !important;
    }

    .dashboard-content .page-title-box div[style*="display: flex"] {
        flex-wrap: wrap;
        gap: 8px;
        margin-top: 16px;
    }

    .stock-action-btn {
        flex: 1 1 45%;
        width: auto !important;
    }

    /* Card Layout for Tables on Mobile */
    .styled-table thead {
        display: none;
        /* Hide table headers — replaced by data-label */
    }

    .styled-table,
    .styled-table tbody,
    .styled-table tr,
    .styled-table td {
        display: block;
        width: 100%;
        box-sizing: border-box;
    }

    .styled-table tr {
        margin-bottom: 16px;
        border: 1px solid var(--border-color);
        border-radius: 12px;
        padding: 14px;
        background: var(--surface-color);
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
    }

    .styled-table td {
        border-bottom: 1px solid #f1f5f9;
        padding: 10px 0;
        display: flex;
        justify-content: space-between;
        align-items: center;
        text-align: right;
    }

    .styled-table td:last-child {
        border-bottom: none;
        justify-content: flex-end;
        gap: 8px;
    }

    /* Show field label before each value */
    .styled-table td::before {
        content: attr(data-label);
        font-weight: 600;
        color: var(--text-muted);
        font-size: 12px;
        text-transform: uppercase;
        text-align: left;
        white-space: nowrap;
        flex-shrink: 0;
        margin-right: 8px;
    }

    /* Right-align content inside cells */
    .styled-table td div {
        text-align: right;
    }

    .styled-table td[style*="text-align: right"] {
        text-align: right !important;
    }
}

@media (max-width: 480px) {
    .kpi-grid {
        grid-template-columns: 1fr;
    }
}