:root {
    --primary: #1a365d;
    --primary-rgb: 26, 54, 93;
    --primary-light: #2b6cb0;
    --primary-dark: #0f1f3d;
    --secondary: #e2e8f0;
    --success: #27ae60;
    --warning: #f39c12;
    --danger: #e74c3c;
    --info: #3498db;
    --bg: #f0f2f5;
    --card-bg: #ffffff;
    --text: #2d3748;
    --text-muted: #718096;
    --border: #e2e8f0;
    /* Standardized font sizes */
    --font-xs: 11px;
    --font-sm: 12px;
    --font-base: 13px;
    --font-md: 14px;
    --font-lg: 16px;
    --font-xl: 18px;
    --font-2xl: 22px;
    --font-3xl: 28px;
    --radius: 10px;
    --shadow: 0 2px 12px rgba(0,0,0,0.08);
    --shadow-hover: 0 6px 24px rgba(0,0,0,0.12);
    --transition: all 0.3s ease;
    --sidebar-width: 260px;
    --header-height: 64px;
}

[data-theme="dark"] {
    --primary: #60a5fa;
    --primary-light: #93bbfd;
    --primary-dark: #3b82f6;
    --secondary: #1e293b;
    --success: #4ade80;
    --warning: #fbbf24;
    --danger: #f87171;
    --info: #38bdf8;
    --bg: #0f172a;
    --card-bg: #1e293b;
    --text: #e2e8f0;
    --text-muted: #94a3b8;
    --border: #334155;
    --shadow: 0 2px 12px rgba(0,0,0,0.3);
    --shadow-hover: 0 6px 24px rgba(0,0,0,0.4);
}

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

 body {
     font-family: 'Segoe UI', -apple-system, BlinkMacSystemFont, sans-serif;
     background: var(--bg);
     color: var(--text);
+    font-size: var(--font-base);
     line-height: 1.6;
     min-height: 100vh;
 }

/* ===== SIDEBAR ===== */
.sidebar {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    width: var(--sidebar-width);
    background: linear-gradient(180deg, var(--primary-dark) 0%, var(--primary) 100%);
    color: #fff;
    z-index: 1000;
    transition: var(--transition);
    display: flex;
    flex-direction: column;
}

.sidebar-brand {
    padding: 20px;
    text-align: center;
    border-bottom: 1px solid rgba(255,255,255,0.1);
}

.sidebar-brand h2 {
    font-size: 18px;
    font-weight: 700;
    letter-spacing: 1px;
}

.sidebar-brand small {
    font-size: 11px;
    color: #94a3b8;
}

.sidebar-menu {
    flex: 1;
    padding: 16px 0;
    overflow-y: auto;
}

.sidebar-menu .menu-label {
    padding: 8px 20px 4px;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    opacity: 0.5;
}

.sidebar-menu a {
    display: flex;
    align-items: center;
    padding: 10px 20px;
    color: rgba(255,255,255,0.75);
    text-decoration: none;
    font-size: 14px;
    transition: var(--transition);
    border-left: 3px solid transparent;
}

.sidebar-menu a:hover, .sidebar-menu a.active {
    background: rgba(255,255,255,0.1);
    color: #fff;
    border-left-color: var(--info);
}

.sidebar-menu a i {
    width: 24px;
    margin-right: 12px;
    font-size: 16px;
}

.sidebar-footer {
    padding: 16px 20px;
    border-top: 1px solid rgba(255,255,255,0.1);
    font-size: 12px;
    text-align: center;
    opacity: 0.6;
}

/* ===== MAIN CONTENT ===== */
.main-content {
    margin-left: var(--sidebar-width);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* ===== HEADER ===== */
.header {
    height: var(--header-height);
    background: var(--card-bg);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    position: sticky;
    top: 0;
    z-index: 999;
    box-shadow: 0 1px 4px rgba(0,0,0,0.04);
}

.header-left {
    display: flex;
    align-items: center;
    gap: 16px;
}

.header-left h3 {
    font-size: 16px;
    font-weight: 600;
    color: var(--text);
}

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

.header-right .user-info {
    text-align: right;
    font-size: 13px;
}

.header-right .user-info .name {
    font-weight: 600;
    color: var(--text);
}

.header-right .user-info .role {
    font-size: 11px;
    color: var(--text-muted);
}

.header-right .avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--primary);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 16px;
}

