/* ====================================================================
   BEDI ERP PORTAL — ULTRA-PREMIUM RESPONSIVE DESIGN SYSTEM v3.1
   Fully Responsive: Mobile · Tablet · Desktop · Wide-screen
   ==================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800;900&display=swap');

/* ── Design Tokens ─────────────────────────────────────────────────── */
:root {
    --brand-primary:    #4f6ef7;
    --brand-primary-dk: #3b56d9;
    --brand-primary-lt: rgba(79,110,247,0.12);
    --brand-success:    #10d48e;
    --brand-success-lt: rgba(16,212,142,0.12);
    --brand-warning:    #f5a623;
    --brand-warning-lt: rgba(245,166,35,0.12);
    --brand-danger:     #ff4f6a;
    --brand-danger-lt:  rgba(255,79,106,0.12);
    --brand-info:       #00c8e0;
    --brand-info-lt:    rgba(0,200,224,0.12);
    --brand-purple:     #a855f7;
    --brand-purple-lt:  rgba(168,85,247,0.12);

    /* Sidebar */
    --sb-bg:           #0d1117;
    --sb-border:       rgba(255,255,255,0.06);
    --sb-text:         #8b9ab0;
    --sb-text-active:  #ffffff;
    --sb-hover-bg:     rgba(255,255,255,0.05);
    --sb-active-bg:    rgba(79,110,247,0.15);
    --sb-active-bar:   var(--brand-primary);
    --sb-width:        258px;
    --sb-header-h:     64px;

    /* Page / Card */
    --page-bg:         #f0f4fb;
    --card-bg:         #ffffff;
    --card-border:     #e4eaf3;
    --card-shadow:     0 2px 12px rgba(15,23,42,0.06);
    --card-shadow-h:   0 12px 32px rgba(15,23,42,0.12);
    --card-radius:     14px;

    /* Top Bar */
    --topbar-bg:       #ffffff;
    --topbar-border:   #e4eaf3;
    --topbar-h:        64px;

    /* Text */
    --txt-primary:     #1a2235;
    --txt-secondary:   #4a5568;
    --txt-muted:       #7a8599;

    /* Misc */
    --font:            'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --ease:            0.22s cubic-bezier(.4,0,.2,1);
}

/* ── Global Reset ───────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
    font-family: var(--font);
    background: var(--page-bg);
    color: var(--txt-primary);
    margin: 0; padding: 0;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* ── Layout ─────────────────────────────────────────────────────────── */
.erp-wrapper {
    display: flex;
    min-height: 100vh;
    width: 100%;
}

.erp-main-content {
    flex-grow: 1;
    margin-left: var(--sb-width);
    display: flex;
    flex-direction: column;
    min-width: 0;
    min-height: 100vh;
    transition: margin-left var(--ease);
    background: var(--page-bg);
}

/* ── Sidebar ─────────────────────────────────────────────────────────── */
.erp-sidebar {
    width: var(--sb-width);
    background: var(--sb-bg);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0; left: 0; bottom: 0;
    z-index: 1050;
    transition: transform var(--ease), width var(--ease);
    border-right: 1px solid var(--sb-border);
    background-image: radial-gradient(ellipse at 80% 0%, rgba(79,110,247,0.08) 0%, transparent 60%);
    overflow: hidden;
}

/* ── Sidebar Brand ───────────────────────────────────────────────────── */
.sidebar-brand {
    height: var(--sb-header-h);
    display: flex;
    align-items: center;
    padding: 0 1.25rem;
    border-bottom: 1px solid var(--sb-border);
    gap: 0.75rem;
    flex-shrink: 0;
    background: linear-gradient(135deg, rgba(79,110,247,0.1) 0%, transparent 60%);
    min-width: 0;
}

.sidebar-brand-logo {
    width: 34px; height: 34px;
    border-radius: 9px;
    background: linear-gradient(135deg, var(--brand-primary), var(--brand-primary-dk));
    display: flex; align-items: center; justify-content: center;
    color: #fff;
    font-size: 1rem;
    flex-shrink: 0;
    box-shadow: 0 4px 14px rgba(79,110,247,0.4);
}

