/* ===== CSS Variables ===== */
:root {
    --primary: #2563EB;
    --primary-light: #EFF6FF;
    --primary-dark: #1D4ED8;
    --primary-gradient: linear-gradient(135deg, #2563EB, #3B82F6);
    --success: #10B981;
    --success-light: #ECFDF5;
    --warning: #F59E0B;
    --warning-light: #FFFBEB;
    --danger: #EF4444;
    --danger-light: #FEF2F2;
    --info: #6366F1;
    --info-light: #EEF2FF;
    --purple: #8B5CF6;
    --purple-light: #F5F3FF;
    --bg: #F8FAFC;
    --bg-card: #FFFFFF;
    --bg-sidebar: #0F172A;
    --bg-sidebar-hover: #1E293B;
    --border: #E2E8F0;
    --border-light: #F1F5F9;
    --text-primary: #0F172A;
    --text-secondary: #475569;
    --text-muted: #94A3B8;
    --text-sidebar: #94A3B8;
    --text-sidebar-active: #FFFFFF;
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
    --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.07), 0 2px 4px -2px rgba(0,0,0,0.05);
    --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.08), 0 4px 6px -4px rgba(0,0,0,0.04);
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 14px;
    --transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    --sidebar-width: 232px;
}

/* ===== Reset ===== */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', 'Helvetica Neue', Arial, sans-serif;
    background: var(--bg);
    color: var(--text-primary);
    line-height: 1.6;
    overflow: hidden;
    height: 100vh;
}

/* ===== Layout ===== */
.layout { display: flex; height: 100vh; }

/* ===== Sidebar ===== */
.sidebar {
    width: var(--sidebar-width);
    background: var(--bg-sidebar);
    display: flex; flex-direction: column;
    flex-shrink: 0; z-index: 100;
    transition: transform 0.3s ease;
}
.sidebar-brand {
    padding: 22px 20px;
    display: flex; align-items: center; gap: 12px;
    border-bottom: 1px solid rgba(255,255,255,0.06);
}
.sidebar-brand-icon {
    width: 38px; height: 38px;
    background: var(--primary-gradient);
    border-radius: 10px;
    display: flex; align-items: center; justify-content: center;
    box-shadow: 0 4px 12px rgba(37,99,235,0.4);
}
.sidebar-brand-icon svg { width: 20px; height: 20px; }
.sidebar-brand-text { color: #fff; font-size: 16px; font-weight: 700; letter-spacing: 0.3px; }
.sidebar-brand-sub { color: var(--text-sidebar); font-size: 11px; opacity: 0.5; margin-top: 1px; }
.sidebar-nav { flex: 1; overflow-y: auto; padding: 12px 0; }
.sidebar-nav::-webkit-scrollbar { width: 0; }
.nav-section { margin-bottom: 6px; }
.nav-section-title {
    padding: 10px 20px 6px;
    font-size: 10px; font-weight: 700;
    color: rgba(148,163,184,0.5);
    text-transform: uppercase; letter-spacing: 1.5px;
}
.nav-item {
    display: flex; align-items: center; gap: 10px;
    padding: 10px 20px; margin: 2px 8px;
    color: var(--text-sidebar);
    cursor: pointer; border-radius: 8px;
    transition: var(--transition);
    font-size: 13.5px; font-weight: 500;
    position: relative;
}
.nav-item:hover { background: var(--bg-sidebar-hover); color: #E2E8F0; }
.nav-item.active {
    background: rgba(37,99,235,0.15);
    color: var(--text-sidebar-active);
}
.nav-item.active::before {
    content: '';
    position: absolute; left: 0; top: 50%;
    transform: translateY(-50%);
    width: 3px; height: 20px;
    background: var(--primary);
    border-radius: 0 3px 3px 0;
}
.nav-item svg { width: 18px; height: 18px; flex-shrink: 0; opacity: 0.7; }
.nav-item.active svg { opacity: 1; }
.nav-badge {
    margin-left: auto;
    background: var(--danger);
    color: #fff; font-size: 10px; font-weight: 700;
    padding: 1px 7px; border-radius: 10px; line-height: 18px;
}

/* ===== Mobile Sidebar Drawer ===== */
.mobile-overlay {
    position: fixed; inset: 0;
    background: rgba(15,23,42,0.5);
    z-index: 90; display: none;
    opacity: 0; transition: opacity 0.3s ease;
}
.mobile-overlay.active { display: block; opacity: 1; }

/* ===== Mobile Menu Button ===== */
.header-menu-btn {
    display: none;
    width: 38px; height: 38px;
    border: none; background: transparent;
    border-radius: 8px; cursor: pointer;
    color: var(--text-primary);
    align-items: center; justify-content: center;
    transition: var(--transition);
    flex-shrink: 0;
}
.header-menu-btn:hover { background: var(--bg); }
.header-menu-btn svg { width: 22px; height: 22px; }

/* ===== Main Content ===== */
.main { flex: 1; display: flex; flex-direction: column; overflow: hidden; min-width: 0; }
.header {
    height: 60px; background: var(--bg-card);
    border-bottom: 1px solid var(--border-light);
    display: flex; align-items: center; justify-content: space-between;
    padding: 0 28px; flex-shrink: 0; gap: 12px;
}
.header-title { font-size: 17px; font-weight: 700; color: var(--text-primary); white-space: nowrap; }
.header-right { display: flex; align-items: center; gap: 16px; flex-shrink: 0; }
.header-search {
    padding: 7px 14px; border: 1px solid var(--border);
    border-radius: 8px; font-size: 13px; width: 220px;
    background: var(--bg); transition: var(--transition);
    font-family: inherit;
}
.header-search:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37,99,235,0.1); }
.header-avatar {
    width: 34px; height: 34px; border-radius: 50%;
    background: var(--primary-gradient); color: #fff;
    display: flex; align-items: center; justify-content: center;
    font-size: 13px; font-weight: 700; cursor: pointer;
}