/* ===== BREADCRUMB ===== */
.breadcrumb {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 24px;
    background: var(--card-bg);
    border-bottom: 1px solid var(--border);
    font-size: 13px;
    flex-wrap: wrap;
}

.breadcrumb a {
    color: var(--text-muted);
    text-decoration: none;
    transition: color 0.2s;
}

.breadcrumb a:hover {
    color: var(--primary);
}

.breadcrumb .breadcrumb-sep {
    color: var(--text-muted);
    font-size: 16px;
    font-weight: 300;
    margin: 0 2px;
}

.breadcrumb .breadcrumb-current {
    color: var(--text);
    font-weight: 500;
}

.breadcrumb .fav-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    border-radius: 4px;
    cursor: pointer;
    border: none;
    background: none;
    color: var(--text-muted);
    font-size: 14px;
    transition: all 0.2s;
    margin-left: 8px;
}

.breadcrumb .fav-toggle:hover {
    background: var(--secondary);
    color: var(--warning);
}

.breadcrumb .fav-toggle.active {
    color: var(--warning);
}

/* ===== FAVORITES BAR (Sidebar) ===== */
#favoritesBar {
    transition: all 0.3s ease;
}

.fav-chip {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 8px;
    background: rgba(255,255,255,0.1);
    border-radius: 12px;
    font-size: 11px;
    color: rgba(255,255,255,0.85);
    text-decoration: none;
    transition: all 0.2s;
    cursor: pointer;
    white-space: nowrap;
    max-width: 120px;
    overflow: hidden;
    text-overflow: ellipsis;
}

.fav-chip:hover {
    background: rgba(255,255,255,0.2);
    color: #fff;
}

.fav-chip .fav-remove {
    margin-left: 2px;
    font-size: 10px;
    opacity: 0.5;
    cursor: pointer;
}

.fav-chip .fav-remove:hover {
    opacity: 1;
}

/* ===== RECENT BAR (Sidebar) ===== */
#recentBar {
    transition: all 0.3s ease;
}

.recent-item {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 4px 4px;
    border-radius: 4px;
    font-size: 11px;
    color: rgba(255,255,255,0.6);
    text-decoration: none;
    transition: all 0.2s;
    cursor: pointer;
}

.recent-item:hover {
    background: rgba(255,255,255,0.08);
    color: rgba(255,255,255,0.9);
}

.recent-item i {
    width: 16px;
    font-size: 11px;
    text-align: center;
    opacity: 0.5;
}

/* ===== MY APPROVALS WIDGET (Sidebar) ===== */
.approval-module {
    margin-bottom: 2px;
}
.approval-module-header {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 4px 12px 4px 28px;
    font-size: 11px;
    color: rgba(255,255,255,0.6);
    cursor: pointer;
    border-radius: 4px;
    transition: background 0.15s;
    text-decoration: none;
}
.approval-module-header:hover {
    background: rgba(255,255,255,0.08);
    color: rgba(255,255,255,0.9);
}
.approval-module-header i {
    width: 14px;
    font-size: 11px;
    text-align: center;
    opacity: 0.6;
}
.approval-module-count {
    margin-left: auto;
    font-size: 10px;
    background: var(--danger, #e74c3c);
    color: #fff;
    padding: 1px 6px;
    border-radius: 10px;
    font-weight: 600;
    line-height: 1.4;
}
.approval-item {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 3px 12px 3px 40px;
    font-size: 11px;
    color: rgba(255,255,255,0.55);
    text-decoration: none;
    border-radius: 3px;
    transition: background 0.15s;
    cursor: pointer;
}
.approval-item:hover {
    background: rgba(255,255,255,0.06);
    color: rgba(255,255,255,0.85);
}
.approval-item .step-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    flex-shrink: 0;
}
.approval-item .step-label {
    font-size: 9px;
    color: rgba(255,255,255,0.35);
    margin-left: auto;
    white-space: nowrap;
}
.approval-sort-btn:hover {
    opacity: 0.9 !important;
    color: rgba(255,255,255,0.9);
}

/* ===== PAGE CONTENT ===== */
.page-wrapper {
    padding: 24px;
    flex: 1;
}

.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
}