.sidebar-brand-text {
    display: flex; flex-direction: column;
    min-width: 0;
    transition: opacity var(--ease), width var(--ease);
}
.sidebar-brand-text .brand-name {
    font-size: 0.92rem;
    font-weight: 800;
    color: #ffffff;
    letter-spacing: 0.3px;
    line-height: 1.2;
    white-space: nowrap;
}
.sidebar-brand-text .brand-sub {
    font-size: 0.65rem;
    color: var(--sb-text);
    letter-spacing: 0.5px;
    text-transform: uppercase;
    white-space: nowrap;
}

/* ── Sidebar Menu ────────────────────────────────────────────────────── */
.sidebar-menu {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 0.5rem 0 1rem;
    scrollbar-width: thin;
    scrollbar-color: rgba(255,255,255,0.08) transparent;
}
.sidebar-menu::-webkit-scrollbar { width: 3px; }
.sidebar-menu::-webkit-scrollbar-track { background: transparent; }
.sidebar-menu::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 4px; }

.menu-header {
    padding: 0.85rem 1.25rem 0.28rem;
    font-size: 0.6rem;
    font-weight: 700;
    letter-spacing: 1.2px;
    text-transform: uppercase;
    color: #4a5568;
    white-space: nowrap;
    overflow: hidden;
    transition: opacity var(--ease);
}