/* ===== Content Area with Animation ===== */
.content {
    flex: 1; overflow-y: auto; padding: 24px 28px;
    position: relative;
}
.content::-webkit-scrollbar { width: 6px; }
.content::-webkit-scrollbar-thumb { background: #CBD5E1; border-radius: 3px; }
.content::-webkit-scrollbar-track { background: transparent; }

.page-section {
    display: none; opacity: 0;
    transform: translateY(12px);
    animation: none;
}
.page-section.active {
    display: block;
    animation: pageIn 0.4s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}
@keyframes pageIn {
    from { opacity: 0; transform: translateY(12px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ===== Page Header ===== */
.page-header { margin-bottom: 24px; }
.page-title { font-size: 22px; font-weight: 800; color: var(--text-primary); margin-bottom: 4px; }
.page-desc { font-size: 13.5px; color: var(--text-muted); }

/* ===== Tabs ===== */
.tabs {
    display: flex; gap: 4px; margin-bottom: 20px;
    background: var(--bg); border-radius: 10px; padding: 4px;
    overflow-x: auto; -webkit-overflow-scrolling: touch;
}
.tab {
    padding: 9px 20px; border-radius: 8px;
    font-size: 13px; font-weight: 600; cursor: pointer;
    border: none; background: transparent;
    color: var(--text-secondary); transition: var(--transition);
    font-family: inherit; white-space: nowrap; flex-shrink: 0;
}
.tab:hover { color: var(--text-primary); background: rgba(255,255,255,0.6); }
.tab.active { background: var(--bg-card); color: var(--primary); box-shadow: var(--shadow-sm); }

.tab-content { display: none; opacity: 0; }
.tab-content.active {
    display: block;
    animation: tabIn 0.35s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}
@keyframes tabIn {
    from { opacity: 0; transform: translateX(8px); }
    to { opacity: 1; transform: translateX(0); }
}

/* ===== Stat Cards ===== */
.stat-grid { display: grid; gap: 16px; margin-bottom: 20px; }
.stat-grid.cols-4 { grid-template-columns: repeat(4, 1fr); }
.stat-grid.cols-3 { grid-template-columns: repeat(3, 1fr); }
.stat-card {
    background: var(--bg-card); border-radius: var(--radius-md);
    padding: 20px; box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-light);
    transition: var(--transition);
}
.stat-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }
.stat-card-header { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 12px; }
.stat-card-label { font-size: 13px; color: var(--text-secondary); font-weight: 500; }
.stat-card-icon {
    width: 40px; height: 40px; border-radius: 10px;
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
}
.stat-card-icon svg { width: 20px; height: 20px; }
.stat-card-value { font-size: 28px; font-weight: 800; color: var(--text-primary); line-height: 1.2; }
.stat-card-trend { font-size: 12px; color: var(--text-muted); margin-top: 6px; display: flex; align-items: center; gap: 4px; }
.stat-card-trend.up { color: var(--success); }

/* ===== Panel ===== */
.panel {
    background: var(--bg-card); border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm); border: 1px solid var(--border-light);
    margin-bottom: 20px; overflow: hidden;
    transition: var(--transition);
}
.panel:hover { box-shadow: var(--shadow-md); }
.panel-header {
    display: flex; justify-content: space-between; align-items: center;
    padding: 18px 22px; border-bottom: 1px solid var(--border-light);
    gap: 12px; flex-wrap: wrap;
}
.panel-title { font-size: 15px; font-weight: 700; display: flex; align-items: center; gap: 8px; }
.panel-title-dot { width: 4px; height: 16px; background: var(--primary); border-radius: 2px; }
.panel-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.panel-body { padding: 22px; }

/* ===== Table Wrapper (scroll) ===== */
.table-wrapper {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

/* ===== Table ===== */
.table { width: 100%; border-collapse: collapse; font-size: 13px; min-width: 600px; }
.table th {
    text-align: left; padding: 12px 16px;
    background: var(--bg); font-weight: 600;
    color: var(--text-secondary); font-size: 12px;
    text-transform: uppercase; letter-spacing: 0.5px;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}
.table td { padding: 14px 16px; border-bottom: 1px solid var(--border-light); vertical-align: middle; }
.table tbody tr { transition: var(--transition); }
.table tbody tr:hover { background: var(--primary-light); }
.table tbody tr:last-child td { border-bottom: none; }

/* ===== Tags ===== */
.tag {
    display: inline-flex; align-items: center;
    padding: 3px 10px; border-radius: 6px;
    font-size: 11px; font-weight: 600;
    white-space: nowrap;
}
.tag-blue { background: var(--primary-light); color: var(--primary); }
.tag-green { background: var(--success-light); color: var(--success); }
.tag-orange { background: var(--warning-light); color: #B45309; }
.tag-red { background: var(--danger-light); color: var(--danger); }
.tag-gray { background: #F1F5F9; color: #64748B; }
.tag-purple { background: var(--purple-light); color: var(--purple); }
.tag-indigo { background: var(--info-light); color: var(--info); }

/* ===== Buttons ===== */
.btn {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 8px 16px; border-radius: 8px;
    font-size: 13px; font-weight: 600; cursor: pointer;
    border: none; transition: var(--transition);
    font-family: inherit; white-space: nowrap;
}
.btn svg { width: 14px; height: 14px; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); transform: translateY(-1px); box-shadow: 0 4px 12px rgba(37,99,235,0.3); }
.btn-outline { background: var(--bg-card); color: var(--text-secondary); border: 1px solid var(--border); }
.btn-outline:hover { border-color: var(--primary); color: var(--primary); }
.btn-ghost { background: transparent; color: var(--primary); }
.btn-ghost:hover { background: var(--primary-light); }
.btn-sm { padding: 5px 12px; font-size: 12px; }
.btn-success { background: var(--success); color: #fff; }
.btn-success:hover { background: #059669; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #DC2626; }

/* ===== Forms ===== */
.form-group { margin-bottom: 14px; }
.form-label { display: block; font-size: 12px; font-weight: 600; color: var(--text-secondary); margin-bottom: 6px; }
.form-input, .form-select {
    width: 100%; padding: 9px 14px;
    border: 1px solid var(--border); border-radius: 8px;
    font-size: 13px; font-family: inherit;
    transition: var(--transition); background: var(--bg-card);
    color: var(--text-primary);
}
.form-input:focus, .form-select:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37,99,235,0.1); }
.form-input[readonly] { background: var(--bg); color: var(--text-muted); }

/* Form input width classes (replacing inline styles) */
.emp-search-input { width: 180px; max-width: 100%; }
.emp-rule-select { width: 130px; max-width: 100%; }
.wo-status-select { width: 120px; max-width: 100%; }
.rw-wo-select { width: 160px; max-width: 100%; }

/* ===== Modal ===== */
.modal-overlay {
    position: fixed; inset: 0;
    background: rgba(15,23,42,0.5);
    backdrop-filter: blur(4px);
    z-index: 1000; display: none;
    align-items: center; justify-content: center;
    opacity: 0; transition: opacity 0.25s ease;
    padding: 16px;
}
.modal-overlay.open { display: flex; opacity: 1; }
.modal {
    background: var(--bg-card); border-radius: var(--radius-lg);
    width: 520px; max-width: 100%; max-height: 85vh;
    overflow-y: auto; box-shadow: 0 25px 50px -12px rgba(0,0,0,0.2);
    transform: scale(0.95) translateY(10px);
    transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}
.modal-overlay.open .modal { transform: scale(1) translateY(0); }
.modal-header {
    display: flex; justify-content: space-between; align-items: center;
    padding: 20px 24px; border-bottom: 1px solid var(--border-light);
}
.modal-title { font-size: 16px; font-weight: 700; }
.modal-close {
    width: 32px; height: 32px; border-radius: 8px;
    display: flex; align-items: center; justify-content: center;
    cursor: pointer; border: none; background: transparent;
    color: var(--text-muted); font-size: 18px; transition: var(--transition);
    flex-shrink: 0;
}
.modal-close:hover { background: var(--bg); color: var(--text-primary); }
.modal-body { padding: 24px; }
.modal-footer {
    display: flex; justify-content: flex-end; gap: 10px;
    padding: 16px 24px; border-top: 1px solid var(--border-light);
}

/* ===== Dept Tree ===== */
.dept-tree { font-size: 13px; }
.dept-node { margin-bottom: 4px; }
.dept-header {
    display: flex; align-items: center; gap: 8px;
    padding: 8px 12px; border-radius: 8px;
    cursor: pointer; transition: var(--transition);
}
.dept-header:hover { background: var(--primary-light); }
.dept-header.selected { background: var(--primary-light); color: var(--primary); font-weight: 600; }
.dept-toggle {
    width: 18px; height: 18px; display: flex;
    align-items: center; justify-content: center;
    border-radius: 4px; background: var(--bg);
    border: none; cursor: pointer; transition: var(--transition);
    font-size: 11px; color: var(--text-muted);
    flex-shrink: 0;
}
.dept-toggle:hover { background: var(--primary); color: #fff; }
.dept-toggle.expanded { transform: rotate(90deg); }
.dept-name { font-weight: 500; }
.dept-count { font-size: 11px; color: var(--text-muted); margin-left: auto; white-space: nowrap; }
.dept-children { padding-left: 20px; display: none; }
.dept-children.open { display: block; animation: slideDown 0.25s ease forwards; }
@keyframes slideDown { from { opacity: 0; max-height: 0; } to { opacity: 1; max-height: 500px; } }

/* ===== BOM Tree ===== */
.bom-tree { font-size: 13px; }
.bom-node {
    border: 1px solid var(--border-light); border-radius: var(--radius-md);
    margin-bottom: 8px; overflow: hidden; transition: var(--transition);
}
.bom-node:hover { border-color: var(--primary); }
.bom-node.selected { border-color: var(--primary); box-shadow: 0 0 0 2px rgba(37,99,235,0.1); }
.bom-header {
    display: flex; align-items: center; gap: 10px;
    padding: 12px 16px; cursor: pointer; transition: var(--transition);
    background: var(--bg-card);
}
.bom-header:hover { background: var(--primary-light); }
.bom-toggle {
    width: 20px; height: 20px; display: flex;
    align-items: center; justify-content: center;
    border-radius: 4px; background: var(--bg);
    border: none; cursor: pointer; transition: var(--transition);
    font-size: 12px; color: var(--text-muted);
    flex-shrink: 0;
}
.bom-toggle:hover { background: var(--primary); color: #fff; }
.bom-toggle.expanded { transform: rotate(90deg); }
.bom-info { flex: 1; min-width: 0; }
.bom-name { font-weight: 600; font-size: 14px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.bom-meta { font-size: 12px; color: var(--text-muted); display: flex; gap: 12px; margin-top: 2px; flex-wrap: wrap; }
.bom-price { font-weight: 700; color: var(--primary); font-size: 15px; white-space: nowrap; }
.bom-children { padding: 0 12px 12px 28px; display: none; }
.bom-children.open { display: block; animation: slideDown 0.3s ease forwards; }

/* ===== Work Order ===== */
.wo-card {
    background: var(--bg-card); border-radius: var(--radius-md);
    border: 1px solid var(--border-light); padding: 20px;
    margin-bottom: 12px; transition: var(--transition);
    position: relative; overflow: hidden;
}
.wo-card:hover { border-color: var(--primary); box-shadow: var(--shadow-md); transform: translateY(-1px); }
.wo-card::before {
    content: ''; position: absolute; left: 0; top: 0; bottom: 0;
    width: 4px;
}
.wo-card.wo-pending::before { background: var(--warning); }
.wo-card.wo-active::before { background: var(--success); }
.wo-card.wo-done::before { background: var(--text-muted); }
.wo-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; }
.wo-id { font-weight: 700; font-size: 14px; }
.wo-body { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 12px; }
.wo-field-label { font-size: 11px; color: var(--text-muted); margin-bottom: 2px; }
.wo-field-value { font-size: 13px; font-weight: 600; }
.wo-progress { margin-top: 14px; }
.wo-progress-bar { height: 6px; background: var(--bg); border-radius: 3px; overflow: hidden; }
.wo-progress-fill { height: 100%; border-radius: 3px; transition: width 0.5s ease; }

/* ===== Report Work Modal ===== */
.report-limit {
    background: linear-gradient(135deg, #FEF3C7, #FFFBEB);
    border: 1px solid #FDE68A; border-radius: var(--radius-sm);
    padding: 12px 16px; margin-top: 8px; font-size: 13px;
}
.report-limit.over { background: linear-gradient(135deg, #FEE2E2, #FEF2F2); border-color: #FECACA; color: var(--danger); }

/* ===== User Group Card ===== */
.group-card {
    background: var(--bg-card); border-radius: var(--radius-md);
    border: 1px solid var(--border-light); padding: 20px;
    transition: var(--transition); cursor: pointer;
}
.group-card:hover { border-color: var(--primary); box-shadow: var(--shadow-md); transform: translateY(-2px); }
.group-card.selected { border-color: var(--primary); box-shadow: 0 0 0 2px rgba(37,99,235,0.1); }
.group-name { font-size: 15px; font-weight: 700; margin-bottom: 6px; }
.group-meta { font-size: 12px; color: var(--text-muted); display: flex; gap: 16px; }

/* ===== Pagination ===== */
.pagination {
    display: flex; justify-content: space-between; align-items: center;
    padding: 14px 22px; border-top: 1px solid var(--border-light);
    gap: 12px; flex-wrap: wrap;
}
.pagination-info { font-size: 12px; color: var(--text-muted); }
.pagination-btns { display: flex; gap: 4px; }
.page-btn {
    min-width: 32px; height: 32px; border-radius: 6px;
    display: flex; align-items: center; justify-content: center;
    font-size: 12px; border: 1px solid var(--border);
    background: var(--bg-card); cursor: pointer;
    transition: var(--transition); font-family: inherit;
}
.page-btn:hover { border-color: var(--primary); color: var(--primary); }
.page-btn.active { background: var(--primary); color: #fff; border-color: var(--primary); }

/* ===== Grid Helpers ===== */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }

/* ===== Progress Bar ===== */
.progress-bar { height: 8px; background: var(--bg); border-radius: 4px; overflow: hidden; }
.progress-fill { height: 100%; border-radius: 4px; transition: width 0.6s cubic-bezier(0.16, 1, 0.3, 1); }

/* ===== Notification Toast ===== */
.toast {
    position: fixed; top: 20px; right: 20px;
    background: var(--bg-card); border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg); padding: 16px 24px;
    display: flex; align-items: center; gap: 12px;
    z-index: 2000; transform: translateX(120%);
    transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1);
    border-left: 4px solid var(--success);
    max-width: calc(100vw - 40px);
}
.toast.show { transform: translateX(0); }
.toast-icon { width: 24px; height: 24px; color: var(--success); flex-shrink: 0; }
.toast-text { font-size: 14px; font-weight: 600; }

/* ===== Employee Page Layout (Tree + Table) ===== */
.emp-layout {
    display: grid;
    grid-template-columns: 260px 1fr;
    gap: 20px;
    align-items: start;
}
.emp-tree-panel {
    background: var(--bg-card);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-light);
    position: sticky;
    top: 0;
    max-height: calc(100vh - 140px);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transition: var(--transition);
}
.emp-tree-panel:hover { box-shadow: var(--shadow-md); }
.emp-tree-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 18px 12px;
    border-bottom: 1px solid var(--border-light);
    flex-shrink: 0;
}
.emp-tree-title {
    font-size: 14px;
    font-weight: 700;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 6px;
}
.emp-tree-toggle-btn {
    width: 28px;
    height: 28px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
}
.emp-tree-toggle-btn svg {
    transition: transform 0.3s ease;
}
.emp-tree-search {
    padding: 10px 14px;
    flex-shrink: 0;
}
.emp-tree-search-input {
    font-size: 12px;
    padding: 7px 12px;
}
.emp-tree-body {
    flex: 1;
    overflow-y: auto;
    padding: 8px 10px 14px;
}
.emp-tree-body::-webkit-scrollbar { width: 4px; }
.emp-tree-body::-webkit-scrollbar-thumb { background: #CBD5E1; border-radius: 2px; }
.emp-tree-body::-webkit-scrollbar-track { background: transparent; }

.emp-main-panel {
    min-width: 0;
}

/* ==========================================================
   RESPONSIVE BREAKPOINTS
   ========================================================== */

/* ----- Tablet (1024px and below) ----- */
@media (max-width: 1024px) {
    .stat-grid.cols-4 { grid-template-columns: repeat(2, 1fr); }
    .stat-grid.cols-3 { grid-template-columns: repeat(2, 1fr); }
    .grid-3 { grid-template-columns: repeat(2, 1fr); }
    .emp-layout { grid-template-columns: 220px 1fr; }
    .emp-search-input { width: 150px; }
}

/* ----- Small Tablet / Large Phone (768px and below) ----- */
@media (max-width: 768px) {
    /* Sidebar becomes drawer */
    .sidebar {
        position: fixed; left: 0; top: 0; bottom: 0;
        transform: translateX(-100%);
        z-index: 200;
        box-shadow: none;
    }
    .sidebar.open {
        transform: translateX(0);
        box-shadow: 4px 0 24px rgba(0,0,0,0.2);
    }

    /* Show menu button */
    .header-menu-btn { display: flex; }

    /* Header adjustments */
    .header { padding: 0 16px; }
    .header-search { width: 160px; }
    .header-title { font-size: 15px; }

    /* Content */
    .content { padding: 16px; }
    .page-title { font-size: 18px; }
    .page-desc { font-size: 12px; }

    /* Stat cards: single column */
    .stat-grid.cols-4, .stat-grid.cols-3 { grid-template-columns: 1fr 1fr; }
    .stat-card { padding: 16px; }
    .stat-card-value { font-size: 22px; }

    /* Grids */
    .grid-2, .grid-3 { grid-template-columns: 1fr; }

    /* Employee layout: stacked */
    .emp-layout { grid-template-columns: 1fr; }
    .emp-tree-panel { position: static; max-height: 280px; }

    /* Panel */
    .panel-header { padding: 14px 16px; }
    .panel-body { padding: 16px; }
    .panel-actions { width: 100%; }
    .emp-search-input, .emp-rule-select { width: 100%; max-width: none; }
    .wo-status-select, .rw-wo-select { width: 100%; max-width: none; }

    /* Modal */
    .modal { width: 100%; max-width: 100%; max-height: 90vh; border-radius: var(--radius-md); }
    .modal-body { padding: 16px; }
    .modal-header { padding: 16px; }
    .modal-footer { padding: 12px 16px; }

    /* Tabs scroll */
    .tabs { -webkit-overflow-scrolling: touch; }

    /* Pagination */
    .pagination { padding: 12px 16px; flex-direction: column; gap: 8px; align-items: flex-start; }
}

/* ----- Phone (480px and below) ----- */
@media (max-width: 480px) {
    .header-search { display: none; }
    .header { padding: 0 12px; }
    .content { padding: 12px; }
    .page-title { font-size: 16px; }

    /* Stat cards: single column */
    .stat-grid.cols-4, .stat-grid.cols-3 { grid-template-columns: 1fr; }
    .stat-card-value { font-size: 20px; }

    /* Panel actions: stack vertically */
    .panel-actions { width: 100%; flex-direction: column; align-items: stretch; }
    .panel-actions .btn { justify-content: center; }

    /* BOM header compact */
    .bom-header { padding: 10px 12px; }
    .bom-price { font-size: 13px; }
    .bom-children { padding: 0 8px 8px 16px; }

    /* Work order cards */
    .wo-card { padding: 14px; }
    .wo-body { grid-template-columns: repeat(2, 1fr); gap: 8px; }

    /* Toast */
    .toast { left: 12px; right: 12px; max-width: none; }

    /* Buttons in panels: compact */
    .btn { padding: 7px 12px; font-size: 12px; }

    /* Modal footer: full-width buttons */
    .modal-footer { flex-direction: column; }
    .modal-footer .btn { width: 100%; justify-content: center; }

    /* Tabs compact */
    .tab { padding: 7px 14px; font-size: 12px; }
}