.page-header h2, .page-header h1 {
    font-size: var(--font-lg);
    font-weight: 700;
    color: var(--text);
    margin: 0;
}

.page-header p {
    font-size: var(--font-sm);
    color: var(--text-muted);
}

/* ===== CARDS ===== */
.card {
    background: var(--card-bg);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
    transition: var(--transition);
}

.card:hover {
    box-shadow: var(--shadow-hover);
}

.card-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.card-header h5 {
    font-size: 15px;
    font-weight: 600;
}

.card-body {
    padding: 20px;
    font-size: var(--font-base);
}

.card-footer {
    padding: 12px 20px;
    border-top: 1px solid var(--border);
    font-size: 13px;
    color: var(--text-muted);
}

/* ===== STATS CARDS ===== */
.stat-card {
    background: var(--card-bg);
    border-radius: var(--radius);
    padding: 20px;
    box-shadow: var(--shadow);
    border-left: 4px solid var(--primary);
    transition: var(--transition);
}

.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-hover);
}

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

.stat-card .stat-value {
    font-size: 28px;
    font-weight: 700;
    color: var(--text);
}

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

/* ===== METRIC CARDS (global) ===== */
.metric-card {
    border-radius: 12px; padding: 20px; text-align: center; cursor: pointer;
    transition: all 0.2s; border: 1px solid var(--border); background: var(--card-bg);
}
.metric-card:hover { transform: translateY(-3px); box-shadow: 0 6px 16px rgba(0,0,0,0.1); }
.metric-card .metric-icon {
    width: 48px; height: 48px; border-radius: 12px;
    display: flex; align-items: center; justify-content: center;
    font-size: 22px; margin: 0 auto 10px;
}
.metric-card .metric-value { font-size: 24px; font-weight: 700; }
.metric-card .metric-label { font-size: 13px; color: var(--text-muted); margin-top: 2px; }