.nav-link-item {
    display: flex;
    align-items: center;
    gap: 0.7rem;
    padding: 0.56rem 1.25rem;
    color: var(--sb-text);
    text-decoration: none;
    font-size: 0.84rem;
    font-weight: 500;
    border-left: 2px solid transparent;
    transition: color var(--ease), background var(--ease), border-color var(--ease);
    white-space: nowrap;
    overflow: hidden;
    position: relative;
}
.nav-link-item span {
    overflow: hidden;
    text-overflow: ellipsis;
    transition: opacity var(--ease), max-width var(--ease);
}
.nav-link-item i {
    width: 18px;
    font-size: 0.9rem;
    color: #4a5568;
    transition: color var(--ease);
    flex-shrink: 0;
}
.nav-link-item:hover { color: #cdd5e3; background: var(--sb-hover-bg); }
.nav-link-item:hover i { color: #a0aec0; }
.nav-link-item.active {
    color: var(--sb-text-active);
    background: var(--sb-active-bg);
    border-left-color: var(--sb-active-bar);
    font-weight: 600;
}
.nav-link-item.active i { color: var(--brand-primary); }

/* ── Sidebar Footer ───────────────────────────────────────────────────── */
.sidebar-footer {
    padding: 0.85rem 1.25rem;
    border-top: 1px solid var(--sb-border);
    background: rgba(0,0,0,0.25);
    flex-shrink: 0;
    overflow: hidden;
}
.sidebar-user-avatar {
    width: 32px; height: 32px; border-radius: 50%;
    background: linear-gradient(135deg, var(--brand-primary), var(--brand-purple));
    color: #fff;
    display: flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: 0.8rem;
    flex-shrink: 0;
}

/* ── Collapsed Sidebar (icon-only mini mode) ─────────────────────────── */
.erp-sidebar.collapsed {
    width: 60px;
}
.erp-sidebar.collapsed .sidebar-brand-text,
.erp-sidebar.collapsed .menu-header,
.erp-sidebar.collapsed .nav-link-item span,
.erp-sidebar.collapsed .sidebar-user-info {
    opacity: 0;
    pointer-events: none;
    max-width: 0;
    overflow: hidden;
}
.erp-sidebar.collapsed .nav-link-item {
    padding: 0.56rem 0;
    justify-content: center;
}
.erp-sidebar.collapsed .nav-link-item i {
    width: auto;
    margin: 0;
}
.erp-sidebar.collapsed .sidebar-brand {
    justify-content: center;
    padding: 0;
}
.erp-sidebar.collapsed .sidebar-footer {
    padding: 0.85rem 0;
    display: flex;
    justify-content: center;
}

/* Main content responds to collapsed sidebar */
.erp-main-content.sidebar-collapsed {
    margin-left: 60px;
}

/* ── Top Navbar ────────────────────────────────────────────────────── */
.erp-topbar {
    height: var(--topbar-h);
    background: var(--topbar-bg);
    border-bottom: 1px solid var(--topbar-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1.5rem;
    position: sticky; top: 0; z-index: 1020;
    box-shadow: 0 1px 4px rgba(15,23,42,0.04);
    gap: 0.75rem;
    flex-shrink: 0;
}

.topbar-left  { display: flex; align-items: center; gap: 0.75rem; flex: 1; min-width: 0; }
.topbar-right { display: flex; align-items: center; gap: 0.5rem; flex-shrink: 0; }

/* ── Topbar toggle button ──────────────────────────────────────────── */
.topbar-icon-btn {
    width: 36px; height: 36px; border-radius: 9px;
    border: 1px solid var(--card-border);
    background: #fff;
    display: flex; align-items: center; justify-content: center;
    color: var(--txt-secondary);
    text-decoration: none;
    transition: all var(--ease);
    font-size: 0.9rem;
    cursor: pointer;
    flex-shrink: 0;
    position: relative;
}
.topbar-icon-btn:hover {
    background: var(--brand-primary-lt);
    border-color: var(--brand-primary);
    color: var(--brand-primary);
    transform: translateY(-1px);
}

/* ── Search ───────────────────────────────────────────────────────── */
.topbar-search {
    position: relative;
    flex: 1;
    max-width: 320px;
    min-width: 0;
}
.topbar-search .form-control {
    background: #f4f7fc;
    border: 1px solid #e4eaf3;
    border-radius: 9px;
    padding: 0.5rem 1rem 0.5rem 2.4rem;
    font-size: 0.84rem;
    transition: all var(--ease);
    color: var(--txt-primary);
    width: 100%;
}
.topbar-search .form-control::placeholder { color: var(--txt-muted); }
.topbar-search .form-control:focus {
    background: #fff;
    border-color: var(--brand-primary);
    box-shadow: 0 0 0 3px rgba(79,110,247,0.14);
    outline: none;
}
.topbar-search-icon {
    position: absolute;
    left: 0.8rem; top: 50%; transform: translateY(-50%);
    color: var(--txt-muted); pointer-events: none; font-size: 0.82rem;
}

/* ── Topbar user pill ─────────────────────────────────────────────── */
.topbar-user {
    display: flex; align-items: center; gap: 0.55rem;
    cursor: pointer;
    padding: 0.28rem 0.65rem;
    border-radius: 9px;
    border: 1px solid transparent;
    transition: all var(--ease);
    text-decoration: none;
    background: none;
}
.topbar-user:hover { background: #f4f7fc; border-color: var(--card-border); }
.topbar-user-avatar {
    width: 34px; height: 34px; border-radius: 50%;
    background: linear-gradient(135deg, var(--brand-primary), var(--brand-purple));
    color: #fff;
    display: flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: 0.8rem;
    flex-shrink: 0;
}

/* ── Page content main area ───────────────────────────────────────── */
main {
    flex: 1;
    padding: 1.4rem !important;
    min-width: 0;
}

/* ── Page Header ──────────────────────────────────────────────────── */
.page-header-title {
    font-size: 1.35rem;
    font-weight: 800;
    color: var(--txt-primary);
    margin: 0;
    line-height: 1.25;
}
.page-header-subtitle {
    font-size: 0.82rem;
    color: var(--txt-muted);
    margin: 0.2rem 0 0;
}

/* ── Stat Cards ───────────────────────────────────────────────────── */
.stat-card {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: var(--card-radius);
    padding: 1.25rem 1.15rem;
    position: relative;
    overflow: hidden;
    transition: transform var(--ease), box-shadow var(--ease);
    box-shadow: var(--card-shadow);
    height: 100%;
}
.stat-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--card-shadow-h);
}
.stat-card::after {
    content: '';
    position: absolute;
    top: -18px; right: -18px;
    width: 72px; height: 72px;
    border-radius: 50%;
    opacity: 0.06;
    transition: all var(--ease);
    pointer-events: none;
}
.stat-card:hover::after { transform: scale(1.3); opacity: 0.1; }
.stat-card.sc-primary::after  { background: var(--brand-primary); }
.stat-card.sc-success::after  { background: var(--brand-success); }
.stat-card.sc-warning::after  { background: var(--brand-warning); }
.stat-card.sc-danger::after   { background: var(--brand-danger); }
.stat-card.sc-info::after     { background: var(--brand-info); }
.stat-card.sc-purple::after   { background: var(--brand-purple); }

.stat-icon-wrapper {
    width: 46px; height: 46px;
    border-radius: 11px;
    display: flex; align-items: center; justify-content: center;
    font-size: 1.2rem;
    flex-shrink: 0;
}
.stat-icon-primary { background: var(--brand-primary-lt); color: var(--brand-primary); }
.stat-icon-success { background: var(--brand-success-lt); color: var(--brand-success); }
.stat-icon-warning { background: var(--brand-warning-lt); color: var(--brand-warning); }
.stat-icon-danger  { background: var(--brand-danger-lt);  color: var(--brand-danger); }
.stat-icon-info    { background: var(--brand-info-lt);    color: var(--brand-info); }
.stat-icon-purple  { background: var(--brand-purple-lt);  color: var(--brand-purple); }

.stat-title {
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.7px;
    color: var(--txt-muted);
    margin-bottom: 0.28rem;
}
.stat-value {
    font-size: 1.6rem;
    font-weight: 800;
    color: var(--txt-primary);
    line-height: 1.15;
    letter-spacing: -0.5px;
}
.stat-sub {
    font-size: 0.76rem;
    color: var(--txt-muted);
    margin-top: 0.18rem;
}

/* ── Cards ────────────────────────────────────────────────────────── */
.erp-card {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: var(--card-radius);
    box-shadow: var(--card-shadow);
    overflow: hidden;
}
.erp-card-header {
    padding: 0.9rem 1.3rem;
    border-bottom: 1px solid var(--card-border);
    display: flex; align-items: center; justify-content: space-between;
    background: #fff;
    flex-wrap: wrap;
    gap: 0.5rem;
}
.erp-card-header h6 {
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--txt-primary);
    margin: 0;
}
.card-body { padding: 1.1rem 1.3rem; }

/* ── Tables ───────────────────────────────────────────────────────── */
.erp-table { margin-bottom: 0; width: 100%; }
.erp-table thead th {
    background: #f7f9fd;
    color: var(--txt-muted);
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    padding: 0.75rem 1.1rem;
    border-bottom: 1px solid var(--card-border);
    white-space: nowrap;
}
.erp-table tbody td {
    padding: 0.82rem 1.1rem;
    vertical-align: middle;
    font-size: 0.85rem;
    border-bottom: 1px solid #f0f4fb;
    color: var(--txt-primary);
}
.erp-table tbody tr { transition: background var(--ease); }
.erp-table tbody tr:hover { background: #f7f9fd; }
.erp-table tbody tr:last-child td { border-bottom: none; }

/* ── Badges ───────────────────────────────────────────────────────── */
.badge-status {
    padding: 0.25rem 0.65rem;
    border-radius: 20px;
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 0.3px;
    display: inline-flex; align-items: center; gap: 0.3rem;
}
.badge-active   { background: var(--brand-success-lt); color: #059669; border: 1px solid rgba(16,212,142,0.25); }
.badge-empty    { background: #f1f5f9; color: #475569; border: 1px solid #e2e8f0; }
.badge-partial  { background: var(--brand-primary-lt); color: var(--brand-primary-dk); border: 1px solid rgba(79,110,247,0.25); }
.badge-full     { background: var(--brand-warning-lt); color: #b45309; border: 1px solid rgba(245,166,35,0.25); }
.badge-locked   { background: var(--brand-danger-lt); color: #b91c1c; border: 1px solid rgba(255,79,106,0.25); }
.badge-archived { background: #f3f4f6; color: #374151; border: 1px solid #d1d5db; }
.badge-danger   { background: var(--brand-danger-lt); color: #991b1b; }

/* ── Unit Calc Banner ─────────────────────────────────────────────── */
.unit-calc-box {
    background: linear-gradient(135deg, #111827 0%, #0d1117 100%);
    color: #fff;
    border-radius: var(--card-radius);
    padding: 1.1rem 1.3rem;
    box-shadow: 0 6px 24px rgba(0,0,0,0.16);
    border: 1px solid rgba(255,255,255,0.06);
    position: relative;
    overflow: hidden;
}
.unit-calc-box::before {
    content: '';
    position: absolute; top: -40px; right: -40px;
    width: 160px; height: 160px; border-radius: 50%;
    background: radial-gradient(circle, rgba(79,110,247,0.2), transparent 70%);
    pointer-events: none;
}
.unit-calc-box .calc-stat-label {
    font-size: 0.69rem; text-transform: uppercase;
    color: #6b7280; letter-spacing: 0.6px; font-weight: 600;
}
.unit-calc-box .calc-stat-val {
    font-size: 1.4rem; font-weight: 800;
    color: #60a5fa; letter-spacing: -0.5px;
}
/* Responsive column dividers in calc box */
.calc-box-col {
    padding: 0.9rem 1.1rem;
    border-right: 1px solid rgba(255,255,255,0.07);
}
@media (max-width: 575px) {
    .calc-box-col {
        border-right: none;
        border-bottom: 1px solid rgba(255,255,255,0.07);
        padding: 0.75rem 0.9rem;
    }
    .calc-box-col:last-child { border-bottom: none; }
}
@media (min-width: 576px) and (max-width: 991px) {
    /* 2-column layout: right borders only on left columns */
    .calc-box-col:nth-child(even) { border-right: none; }
    .calc-box-col:nth-child(1),
    .calc-box-col:nth-child(2) { border-bottom: 1px solid rgba(255,255,255,0.07); }
}


/* ── Quick Action Buttons ─────────────────────────────────────────── */
.quick-action-btn {
    display: inline-flex; align-items: center;
    gap: 0.4rem;
    padding: 0.52rem 1rem;
    border-radius: 8px;
    font-size: 0.83rem;
    font-weight: 600;
    text-decoration: none;
    transition: all var(--ease);
    border: none;
    white-space: nowrap;
}
.quick-action-btn:hover { transform: translateY(-2px); }

/* ── Forms ────────────────────────────────────────────────────────── */
.form-control, .form-select {
    border-radius: 9px;
    border: 1px solid #dce3ef;
    font-size: 0.87rem;
    transition: all var(--ease);
}
.form-control:focus, .form-select:focus {
    border-color: var(--brand-primary);
    box-shadow: 0 0 0 3px rgba(79,110,247,0.14);
}
.form-label { font-size: 0.81rem; font-weight: 600; color: var(--txt-secondary); }

/* ── Buttons ──────────────────────────────────────────────────────── */
.btn {
    border-radius: 9px; font-weight: 600; font-size: 0.86rem;
    transition: all var(--ease);
}
.btn:hover { transform: translateY(-1px); }
.btn-primary   { background: var(--brand-primary); border-color: var(--brand-primary); }
.btn-primary:hover { background: var(--brand-primary-dk); border-color: var(--brand-primary-dk); box-shadow: 0 6px 16px rgba(79,110,247,0.3); }
.btn-success:hover { box-shadow: 0 6px 16px rgba(16,212,142,0.3); }
.btn-danger:hover  { box-shadow: 0 6px 16px rgba(255,79,106,0.25); }

/* ── Section heading ──────────────────────────────────────────────── */
.section-heading {
    font-size: 1rem;
    font-weight: 800;
    color: var(--txt-primary);
    display: flex; align-items: center; gap: 0.6rem;
    flex-wrap: wrap;
}
.section-heading::after {
    content: '';
    flex: 1; height: 1px; min-width: 20px;
    background: linear-gradient(90deg, var(--card-border), transparent);
}

/* ── Live dot animation ───────────────────────────────────────────── */
@keyframes pulse-dot {
    0%   { box-shadow: 0 0 0 0 rgba(16,212,142,.5); }
    70%  { box-shadow: 0 0 0 6px rgba(16,212,142,0); }
    100% { box-shadow: 0 0 0 0 rgba(16,212,142,0); }
}
.live-dot {
    display: inline-block; width: 7px; height: 7px; border-radius: 50%;
    background: var(--brand-success);
    animation: pulse-dot 2s infinite;
    flex-shrink: 0;
}

/* ── Sidebar Overlay (mobile) ─────────────────────────────────────── */
.sidebar-overlay {
    display: none;
    position: fixed; inset: 0;
    background: rgba(0,0,0,0.55);
    z-index: 1040;
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
}
.sidebar-overlay.show { display: block; }

/* ── Scrollbar (global) ───────────────────────────────────────────── */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #cdd5e3; border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: #a0aec0; }

/* ── Progress bars ────────────────────────────────────────────────── */
.progress { border-radius: 8px; background: #eef0f7; }
.progress-bar { border-radius: 8px; transition: width 0.8s ease; }

/* ── Alert ────────────────────────────────────────────────────────── */
.alert { border-radius: 10px; font-size: 0.875rem; font-weight: 500; }

/* ── Footer ───────────────────────────────────────────────────────── */
footer.bg-white {
    background: #fff !important;
    border-top: 1px solid var(--card-border) !important;
    font-size: 0.73rem;
    color: var(--txt-muted);
    padding: 0.7rem 1.5rem !important;
    flex-shrink: 0;
}

/* ── Hover lift utility ───────────────────────────────────────────── */
.hover-lift { transition: transform var(--ease), box-shadow var(--ease); }
.hover-lift:hover { transform: translateY(-3px); box-shadow: var(--card-shadow-h); }

/* ══════════════════════════════════════════════════════════════════════
   RESPONSIVE BREAKPOINTS
   ══════════════════════════════════════════════════════════════════════ */

/* ── Wide desktop (≥1400px): wider sidebar, larger cards ─────────── */
@media (min-width: 1400px) {
    :root { --sb-width: 268px; }
    .stat-value { font-size: 1.75rem; }
    .page-header-title { font-size: 1.5rem; }
}

/* ── Standard desktop (992px – 1399px) ───────────────────────────── */
@media (min-width: 992px) and (max-width: 1399px) {
    :root { --sb-width: 248px; }
}

/* ── Tablet landscape / small desktop (768px – 991px) ────────────── */
@media (min-width: 768px) and (max-width: 991px) {
    :root {
        --sb-width: 60px;
        --topbar-h: 58px;
    }
    .erp-sidebar {
        width: var(--sb-width);
    }
    .erp-main-content {
        margin-left: var(--sb-width);
    }
    .sidebar-brand-text,
    .menu-header,
    .nav-link-item span,
    .sidebar-user-info {
        opacity: 0;
        pointer-events: none;
        max-width: 0;
        overflow: hidden;
        display: none;
    }
    .nav-link-item {
        padding: 0.62rem 0;
        justify-content: center;
    }
    .nav-link-item i { width: auto; margin: 0; }
    .sidebar-brand { justify-content: center; padding: 0; }
    .sidebar-footer { padding: 0.85rem 0; display: flex; justify-content: center; }
    .sidebar-user-info { display: none; }
    .topbar-search { max-width: 240px; }

    /* Tooltip for icon-only items */
    .nav-link-item { position: relative; }
    .nav-link-item:hover::after {
        content: attr(data-label);
        position: absolute;
        left: 64px;
        top: 50%; transform: translateY(-50%);
        background: #1e293b;
        color: #e2e8f0;
        font-size: 0.78rem;
        font-weight: 600;
        padding: 0.35rem 0.75rem;
        border-radius: 7px;
        white-space: nowrap;
        pointer-events: none;
        z-index: 1060;
        box-shadow: 0 4px 12px rgba(0,0,0,0.3);
    }
}

/* ── Mobile landscape (576px – 767px) ────────────────────────────── */
@media (min-width: 576px) and (max-width: 767px) {
    :root { --topbar-h: 56px; }

    .erp-sidebar {
        transform: translateX(-100%);
        width: 240px;
    }
    .erp-sidebar.show { transform: translateX(0); }
    .erp-main-content { margin-left: 0; }

    .topbar-search { display: none; }

    main { padding: 1rem !important; }
    .stat-value { font-size: 1.4rem; }
    .page-header-title { font-size: 1.1rem; }

    .unit-calc-box { padding: 0.9rem 1rem; }
    .unit-calc-box .calc-stat-val { font-size: 1.15rem; }

    .quick-action-btn { padding: 0.45rem 0.75rem; font-size: 0.78rem; }

    /* Stack KPI cards 2 per row on tablet */
    .kpi-grid { grid-template-columns: repeat(2, 1fr) !important; }

    .section-heading { font-size: 0.92rem; }
}

/* ── Mobile portrait (<576px) ────────────────────────────────────── */
@media (max-width: 575px) {
    :root { --topbar-h: 54px; }

    .erp-sidebar {
        transform: translateX(-100%);
        width: 235px;
    }
    .erp-sidebar.show { transform: translateX(0); box-shadow: 6px 0 32px rgba(0,0,0,0.35); }
    .erp-main-content { margin-left: 0; }

    .topbar-search,
    .topbar-quick-actions { display: none !important; }

    main { padding: 0.9rem !important; }

    .page-header-title { font-size: 1rem; }
    .page-header-subtitle { font-size: 0.76rem; }

    .stat-value { font-size: 1.3rem; }
    .stat-icon-wrapper { width: 38px; height: 38px; font-size: 1rem; }
    .stat-card { padding: 1rem 0.9rem; }

    .unit-calc-box { padding: 0.85rem 0.9rem; }
    .unit-calc-box .calc-stat-val { font-size: 1.05rem; }
    .unit-calc-box [style*="border-right"] { border-right: none !important; border-bottom: 1px solid rgba(255,255,255,0.07); padding-bottom: 0.7rem; margin-bottom: 0.7rem; }

    .erp-card-header { padding: 0.75rem 1rem; }
    .erp-card-header h6 { font-size: 0.83rem; }
    .card-body { padding: 0.9rem 1rem; }

    .erp-table thead th { padding: 0.62rem 0.85rem; font-size: 0.65rem; }
    .erp-table tbody td { padding: 0.7rem 0.85rem; font-size: 0.82rem; }

    .quick-action-btn {
        padding: 0.42rem 0.65rem;
        font-size: 0.76rem;
    }

    footer.bg-white {
        flex-direction: column;
        text-align: center;
        gap: 0.25rem;
        padding: 0.6rem 1rem !important;
    }

    .topbar-icon-btn { width: 33px; height: 33px; }
    .topbar-user-avatar { width: 30px; height: 30px; font-size: 0.74rem; }

    .section-heading { font-size: 0.88rem; }
    .section-heading .gap-2 { flex-wrap: wrap; gap: 0.35rem !important; }

    /* Notification dropdown full-width on mobile */
    .dropdown-menu[style*="width:320px"] {
        width: calc(100vw - 2rem) !important;
    }
}

/* ── Very small phones (<360px) ───────────────────────────────────── */
@media (max-width: 359px) {
    .stat-value { font-size: 1.15rem; }
    .page-header-title { font-size: 0.92rem; }
    main { padding: 0.7rem !important; }
}

/* ── Touch-device: remove hover transforms (prevents sticky states) ─ */
@media (hover: none) and (pointer: coarse) {
    .stat-card:hover { transform: none; box-shadow: var(--card-shadow); }
    .btn:hover { transform: none; }
    .quick-action-btn:hover { transform: none; }
    .topbar-icon-btn:hover { transform: none; }
}

/* ── Print media ──────────────────────────────────────────────────── */
@media print {
    .erp-sidebar, .erp-topbar, .sidebar-overlay { display: none !important; }
    .erp-main-content { margin-left: 0 !important; }
    main { padding: 0 !important; }
    body { background: white !important; }
    .stat-card, .erp-card { box-shadow: none !important; border: 1px solid #ddd !important; }
    .no-print { display: none !important; }
}