/* ===== TABLES ===== */
.table-container {
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

thead {
    background: var(--bg);
}

th {
    padding: 12px 16px;
    text-align: left;
    font-weight: 600;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    border-bottom: 2px solid var(--border);
}

td {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}

tr:hover {
    background: rgba(43,108,176,0.04);
}

/* ===== BADGES ===== */
.badge {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.3px;
}
.badge-primary { background: #ebf4ff; color: var(--primary-light); }
.badge-success { background: #e6f7ee; color: var(--success); }
.badge-warning { background: #fef3e2; color: var(--warning); }
.badge-danger { background: #fde8e8; color: var(--danger); }
.badge-info { background: #e8f4fd; color: var(--info); }

/* ===== FORMS ===== */
.form-group { margin-bottom: 16px; }

.form-group label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    margin-bottom: 6px;
    color: var(--text);
}

.form-control {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 14px;
    transition: var(--transition);
    background: var(--card-bg);
    color: var(--text);
}

.form-control:focus {
    outline: none;
    border-color: var(--primary-light);
    box-shadow: 0 0 0 3px rgba(43,108,176,0.12);
}

select.form-control {
    appearance: none;
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 36px;
}

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

/* ===== BUTTONS ===== */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    text-decoration: none;
    line-height: 1;
}

.btn-primary { background: var(--primary-light); color: #fff; }
.btn-primary:hover { background: var(--primary); transform: translateY(-1px); box-shadow: 0 4px 12px rgba(43,108,176,0.3); }

.btn-success { background: var(--success); color: #fff; }
.btn-success:hover { background: #219a52; }

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

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

.btn-sm { padding: 6px 12px; font-size: 12px; }
.btn-lg { padding: 14px 28px; font-size: 16px; }

/* ===== SEARCH BAR ===== */
.search-bar {
    display: flex;
    align-items: center;
    gap: 8px;
}

.search-bar input {
    padding: 8px 14px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 13px;
    min-width: 240px;
    background: var(--card-bg);
}

.search-bar input:focus {
    outline: none;
    border-color: var(--primary-light);
}

/* ===== GRID ===== */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 20px; }
.grid-4 { display: grid; grid-template-columns: 1fr 1fr 1fr 1fr; gap: 20px; }

/* ===== ALERTS ===== */
.alert {
    padding: 14px 20px;
    border-radius: 8px;
    margin-bottom: 16px;
    font-size: 14px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.alert-success { background: #e6f7ee; color: #1a7a3a; border: 1px solid #b8e6c8; }
.alert-danger { background: #fde8e8; color: #b91c1c; border: 1px solid #f5c6c6; }
.alert-warning { background: #fef3e2; color: #92400e; border: 1px solid #fde68a; }
.alert-info { background: #e8f4fd; color: #1e40af; border: 1px solid #bfdbfe; }

/* ===== LOGIN PAGE ===== */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--primary-dark) 0%, var(--primary) 100%);
}

.login-card {
    background: var(--card-bg);
    border-radius: 16px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
    padding: 40px;
    width: 420px;
    max-width: 90vw;
}

.login-card h2 {
    text-align: center;
    margin-bottom: 8px;
    color: var(--primary);
    font-size: 24px;
}

.login-card p {
    text-align: center;
    color: var(--text-muted);
    margin-bottom: 28px;
    font-size: 14px;
}

/* ===== MODULES GRID ===== */
.modules-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 20px;
}

.module-card {
    background: var(--card-bg);
    border-radius: var(--radius);
    padding: 24px;
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
    transition: var(--transition);
    cursor: pointer;
    text-decoration: none;
    color: var(--text);
    display: block;
}

.module-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-hover);
}

.module-card .module-icon {
    width: 56px;
    height: 56px;
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    margin-bottom: 16px;
    color: #fff;
}

.module-card h4 {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 4px;
}

.module-card p {
    font-size: 13px;
    color: var(--text-muted);
}

/* ===== DETAIL ROW ===== */
.detail-row {
    display: flex;
    padding: 8px 0;
    border-bottom: 1px solid var(--border);
}

.detail-row .label {
    width: 180px;
    font-weight: 600;
    color: var(--text-muted);
    font-size: 13px;
}

.detail-row .value {
    flex: 1;
    font-size: 13px;
}

/* ===== SIDEBAR TOGGLE BUTTON ===== */
.sidebar-toggle {
    display: inline-flex;
    background: none;
    border: none;
    font-size: 22px;
    color: var(--text);
    cursor: pointer;
    padding: 4px;
    line-height: 1;
    transition: color .15s;
}
.sidebar-toggle:hover { color: var(--primary); }
.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.5);
    z-index: 999;
}

/* ===== SIDEBAR COLLAPSED (Desktop) ===== */
.sidebar.collapsed {
    width: 0;
    overflow: hidden;
    padding: 0;
    min-width: 0;
}
.sidebar.collapsed:hover {
    width: var(--sidebar-width);
    overflow: visible;
    padding: initial;
}

/* ===== RESPONSIVE ===== */
@media (max-width: 1024px) {
    .grid-4 { grid-template-columns: 1fr 1fr; }
    .detail-row .label { width: 140px; }
}

@media (max-width: 768px) {
    /* Sidebar */
    .sidebar.collapsed { width: 0 !important; overflow: hidden; padding: 0 !important; min-width: 0 !important; }
    .sidebar.collapsed .sidebar-brand,
    .sidebar.collapsed .sidebar-section,
    .sidebar.collapsed .search-wrapper,
    .sidebar.collapsed .favorites-section,
    .sidebar.collapsed .recent-section,
    .sidebar.collapsed .sidebar-footer { display: none; }
    .sidebar {
        transform: translateX(-100%);
        width: var(--sidebar-width) !important;
    }
    .sidebar.open { transform: translateX(0); }
    .sidebar-overlay.open { display: block; }
    .main-content { margin-left: 0; }

    /* Layout */
    .page-wrapper { padding: 16px; }
    .header { padding: 0 8px; height: 56px; gap: 4px; overflow: hidden; }
    .header-left { gap: 8px; }
    .header-left h3 { font-size: 13px; max-width: 120px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
    .header-search { display: none; }
    .header-right { gap: 4px; flex-shrink: 1; min-width: 0; }
    .header-right .user-info { display: none; }
    .header-right .avatar { width: 30px; height: 30px; font-size: 12px; }
    #companySwitcher { display: none; }
    .notification-bell { margin-right: 2px !important; }
    .header-right a[title="My Tasks"] { margin-right: 2px !important; }
    button[onclick*="openHelp"] { display: none; }
    .sidebar-toggle { padding: 4px; }

    /* Stats */
    .stat-card { padding: 16px; }
    .stat-card .stat-value { font-size: 22px; }
    .stat-card .stat-icon { width: 40px; height: 40px; font-size: 18px; }

    /* Grids */
    .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; gap: 12px; }
    .modules-grid { grid-template-columns: 1fr; }

    /* Tables */
    table { font-size: 12px; }
    th, td { padding: 8px 10px; }
    .table-container { margin: 0 -16px; border-radius: 0; }

    /* Cards */
    .card { border-radius: 8px; }
    .card-header { padding: 12px 16px; flex-wrap: wrap; gap: 8px; }
    .card-header h5 { font-size: 13px; }
    .card-body { padding: 14px; }

    /* Detail rows */
    .detail-row { flex-direction: column; padding: 8px 0; }
    .detail-row .label { width: 100%; font-size: 12px; margin-bottom: 2px; }

    /* Login */
    .login-card { padding: 28px 20px; width: 100%; max-width: 100vw; border-radius: 0; min-height: 100vh; display: flex; flex-direction: column; justify-content: center; }
    .login-page { background: var(--card-bg); }

    /* Search */
    .search-bar { flex-direction: column; align-items: stretch; }
    .search-bar input { min-width: 0; width: 100%; }

    /* Buttons */
    .btn { padding: 8px 14px; font-size: 13px; }
    .btn-sm { padding: 5px 10px; font-size: 11px; }

    /* Modal */
    .modal-card { width: 100% !important; max-width: 100% !important; max-height: 100vh !important; border-radius: 0 !important; margin: 0 !important; }

    /* Badge overflow */
    .badge { font-size: 10px; padding: 3px 8px; }

    /* Toast */
    .toast-container { top: 10px; right: 10px; left: 10px; }
    .toast { min-width: 0; font-size: 13px; }

    /* Page header */
    .page-header { flex-direction: column; align-items: flex-start; gap: 8px; }
    .page-header h2 { font-size: 18px; }

    /* Form */
    .form-control { padding: 8px 12px; font-size: 13px; }
}

@media (max-width: 480px) {
    .page-wrapper { padding: 12px; }
    .header { padding: 0 12px; height: 50px; }
    .header-left h3 { font-size: 13px; }
    .stat-card .stat-value { font-size: 18px; }
    th, td { padding: 6px 8px; font-size: 11px; }
    .card-header { padding: 10px 12px; }
    .card-body { padding: 10px; }
    .grid-2, .grid-3, .grid-4 { gap: 8px; }
}


/* scrollbar */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #cbd5e0; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #a0aec0; }


/* Pagination */
.pagination {
    display: flex;
    align-items: center;
    gap: 4px;
    margin-top: 16px;
}

.pagination a, .pagination span {
    padding: 6px 12px;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 13px;
    text-decoration: none;
    color: var(--text);
    transition: var(--transition);
}

.pagination a:hover { background: var(--bg); }
.pagination .active { background: var(--primary-light); color: #fff; border-color: var(--primary-light); }

/* =============================================================================
   MOBILE UI REFINEMENTS — v1.69
   Touch-friendly improvements for mobile and tablet use
   ============================================================================= */

/* Larger touch targets for sidebar links on mobile */
@media (max-width: 768px) {
    .sidebar a {
        padding: 14px 20px;
        font-size: 15px;
    }

    .sidebar .menu-label {
        padding: 16px 20px 6px;
        font-size: 11px;
    }

    /* Larger table cells for touch */
    .table-container table td,
    .table-container table th {
        padding: 12px 8px;
    }

    /* Bigger buttons on mobile */
    .btn,
    .btn-primary,
    .btn-sm,
    button {
        min-height: 44px;
    }

    .btn-sm {
        padding: 10px 16px;
    }

    /* Form controls */
    .form-control,
    select.form-control,
    input[type="text"],
    input[type="email"],
    input[type="password"],
    input[type="number"],
    textarea.form-control {
        font-size: 16px; /* Prevents iOS zoom on focus */
        padding: 12px 14px;
    }

    /* Card padding */
    .card {
        padding: 16px;
    }

    /* Bottom navigation for mobile */
    .mobile-bottom-nav {
        display: flex;
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        background: #fff;
        border-top: 1px solid var(--border);
        z-index: 999;
        padding: 8px 0;
        box-shadow: 0 -2px 10px rgba(0,0,0,0.05);
    }

    .mobile-bottom-nav a {
        flex: 1;
        text-align: center;
        color: var(--text-muted);
        text-decoration: none;
        font-size: 10px;
        padding: 4px 0;
    }

    .mobile-bottom-nav a i {
        display: block;
        font-size: 20px;
        margin-bottom: 2px;
    }

    .mobile-bottom-nav a.active {
        color: var(--primary);
    }

    /* Adjust main content for bottom nav */
    .main-content {
        padding-bottom: 72px;
    }
}

/* Swipe-to-refresh pull indicator (mobile) */
@media (max-width: 768px) {
    .pull-indicator {
        text-align: center;
        padding: 12px;
        color: var(--text-muted);
        font-size: 12px;
        display: none;
    }

    /* Full-width modals on mobile */
    .modal-content {
        margin: 0;
        border-radius: 16px 16px 0 0;
        max-height: 90vh;
        overflow-y: auto;
    }

    .modal-dialog {
        align-items: flex-end;
        padding: 0;
    }
}

/* Smooth scrolling for the whole page */
html {
    scroll-behavior: smooth;
}

/* Better focus styles for accessibility */
a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
    outline: 2px solid var(--primary-light);
    outline-offset: 2px;
}

/* Loading spinner for async operations */
.spinner {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 2px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Toast notifications */
.toast-container {
    position: fixed;
    top: 16px;
    right: 16px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.toast {
    padding: 12px 20px;
    border-radius: 8px;
    color: #fff;
    font-size: 14px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    animation: slideIn 0.3s ease;
    max-width: 360px;
}

.toast-success { background: var(--success); }
.toast-error { background: var(--danger); }
.toast-warning { background: var(--warning); }
.toast-info { background: var(--info); }

@keyframes slideIn {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

/* Empty state improvements */
.empty-state {
    padding: 48px 24px;
}

.empty-state i {
    opacity: 0.4;
}

/* =============================================================================
   UI COMPONENT ENHANCEMENTS — v1.70
   Toast, loading overlay, modal dialog, table enhancements
   ============================================================================= */

/* Loading overlay */
.loading-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255,255,255,0.8);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 100;
    border-radius: var(--radius);
}

/* Modal overlay */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.5);
    z-index: 5000;
    display: none;
    animation: fadeIn 0.2s ease;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* Enhanced empty state */
.empty-state-enhanced {
    text-align: center;
    padding: 60px 24px;
    color: var(--text-muted);
}

.empty-state-enhanced i {
    font-size: 48px;
    margin-bottom: 16px;
    opacity: 0.3;
    display: block;
}

.empty-state-enhanced h4 {
    font-size: 16px;
    margin-bottom: 8px;
    color: var(--text);
}

.empty-state-enhanced p {
    font-size: 13px;
    max-width: 400px;
    margin: 0 auto 16px;
}

/* Responsive table enhancements */
.table-responsive {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.table-responsive table {
    min-width: 600px;
}

/* Card hover effect */
.card-hover:hover {
    box-shadow: var(--shadow-hover);
    transform: translateY(-2px);
    transition: all 0.3s ease;
}

/* Stat card gradient variants — only for colored backgrounds */
.stat-card-primary { background: linear-gradient(135deg, #2563eb, #1d4ed8); color: #fff; }
.stat-card-success { background: linear-gradient(135deg, #16a34a, #15803d); color: #fff; }
.stat-card-warning { background: linear-gradient(135deg, #d97706, #b45309); color: #fff; }
.stat-card-danger { background: linear-gradient(135deg, #dc2626, #b91c1c); color: #fff; }
.stat-card-info { background: linear-gradient(135deg, #0891b2, #0e7490); color: #fff; }

/* KPI row layout */
.kpi-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

@media (max-width: 768px) {
    .kpi-row {
        grid-template-columns: repeat(2, 1fr);
        gap: 12px;
    }

    .stat-card .stat-value {
        font-size: 22px;
    }
}

/* Card header with actions */
.card-header-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
}

.card-header-actions h5 {
    margin: 0;
    font-size: 15px;
    font-weight: 600;
}

/* Search bar enhancement */
.search-bar-enhanced {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.search-bar-enhanced input {
    min-width: 200px;
}

/* Page header */
.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
    flex-wrap: wrap;
    gap: 12px;
}

.page-header h4 {
    margin: 0;
    font-size: var(--font-lg);
    font-weight: 700;
}

.page-header p {
    margin: 4px 0 0;
    color: var(--text-muted);
    font-size: 13px;
}

/* Action button bar */
.action-bar {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

/* Pagination */
.pagination-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 0;
    font-size: 13px;
    color: var(--text-muted);
    flex-wrap: wrap;
    gap: 8px;
}

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

.pagination-bar .pages a,
.pagination-bar .pages span {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 32px;
    height: 32px;
    padding: 0 8px;
    border-radius: 6px;
    font-size: 13px;
    text-decoration: none;
    color: var(--text);
    background: var(--bg);
}

.pagination-bar .pages a:hover {
    background: var(--primary-light);
    color: #fff;
}

.pagination-bar .pages .active {
    background: var(--primary);
    color: #fff;
    font-weight: 600;
}

.pagination-bar .pages .disabled {
    opacity: 0.4;
    pointer-events: none;
}

/* Filter bar */
.filter-bar {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    align-items: center;
}

.filter-bar select,
.filter-bar input {
    width: auto;
    padding: 8px 12px;
}

/* Bulk action bar */
.bulk-action-bar {
    display: none;
    background: #f0f9ff;
    border: 1px solid #bae6fd;
    border-radius: 8px;
    padding: 12px 16px;
    margin-bottom: 12px;
    align-items: center;
    gap: 12px;
    font-size: 13px;
}

.bulk-action-bar.show {
    display: flex;
}

/* Inline form (for filter/search) */
.form-inline {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    align-items: center;
}

/* Checkbox column for bulk select */
th.checkbox-col,
td.checkbox-col {
    width: 40px;
    text-align: center;
}

/* Responsive table card */
.table-card {
    background: var(--card-bg);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
}

.table-card .table-card-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
}

.table-card .table-card-body {
    padding: 0;
}

.table-card .table-card-footer {
    padding: 12px 20px;
    border-top: 1px solid var(--border);
}

/* Status indicator dot */
.status-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    margin-right: 6px;
}

.status-dot-success { background: var(--success); }
.status-dot-warning { background: var(--warning); }
.status-dot-danger { background: var(--danger); }
.status-dot-info { background: var(--info); }
.status-dot-secondary { background: var(--text-muted); }

/* ===== NOTIFICATION BELL ===== */
.notification-bell { position: relative; display: inline-block; margin-left: auto; padding: 8px 12px; color: #fff; text-decoration: none; }
.notification-bell i { font-size: 18px; }
.notification-count { position: absolute; top: 0; right: 0; font-size: 10px; padding: 2px 5px; min-width: 18px; text-align: center; border-radius: 99px; }

/* ===== MOBILE — Module grid & form overrides ===== */
@media (max-width: 768px) {
    .module-form-grid { grid-template-columns: 1fr !important; gap: 8px !important; }
    .module-form-grid [class*="col-"] { grid-column: span 1 !important; }
    .module-form-grid select,
    .module-form-grid input,
    .module-form-grid textarea { font-size: 16px !important; min-height: 44px; }
    .module-form-grid .btn { min-height: 44px; font-size: 15px; width: 100%; }
    .module-form-grid .form-group { margin-bottom: 6px; }
    .card-body { padding: 12px !important; }

    .table-card .btn { min-height: 40px; min-width: 40px; }
    .table-card input[type="checkbox"] { width: 20px; height: 20px; }
    .filter-bar input { font-size: 16px !important; }

    .page-header-actions .btn { font-size: 13px; padding: 8px 12px; }
    .page-header h2 { font-size: 18px; }
    .page-header .btn { min-height: 40px; }
    .filter-bar form > * { min-height: 40px; }

    table { font-size: 12px; }
    th, td { padding: 8px 10px; }
    .table-container { margin: 0 -16px; border-radius: 0; }
    .stat-card { padding: 16px; }
    .stat-card .stat-value { font-size: 22px; }
}
/* Fix Chrome Android text-size-adjust compatibility */
body { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
