/**
 * AKLMS 2.0 - Design layer (loaded after style.css)
 * Brand: AK Media #205c5e + gold #e0a526
 * Development & Programming Rights: M2 Service - https://m2.ist
 */

/* ============ Tokens ============ */
:root {
    --mk-brand: #205c5e;
    --mk-brand-2: #2c6b6e;
    --mk-brand-3: #3a9ea5;
    --mk-brand-dark: #163f41;
    --mk-gold: #e0a526;
    --mk-soft: #e8f4f5;
    --mk-ok: #2e9d68;
    --mk-warn: #d9901a;
    --mk-danger: #d0453b;
    --mk-radius: 16px;
    --mk-radius-lg: 22px;
    --mk-shadow: 0 10px 30px rgba(20, 60, 62, 0.08);
    --mk-shadow-lg: 0 18px 50px rgba(20, 60, 62, 0.16);
    --mk-grad: linear-gradient(135deg, #205c5e 0%, #2c6b6e 60%, #347f82 100%);

    --bg-secondary: #f1f6f6;
    --border-color: #e2eaea;
    --text-primary: #1f3536;
    --text-secondary: #5f7677;
    --shadow: var(--mk-shadow);
    --sidebar-width: 272px;
}

[data-theme="dark"] {
    --bg-primary: #121b1c;
    --bg-secondary: #0e1617;
    --bg-card: #172324;
    --text-primary: #e3eeee;
    --text-secondary: #a3b8b9;
    --text-muted: #7f9596;
    --border-color: #2a3a3b;
    --mk-soft: rgba(58, 158, 165, 0.14);
    --mk-shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
    --mk-shadow-lg: 0 18px 50px rgba(0, 0, 0, 0.45);
    --light-primary: rgba(58, 158, 165, 0.16);
}

/* ============ Base ============ */
body.app-layout {
    background:
        radial-gradient(900px 500px at 100% -10%, rgba(191, 224, 225, 0.55), transparent 60%),
        radial-gradient(700px 420px at -10% 110%, rgba(244, 226, 184, 0.45), transparent 60%),
        var(--bg-secondary);
    background-attachment: fixed;
    color: var(--text-primary);
    -webkit-font-smoothing: antialiased;
}
[data-theme="dark"] body.app-layout {
    background:
        radial-gradient(900px 500px at 100% -10%, rgba(32, 92, 94, 0.28), transparent 60%),
        radial-gradient(700px 420px at -10% 110%, rgba(224, 165, 38, 0.08), transparent 60%),
        var(--bg-secondary);
}
.app-layout .fa-solid, .app-layout .fa-regular, .app-layout .fa-brands { line-height: 1; }
.app-layout .btn i, .app-layout .sb-link i, .app-layout .page-title i { margin-inline-end: 6px; }

.container { padding: 18px 22px; }
.app-shell { display: flex; flex-direction: column; min-height: 100vh; min-height: 100dvh; }
.app-shell > .container { flex: 1 0 auto; width: 100%; }
.app-shell > .footer { flex-shrink: 0; margin-top: auto; }
.main-content {
    background: var(--bg-card);
    border-radius: var(--mk-radius-lg);
    padding: 26px;
    border: 1px solid rgba(32, 92, 94, 0.06);
    box-shadow: var(--mk-shadow);
    margin-top: 6px;
}

/* ============ Sidebar ============ */
.sidebar {
    background: linear-gradient(180deg, #153b3d 0%, #1b4c4e 55%, #205c5e 100%);
    border-left: 0;
    color: #e7f1f1;
    box-shadow: -8px 0 30px rgba(10, 30, 31, 0.18);
}
.sb-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 20px 18px 14px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}
.sb-brand { justify-content: center; position: relative; }
.sb-logo-link { display: flex; justify-content: center; padding: 2px 0; }
.sb-logo {
    display: block;
    width: 132px;
    height: 50px;
    object-fit: contain;
    filter: brightness(0) invert(1);
    backface-visibility: hidden;
}
.sb-brand .sidebar-close { position: absolute; inset-inline-end: 14px; top: 50%; transform: translateY(-50%); }
.sb-app { font-weight: 800; font-size: 0.95rem; color: #fff; letter-spacing: 0.3px; }
.sb-app em {
    font-style: normal;
    font-size: 0.7rem;
    color: #1b3a3b;
    background: var(--mk-gold);
    border-radius: 99px;
    padding: 1px 7px;
    margin-inline-start: 4px;
}
.sidebar .sidebar-close {
    margin-inline-start: auto;
    color: #fff;
}
.sidebar-nav { padding: 10px 12px 18px; scrollbar-width: thin; scrollbar-color: rgba(255,255,255,0.2) transparent; }
.sb-group { margin-top: 10px; }
.sb-label {
    display: block;
    padding: 8px 12px 6px;
    font-size: 0.72rem;
    font-weight: 800;
    letter-spacing: 0.06em;
    color: rgba(255, 217, 138, 0.8);
}
.sb-link {
    position: relative;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    margin: 2px 0;
    border-radius: 12px;
    color: rgba(236, 245, 245, 0.86);
    text-decoration: none;
    font-weight: 600;
    font-size: 0.93rem;
    transition: background 0.2s, color 0.2s, transform 0.2s;
}
.sb-link i {
    width: 30px;
    height: 30px;
    border-radius: 9px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.07);
    font-size: 0.88rem;
    margin: 0 !important;
    transition: background 0.2s, color 0.2s;
}
.sb-link:hover { background: rgba(255, 255, 255, 0.08); color: #fff; }
.sb-link.active {
    background: rgba(255, 255, 255, 0.14);
    color: #fff;
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.08);
}
.sb-link.active i { background: var(--mk-gold); color: #1b3a3b; }
.sb-link.active::before {
    content: '';
    position: absolute;
    right: -12px;
    top: 9px;
    bottom: 9px;
    width: 4px;
    border-radius: 4px 0 0 4px;
    background: var(--mk-gold);
}
.sb-user {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 0 12px 14px;
    padding: 12px;
    border-radius: 16px;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.08);
}
.sb-avatar {
    width: 40px;
    height: 40px;
    flex: none;
    border-radius: 12px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    color: #1b3a3b;
    background: linear-gradient(135deg, #ffd98a, var(--mk-gold));
}
.sb-user-info { min-width: 0; flex: 1; line-height: 1.35; }
.sb-user-info strong { display: block; color: #fff; font-size: 0.9rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sb-user-info small { color: rgba(236, 245, 245, 0.7); font-size: 0.78rem; }
.sb-user-info small i { margin-inline-end: 4px; color: #ffd98a; }
.sb-logout {
    width: 36px;
    height: 36px;
    flex: none;
    border-radius: 10px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    background: rgba(255, 255, 255, 0.1);
    text-decoration: none;
    transition: background 0.2s;
}
.sb-logout:hover { background: rgba(208, 69, 59, 0.85); color: #fff; }

/* ============ Top bar ============ */
.topbar {
    position: sticky;
    top: 0;
    z-index: 900;
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px 24px;
    background: rgba(255, 255, 255, 0.78);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid rgba(32, 92, 94, 0.08);
}
[data-theme="dark"] .topbar { background: rgba(18, 27, 28, 0.82); border-color: rgba(255, 255, 255, 0.06); }
.topbar .menu-toggle {
    background: var(--mk-soft);
    color: var(--mk-brand);
    border-radius: 12px;
}
.tb-title { min-width: 0; flex: 1; }
.tb-title h1 {
    margin: 0;
    font-size: 1.2rem;
    font-weight: 800;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.tb-title span { font-size: 0.8rem; color: var(--text-secondary); font-weight: 600; }
.tb-actions { display: flex; align-items: center; gap: 8px; }
.theme-toggle {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    border: 0;
    cursor: pointer;
    font-family: inherit;
    font-weight: 700;
    font-size: 0.85rem;
    padding: 9px 14px;
    border-radius: 12px;
    color: var(--mk-brand);
    background: var(--mk-soft);
    transition: background 0.2s, color 0.2s;
}
.theme-toggle:hover { background: var(--mk-brand); color: #fff; }
[data-theme="dark"] .theme-toggle { color: #ffd98a; }
.tb-version {
    font-size: 0.75rem;
    font-weight: 800;
    color: var(--mk-brand);
    background: rgba(224, 165, 38, 0.16);
    padding: 5px 10px;
    border-radius: 99px;
}
[data-theme="dark"] .tb-version { color: #ffd98a; }

/* ============ Page header (mini hero) ============ */
.page-header {
    position: relative;
    overflow: hidden;
    flex-wrap: wrap;
    gap: 14px;
    padding: 22px 24px;
    margin: -6px -6px 22px;
    border: 0;
    border-radius: 20px;
    color: #fff;
    background:
        radial-gradient(circle at 10% 130%, rgba(224, 165, 38, 0.3), transparent 45%),
        radial-gradient(circle at 95% -20%, rgba(255, 255, 255, 0.16), transparent 50%),
        var(--mk-grad);
    box-shadow: 0 14px 36px rgba(20, 60, 62, 0.22);
}
.page-header::after {
    content: '';
    position: absolute;
    left: -50px;
    bottom: -70px;
    width: 190px;
    height: 190px;
    border: 26px solid rgba(255, 255, 255, 0.06);
    border-radius: 50%;
    pointer-events: none;
}
.page-header > * { position: relative; z-index: 1; }
.page-title { color: #fff; font-size: 1.55rem; font-weight: 800; margin: 0; }
.page-header .text-muted { color: rgba(255, 255, 255, 0.8) !important; }
.page-header .btn {
    background: rgba(255, 255, 255, 0.14);
    color: #fff;
    box-shadow: inset 0 0 0 1.5px rgba(255, 255, 255, 0.35);
}
.page-header .btn:hover { background: rgba(255, 255, 255, 0.24); color: #fff; }
.page-header .btn-primary,
.page-header .btn-success { background: #fff; color: var(--mk-brand); box-shadow: 0 6px 16px rgba(0, 0, 0, 0.12); }
.page-header .btn-primary:hover,
.page-header .btn-success:hover { background: #fff; color: var(--mk-brand-dark); }
.page-header .form-control { background: rgba(255, 255, 255, 0.95); color: #1f3536; border-color: transparent; }

/* ============ Buttons ============ */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 10px 18px;
    border-radius: 12px;
    font-weight: 700;
    font-size: 0.93rem;
    line-height: 1.4;
    transition: transform 0.15s, box-shadow 0.2s, background 0.2s, filter 0.2s;
}
.btn i { margin: 0 !important; }
.btn:hover { transform: translateY(-1px); }
.btn-primary { background: linear-gradient(135deg, var(--mk-brand), var(--mk-brand-2)); color: #fff; box-shadow: 0 6px 16px rgba(32, 92, 94, 0.22); }
.btn-primary:hover { background: linear-gradient(135deg, var(--mk-brand-dark), var(--mk-brand)); color: #fff; box-shadow: 0 10px 22px rgba(32, 92, 94, 0.3); }
.btn-secondary { background: var(--mk-soft); color: var(--mk-brand); box-shadow: inset 0 0 0 1px rgba(32, 92, 94, 0.14); }
.btn-secondary:hover { background: var(--mk-brand); color: #fff; }
[data-theme="dark"] .btn-secondary { color: #9fd6d9; }
[data-theme="dark"] .btn-secondary:hover { color: #fff; }
.btn-success { background: linear-gradient(135deg, #2e9d68, #3bb87d); color: #fff; box-shadow: 0 6px 16px rgba(46, 157, 104, 0.22); }
.btn-success:hover { color: #fff; filter: brightness(1.06); }
.btn-info { background: linear-gradient(135deg, #2f8f96, #3a9ea5); color: #fff; }
.btn-info:hover { color: #fff; filter: brightness(1.06); }
.btn-warning { background: linear-gradient(135deg, #e0a526, #eab94a); color: #3a2a05; }
.btn-warning:hover { color: #3a2a05; filter: brightness(1.05); }
.btn-danger { background: rgba(208, 69, 59, 0.1); color: var(--mk-danger); box-shadow: inset 0 0 0 1.5px rgba(208, 69, 59, 0.35); }
.btn-danger:hover { background: var(--mk-danger); color: #fff; }
.btn-sm { padding: 6px 11px; font-size: 0.82rem; border-radius: 10px; }
.btn:disabled, .btn.disabled { opacity: 0.55; transform: none; cursor: not-allowed; }
.table td .btn { margin: 2px; }

/* ============ Cards ============ */
.card {
    border-radius: 18px;
    padding: 20px 22px;
    border: 1px solid rgba(32, 92, 94, 0.07);
    box-shadow: var(--mk-shadow);
}
.card-header { border-bottom: 1px solid var(--border-color); padding-bottom: 12px; margin-bottom: 16px; }
.card-title { color: var(--mk-brand); font-weight: 800; font-size: 1.1rem; margin: 0; }
[data-theme="dark"] .card-title { color: #9fd6d9; }

/* Stat cards: rotating brand palette like the client report */
.stat-card {
    border-radius: 20px;
    padding: 22px 16px;
    background: linear-gradient(145deg, #205c5e, #2f7a7d);
    box-shadow: 0 14px 34px rgba(20, 60, 62, 0.2);
}
.stat-card::before {
    top: auto; right: auto;
    left: -30px; bottom: -30px;
    width: 110px; height: 110px;
    transform: none;
    background: rgba(255, 255, 255, 0.08);
}
.stat-card:hover::before { transform: scale(1.15); }
.stat-value { font-weight: 800; }
.stat-label { font-weight: 700; }
.col-md-2:nth-child(6n+2) .stat-card, .col-md-3:nth-child(4n+2) .stat-card, .stats-grid-6 .stat-card:nth-child(6n+2), .stats-container .stat-card:nth-child(4n+2) { background: linear-gradient(145deg, #2b3f40, #3e5859); }
.col-md-2:nth-child(6n+3) .stat-card, .col-md-3:nth-child(4n+3) .stat-card, .stats-grid-6 .stat-card:nth-child(6n+3), .stats-container .stat-card:nth-child(4n+3) { background: linear-gradient(145deg, #c98a14, #e3ad3b); }
.col-md-2:nth-child(6n+4) .stat-card, .col-md-3:nth-child(4n+4) .stat-card, .stats-grid-6 .stat-card:nth-child(6n+4), .stats-container .stat-card:nth-child(4n+4) { background: linear-gradient(145deg, #2f8f96, #3fb0b7); }
.col-md-2:nth-child(6n+5) .stat-card, .stats-grid-6 .stat-card:nth-child(6n+5) { background: linear-gradient(145deg, #2e9d68, #43b981); }
.col-md-2:nth-child(6n+6) .stat-card, .stats-grid-6 .stat-card:nth-child(6n+6) { background: linear-gradient(145deg, #7a5cc7, #9478da); }

/* ============ Forms ============ */
.form-label { color: var(--text-primary); font-weight: 700; font-size: 0.9rem; margin-bottom: 6px; }
.form-control {
    border: 1.5px solid var(--border-color);
    border-radius: 12px;
    padding: 10px 13px;
    background: var(--bg-primary);
    transition: border-color 0.2s, box-shadow 0.2s, background 0.2s;
}
.form-control:hover { border-color: #c9d9d9; }
.form-control:focus {
    outline: none;
    border-color: var(--mk-brand-3);
    box-shadow: 0 0 0 4px rgba(58, 158, 165, 0.15);
    background: var(--bg-card);
}
[data-theme="dark"] .form-control:hover { border-color: #3b4f50; }
.form-group { margin-bottom: 16px; }

/* ============ Tables ============ */
.table-container, .table-responsive {
    border-radius: 18px;
    border: 1px solid var(--border-color);
    background: var(--bg-card);
    overflow: auto;
    box-shadow: 0 4px 16px rgba(20, 60, 62, 0.04);
}
.table { border-collapse: separate; border-spacing: 0; }
.table th {
    position: sticky;
    top: 0;
    z-index: 2;
    background: #eef6f6;
    color: var(--mk-brand);
    font-weight: 800;
    font-size: 0.85rem;
    border-bottom: 1px solid var(--border-color);
    padding: 13px 12px;
}
[data-theme="dark"] .table th { background: #1c2c2d; color: #9fd6d9; }
.table td { border-bottom: 1px solid var(--border-color); padding: 12px; vertical-align: middle; }
.table tbody tr { transition: background 0.15s; }
.table tr:hover, .table tbody tr:hover { background: rgba(58, 158, 165, 0.06); }
.table tbody tr:last-child td { border-bottom: 0; }

/* ============ Badges / Alerts ============ */
.badge {
    border-radius: 99px;
    padding: 4px 11px;
    font-weight: 700;
    font-size: 0.78rem;
}
.alert {
    border: 0;
    border-inline-start: 4px solid;
    border-left-width: 0;
    border-radius: 14px;
    padding: 13px 16px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}
.alert-success { background: rgba(46, 157, 104, 0.1); color: #1f7a4f; border-color: var(--mk-ok); }
.alert-warning { background: rgba(224, 165, 38, 0.14); color: #8a6212; border-color: var(--mk-gold); }
.alert-danger { background: rgba(208, 69, 59, 0.1); color: #a8342b; border-color: var(--mk-danger); }
.alert-info { background: rgba(58, 158, 165, 0.12); color: #1f6f74; border-color: var(--mk-brand-3); }
[data-theme="dark"] .alert-success { color: #7fd9a8; }
[data-theme="dark"] .alert-warning { color: #ffd98a; }
[data-theme="dark"] .alert-danger { color: #ff9c93; }
[data-theme="dark"] .alert-info { color: #9fd6d9; }

/* ============ Modal ============ */
.modal { background: rgba(12, 30, 31, 0.55); backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px); }
.modal-content {
    border-radius: 22px;
    padding: 24px 24px 18px;
    border: 1px solid rgba(32, 92, 94, 0.08);
    box-shadow: var(--mk-shadow-lg);
    animation: akPop 0.22s ease;
}
@keyframes akPop { from { transform: translateY(12px) scale(0.985); opacity: 0; } to { transform: none; opacity: 1; } }
.modal-header { border-bottom: 1px solid var(--border-color); padding-bottom: 12px; margin-bottom: 16px; }
.modal-header h2, .modal-header h3 { color: var(--mk-brand); font-weight: 800; margin: 0; font-size: 1.2rem; }
[data-theme="dark"] .modal-header h2, [data-theme="dark"] .modal-header h3 { color: #9fd6d9; }
.close {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 1.4rem;
    color: var(--text-secondary);
    background: var(--bg-secondary);
    transition: background 0.2s, color 0.2s;
}
.close:hover { background: rgba(208, 69, 59, 0.12); color: var(--mk-danger); }
.modal-footer { border-top: 1px solid var(--border-color); padding-top: 14px; margin-top: 10px; display: flex; gap: 10px; flex-wrap: wrap; }

/* ============ Searchable select ============ */
.ss-display { border-radius: 12px !important; border-width: 1.5px !important; }
.ss-panel { border-radius: 14px !important; box-shadow: var(--mk-shadow-lg) !important; border-color: var(--border-color) !important; }

/* ============ Pagination ============ */
.pagination-bar a, .pagination-bar span, .pagination a, .pagination span {
    border-radius: 10px !important;
}

/* ============ Footer + M2 signature ============ */
.footer {
    background: linear-gradient(135deg, #153b3d, #205c5e);
    color: #e8f4f5;
    padding: 22px 0 18px;
    margin-top: 26px;
}
.footer-inner {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 22px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    text-align: center;
}
.footer-app { font-size: 0.88rem; color: rgba(232, 244, 245, 0.85); }
.footer-app strong { color: #fff; }
.footer-app .ver {
    display: inline-block;
    margin-inline-start: 6px;
    font-weight: 800;
    font-size: 0.75rem;
    color: #1b3a3b;
    background: var(--mk-gold);
    border-radius: 99px;
    padding: 1px 8px;
}
.footer #install-btn { margin-top: 4px; background: rgba(255, 255, 255, 0.14); color: #fff; }
.footer .m2-signature { margin-top: 10px; padding-top: 14px; width: 100%; max-width: 520px; }

.m2-signature {
    --m2-sig-text: #e8f4f5;
    --m2-sig-accent: #e0a526;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
    gap: 12px;
    margin-top: 26px;
    padding-top: 22px;
    border-top: 1px solid rgba(255, 255, 255, 0.12);
    font-size: 14px;
    letter-spacing: 0.2px;
    text-align: center;
}
.m2-signature__logo {
    display: inline-flex;
    align-items: center;
    line-height: 0;
    transition: opacity 0.25s ease, transform 0.25s ease;
}
.m2-signature__logo:hover { opacity: 0.85; transform: translateY(-2px); }
.m2-signature__logo img { height: 18px; width: auto; max-width: 52px; object-fit: contain; }
.m2-signature__mark {
    display: inline-flex;
    width: 16px;
    height: 16px;
    color: var(--m2-sig-accent);
    filter: drop-shadow(0 0 6px color-mix(in srgb, var(--m2-sig-accent) 55%, transparent));
    animation: m2-sig-pulse 3.4s ease-in-out infinite;
}
.m2-signature__mark svg { width: 100%; height: 100%; display: block; }
@keyframes m2-sig-pulse {
    0%, 100% { transform: scale(1) rotate(0deg); opacity: 0.9; }
    50% { transform: scale(1.12) rotate(45deg); opacity: 1; }
}
.m2-signature__tag, .m2-signature__tag strong { color: var(--m2-sig-text); font-size: 13px; }
.m2-signature__year { color: color-mix(in srgb, var(--m2-sig-text) 78%, transparent); font-size: 13px; }
@media (max-width: 575px) { .m2-signature { gap: 8px 10px; } }

/* ============ Dashboard ============ */
.dash-hero {
    position: relative;
    overflow: hidden;
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    flex-wrap: wrap;
    gap: 18px;
    color: #fff;
    border-radius: 26px;
    padding: 32px 30px;
    margin-bottom: 20px;
    background:
        radial-gradient(circle at 8% 120%, rgba(224, 165, 38, 0.4), transparent 42%),
        radial-gradient(circle at 100% 0%, rgba(255, 255, 255, 0.16), transparent 45%),
        linear-gradient(135deg, #184a4c 0%, #205c5e 45%, #2f7a7d 100%);
    box-shadow: 0 24px 60px rgba(20, 60, 62, 0.26);
}
.dash-hero::before {
    content: '';
    position: absolute;
    left: 30px;
    top: -60px;
    width: 200px;
    height: 200px;
    border: 30px solid rgba(255, 255, 255, 0.05);
    border-radius: 36px;
    transform: rotate(18deg);
}
.dash-hero > * { position: relative; z-index: 1; }
.dash-kicker {
    display: inline-block;
    font-size: 0.75rem;
    font-weight: 800;
    letter-spacing: 0.08em;
    color: #ffd98a;
    background: rgba(255, 255, 255, 0.14);
    padding: 5px 12px;
    border-radius: 99px;
}
.dash-hero h1 { margin: 10px 0 4px; font-size: 2rem; font-weight: 800; color: #fff; }
.dash-hero p { margin: 0; opacity: 0.88; font-weight: 600; }
.dash-hero-side { display: flex; gap: 10px; flex-wrap: wrap; }
.dash-chip {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.12);
    border: 1px solid rgba(255, 255, 255, 0.16);
    font-weight: 700;
    font-size: 0.9rem;
    color: #fff;
    text-decoration: none;
}
.dash-chip:hover { background: rgba(255, 255, 255, 0.2); color: #fff; }
.dash-chip b { color: #ffd98a; font-size: 1.1rem; }

.dash-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 16px; margin-bottom: 22px; }
.dash-stat {
    --c1: #205c5e; --c2: #2f7a7d;
    position: relative;
    overflow: hidden;
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 20px;
    border-radius: 22px;
    color: #fff;
    text-decoration: none;
    background: linear-gradient(145deg, var(--c1), var(--c2));
    box-shadow: 0 14px 34px rgba(20, 60, 62, 0.18);
    transition: transform 0.2s, box-shadow 0.2s;
}
.dash-stat::after {
    content: '';
    position: absolute;
    left: -30px;
    bottom: -40px;
    width: 120px;
    height: 120px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.08);
}
.dash-stat:hover { transform: translateY(-4px); box-shadow: 0 20px 44px rgba(20, 60, 62, 0.26); color: #fff; }
.dash-stat-icon {
    width: 52px;
    height: 52px;
    flex: none;
    border-radius: 16px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 1.3rem;
    background: rgba(255, 255, 255, 0.16);
}
.dash-stat-body { position: relative; z-index: 1; min-width: 0; }
.dash-stat-num { display: block; font-size: 2rem; font-weight: 800; line-height: 1.1; }
.dash-stat-label { font-weight: 700; font-size: 0.9rem; opacity: 0.92; }
.dash-stat small { display: block; font-size: 0.75rem; opacity: 0.75; }
.dash-stat.v2 { --c1: #2b3f40; --c2: #3e5859; }
.dash-stat.v3 { --c1: #c98a14; --c2: #e3ad3b; }
.dash-stat.v4 { --c1: #2f8f96; --c2: #3fb0b7; }
.dash-stat.v5 { --c1: #2e9d68; --c2: #43b981; }
.dash-stat.v6 { --c1: #b8483f; --c2: #d86a5f; }
.dash-stat.v7 { --c1: #7a5cc7; --c2: #9478da; }
.dash-stat.v8 { --c1: #1b4c4e; --c2: #3a9ea5; }

.dash-cols { display: grid; grid-template-columns: 2fr 1fr; gap: 18px; }
.dash-section-title { display: flex; align-items: center; gap: 10px; margin: 0 0 14px; font-size: 1.1rem; font-weight: 800; color: var(--text-primary); }
.dash-section-title i {
    width: 38px;
    height: 38px;
    border-radius: 12px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--mk-soft);
    color: var(--mk-brand);
}
.dash-actions { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.dash-action {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    padding: 18px 12px;
    border-radius: 18px;
    text-align: center;
    text-decoration: none;
    font-weight: 700;
    color: var(--text-primary);
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    transition: transform 0.18s, box-shadow 0.2s, border-color 0.2s, background 0.2s;
}
.dash-action i {
    width: 48px;
    height: 48px;
    border-radius: 15px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 1.15rem;
    color: #fff;
    background: linear-gradient(135deg, var(--mk-brand), var(--mk-brand-3));
    box-shadow: 0 8px 18px rgba(32, 92, 94, 0.25);
}
.dash-action:hover { transform: translateY(-3px); border-color: rgba(32, 92, 94, 0.3); box-shadow: var(--mk-shadow); color: var(--mk-brand); background: var(--bg-card); }
.dash-mk { display: flex; flex-direction: column; gap: 12px; }
.dash-mk-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 12px 14px; border-radius: 14px; background: var(--bg-secondary); font-weight: 700; }
.dash-mk-row b { font-size: 1.3rem; color: var(--mk-brand); }
[data-theme="dark"] .dash-mk-row b { color: #9fd6d9; }
.dash-mk-row span i { color: var(--mk-gold); margin-inline-end: 8px; }

/* ============ Misc ============ */
.text-muted { color: var(--text-secondary) !important; }
hr { border: 0; border-top: 1px solid var(--border-color); }

@media (max-width: 992px) {
    .dash-cols { grid-template-columns: 1fr; }
    .sb-link.active::before { display: none; }
}
@media (max-width: 640px) {
    .container { padding: 12px; }
    .main-content { padding: 16px; border-radius: 18px; }
    .page-header { padding: 18px; margin: -4px -4px 18px; border-radius: 16px; }
    .page-title { font-size: 1.25rem; }
    .topbar { padding: 12px 14px; }
    .tb-version, .theme-toggle #theme-text { display: none; }
    .dash-hero { padding: 24px 20px; border-radius: 20px; }
    .dash-hero h1 { font-size: 1.5rem; }
}

/* ============ Utilities (replace legacy inline styles) ============ */
.u-m-0 { margin: 0 !important; }
.u-mb-10 { margin-bottom: 10px; }
.u-mb-20 { margin-bottom: 20px; }
.u-mb-24 { margin-bottom: 24px; }
.u-center { text-align: center; }
.u-middle { vertical-align: middle; }
.u-rtl { direction: rtl; text-align: right; }
.u-fs-12 { font-size: 12px; }
.u-brand { color: var(--mk-brand); font-weight: 700; }
[data-theme="dark"] .u-brand { color: #9fd6d9; }
.u-form-actions { display: flex; justify-content: center; flex-wrap: wrap; gap: 10px; margin-top: 26px; }
.u-sep { padding-top: 18px; border-top: 1px solid var(--border-color); }
.u-empty { text-align: center; padding: 40px !important; color: var(--text-secondary); }
.u-row-between { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; gap: 10px; }
.u-inline-5 { display: flex; align-items: center; gap: 5px; }
.u-inline-10 { display: flex; align-items: center; gap: 10px; }
.u-wrap-5 { display: flex; gap: 5px; flex-wrap: wrap; }
.u-soft-bg { background: var(--bg-secondary); }
.u-row-total, .u-row-total td, .u-row-total th { font-weight: 800; background: var(--mk-soft); }
.u-chip-info { background: rgba(58, 158, 165, 0.14); color: #1f6f74; padding: 3px 9px; border-radius: 99px; }
[data-theme="dark"] .u-chip-info { color: #9fd6d9; }
.stat-card.u-grad-1 { background: linear-gradient(145deg, #205c5e, #2f7a7d); }
.stat-card.u-grad-2 { background: linear-gradient(145deg, #c98a14, #e3ad3b); }
.stat-card.u-grad-3 { background: linear-gradient(145deg, #2f8f96, #3fb0b7); }
.stat-card.u-grad-4 { background: linear-gradient(145deg, #2e9d68, #43b981); }
.stat-card.u-grad-5 { background: linear-gradient(145deg, #2b3f40, #3e5859); }

/* Dark-mode repair for remaining legacy inline colors */
[data-theme="dark"] [style*="background: #f8f9fa"], [data-theme="dark"] [style*="background:#f8f9fa"],
[data-theme="dark"] [style*="background: #fff"], [data-theme="dark"] [style*="background: white"],
[data-theme="dark"] [style*="background-color: #f8f9fa"], [data-theme="dark"] [style*="background: #e9ecef"] {
    background: var(--bg-secondary) !important;
}
[data-theme="dark"] [style*="color: #333"], [data-theme="dark"] [style*="color:#333"],
[data-theme="dark"] [style*="color: #666"], [data-theme="dark"] [style*="color:#666"],
[data-theme="dark"] [style*="color: #555"] {
    color: var(--text-secondary) !important;
}
[data-theme="dark"] [style*="border: 1px solid #eee"], [data-theme="dark"] [style*="border-top: 1px solid #eee"],
[data-theme="dark"] [style*="border: 1px solid #ddd"] {
    border-color: var(--border-color) !important;
}

.u-progress { position: relative; height: 20px; min-width: 90px; border-radius: 99px; overflow: hidden; background: var(--mk-soft); }
.u-progress-bar { height: 100%; border-radius: 99px; background: linear-gradient(90deg, var(--mk-brand), var(--mk-brand-3)); transition: width 0.3s ease; }
.u-progress-label { position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); font-size: 11px; font-weight: 800; color: var(--text-primary); }
[data-theme="dark"] .u-progress { background: rgba(255, 255, 255, 0.08); }

/* ============ Mobile refinements ============ */
@media (max-width: 768px) {
    .table-responsive-cards tbody td.td-actions .btn,
    .table-responsive-cards tbody td.td-actions .btn-sm {
        width: auto;
        flex: 1 1 calc(50% - 6px);
        min-width: 0;
        margin: 0;
    }
    .table-responsive-cards tbody td .u-progress { width: 100%; }
}
@media (max-width: 640px) {
    .page-header { flex-direction: column; align-items: stretch; }
    .page-header > div { display: flex; flex-wrap: wrap !important; gap: 8px; }
    .page-header > div > .btn, .page-header > .btn { flex: 1 1 auto; }
    .page-header .btn { white-space: nowrap; }
    .dash-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
    .dash-stat { flex-direction: column; align-items: flex-start; gap: 10px; padding: 14px; border-radius: 18px; }
    .dash-stat-icon { width: 40px; height: 40px; border-radius: 12px; font-size: 1rem; }
    .dash-stat-num { font-size: 1.55rem; }
    .dash-stat-label { font-size: 0.8rem; line-height: 1.35; }
    .dash-hero-side { width: 100%; }
    .dash-chip { flex: 1 1 auto; justify-content: center; }
    .dash-actions { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
    .dash-action { padding: 14px 8px; font-size: 0.88rem; }
    .card { padding: 16px; border-radius: 16px; }
    .modal-content { width: calc(100% - 20px); padding: 18px 16px 14px; border-radius: 18px; }
    .footer .m2-signature { max-width: 100%; }
}

/* ============ Login ============ */
body.login-page {
    min-height: 100vh;
    margin: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 28px 16px;
    font-family: 'Cairo', sans-serif;
    background:
        radial-gradient(circle at 10% 110%, rgba(224, 165, 38, 0.35), transparent 45%),
        radial-gradient(circle at 95% -5%, rgba(255, 255, 255, 0.14), transparent 40%),
        linear-gradient(135deg, #123638 0%, #205c5e 50%, #2f7a7d 100%);
    overflow-x: hidden;
}
[data-theme="dark"] body.login-page {
    background:
        radial-gradient(circle at 10% 110%, rgba(224, 165, 38, 0.2), transparent 45%),
        linear-gradient(135deg, #0a1819 0%, #10292a 55%, #173d3f 100%);
}
.lg-bg { position: fixed; inset: 0; pointer-events: none; overflow: hidden; }
.lg-orb { position: absolute; border-radius: 50%; filter: blur(2px); opacity: 0.5; animation: lg-float 14s ease-in-out infinite; }
.lg-orb-1 { width: 320px; height: 320px; top: -90px; left: -80px; background: radial-gradient(circle, rgba(58, 158, 165, 0.55), transparent 70%); }
.lg-orb-2 { width: 260px; height: 260px; bottom: -70px; right: -50px; background: radial-gradient(circle, rgba(224, 165, 38, 0.45), transparent 70%); animation-delay: -5s; }
.lg-orb-3 { width: 180px; height: 180px; top: 40%; right: 12%; background: radial-gradient(circle, rgba(255, 255, 255, 0.18), transparent 70%); animation-delay: -9s; }
@keyframes lg-float { 0%, 100% { transform: translate(0, 0); } 50% { transform: translate(18px, -22px); } }

.lg-theme {
    position: fixed;
    top: 18px;
    left: 18px;
    width: 42px;
    height: 42px;
    border-radius: 14px;
    border: 1px solid rgba(255, 255, 255, 0.22);
    background: rgba(255, 255, 255, 0.12);
    color: #fff;
    cursor: pointer;
    backdrop-filter: blur(8px);
    transition: background 0.2s ease, transform 0.2s ease;
    z-index: 2;
}
.lg-theme:hover { background: rgba(255, 255, 255, 0.22); transform: translateY(-1px); }

.lg-wrap { position: relative; z-index: 1; width: 100%; max-width: 420px; display: flex; flex-direction: column; align-items: center; }
.lg-card {
    width: 100%;
    background: var(--bg-card, #fff);
    border-radius: 26px;
    padding: 34px 30px 26px;
    box-shadow: 0 30px 80px rgba(8, 30, 31, 0.35);
    border: 1px solid rgba(255, 255, 255, 0.6);
}
[data-theme="dark"] .lg-card { border-color: var(--border-color); }
.lg-brand { text-align: center; margin-bottom: 24px; }
.lg-logo {
    width: 84px;
    height: 84px;
    margin: 0 auto 14px;
    border-radius: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--mk-grad);
    box-shadow: 0 14px 30px rgba(32, 92, 94, 0.35);
}
.lg-logo img { max-width: 62px; max-height: 62px; object-fit: contain; }
.lg-title { margin: 0; font-size: 1.8rem; font-weight: 800; color: var(--mk-brand); display: inline-flex; align-items: center; gap: 8px; }
[data-theme="dark"] .lg-title { color: #e3eeee; }
.lg-ver { font-size: 0.72rem; font-weight: 800; color: #1b3a3b; background: var(--mk-gold); border-radius: 99px; padding: 2px 9px; }
.lg-sub { margin: 6px 0 0; color: var(--text-secondary); font-size: 0.95rem; }

.lg-alert { display: flex; align-items: center; gap: 8px; padding: 11px 14px; border-radius: 14px; font-size: 0.9rem; margin-bottom: 16px; }
.lg-alert-err { background: rgba(208, 69, 59, 0.1); color: var(--mk-danger); border: 1px solid rgba(208, 69, 59, 0.25); }
.lg-alert-ok { background: rgba(46, 157, 104, 0.1); color: var(--mk-ok); border: 1px solid rgba(46, 157, 104, 0.25); }

.lg-form { display: flex; flex-direction: column; gap: 16px; }
.lg-field { display: flex; flex-direction: column; gap: 6px; text-align: right; }
.lg-label { font-weight: 700; font-size: 0.9rem; color: var(--text-primary); }
.lg-input {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 0 14px;
    border-radius: 14px;
    border: 1.5px solid var(--border-color);
    background: var(--bg-secondary);
    transition: border-color 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}
.lg-input:focus-within { border-color: var(--mk-brand-3); background: var(--bg-card, #fff); box-shadow: 0 0 0 4px rgba(58, 158, 165, 0.16); }
.lg-input > i { color: var(--mk-brand-3); width: 16px; text-align: center; }
.lg-input input {
    flex: 1;
    min-width: 0;
    border: 0;
    outline: 0;
    background: transparent;
    padding: 14px 0;
    font: inherit;
    font-size: 1rem;
    color: var(--text-primary);
}
.lg-eye { border: 0; background: transparent; color: var(--text-secondary); cursor: pointer; padding: 6px; border-radius: 8px; }
.lg-eye:hover { color: var(--mk-brand); }
.lg-submit {
    margin-top: 6px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    width: 100%;
    padding: 14px;
    border: 0;
    border-radius: 14px;
    font: inherit;
    font-size: 1.05rem;
    font-weight: 800;
    color: #fff;
    background: var(--mk-grad);
    box-shadow: 0 14px 28px rgba(32, 92, 94, 0.3);
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}
.lg-submit:hover { transform: translateY(-2px); box-shadow: 0 18px 34px rgba(32, 92, 94, 0.38); }
.lg-install {
    display: none;
    width: 100%;
    margin-top: 12px;
    padding: 10px;
    border-radius: 12px;
    border: 1.5px dashed var(--mk-brand-3);
    background: transparent;
    color: var(--mk-brand);
    font: inherit;
    font-weight: 700;
    cursor: pointer;
}
[data-theme="dark"] .lg-install { color: #e3eeee; }

.lg-rights { margin: 22px 0 0; color: rgba(232, 244, 245, 0.85); font-size: 0.88rem; text-align: center; }
.lg-sig { margin-top: 12px; padding-top: 12px; width: 100%; }

@media (max-width: 480px) {
    body.login-page { align-items: flex-start; padding-top: 72px; }
    .lg-card { padding: 28px 20px 22px; border-radius: 22px; }
    .lg-title { font-size: 1.55rem; }
}
.lg-logo { background: #fff; border: 1px solid var(--border-color); box-shadow: 0 14px 30px rgba(32, 92, 94, 0.18); }
.lg-logo { width: auto; height: auto; display: inline-flex; padding: 14px 22px; border-radius: 20px; }
.lg-logo img { max-width: 190px; max-height: 58px; }

/* ============ Mobile: filters, stat tiles, permissions ============ */
@media (max-width: 640px) {
    /* GET filter forms -> 2-column grid */
    form.form-row[method="get" i] {
        display: grid !important;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 12px 10px !important;
        align-items: end !important;
    }
    form.form-row[method="get" i] > .form-col {
        width: auto !important;
        min-width: 0 !important;
        max-width: none !important;
        margin: 0 !important;
        flex: none !important;
    }
    form.form-row[method="get" i] > .form-col:has(input[type="text"], input[type="search"]),
    form.form-row[method="get" i] > .form-col:has(> .btn),
    form.form-row[method="get" i] > .form-col:only-child {
        grid-column: 1 / -1;
    }
    form.form-row[method="get" i] > .form-col:has(> .btn) {
        display: flex !important;
        flex-wrap: wrap;
        gap: 8px !important;
    }
    form.form-row[method="get" i] > .form-col > .btn { flex: 1 1 0; justify-content: center; margin: 0; }
    form.form-row[method="get" i] .form-label { display: flex; align-items: center; gap: 6px; font-size: 0.82rem; margin-bottom: 5px; text-align: right; }
    form.form-row[method="get" i] .form-control,
    form.form-row[method="get" i] .ss-wrap,
    form.form-row[method="get" i] .ss-display { width: 100% !important; min-width: 0; }
    form.form-row[method="get" i] .form-control { padding: 10px 12px; font-size: 0.9rem; }

    /* Stat tiles -> 2x2 like dashboard */
    .row:has(> [class*="col-"] > .stat-card),
    .stats-container,
    .stats-grid-6 {
        display: grid !important;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 10px !important;
        margin-inline: 0 !important;
    }
    .row:has(> [class*="col-"] > .stat-card) > [class*="col-"] {
        width: auto !important;
        max-width: none !important;
        flex: none !important;
        padding: 0 !important;
        margin: 0 !important;
    }
    .row:has(> [class*="col-"] > .stat-card) .stat-card,
    .stats-container .stat-card,
    .stats-grid-6 .stat-card {
        height: 100%;
        margin: 0 !important;
        min-height: 104px;
        padding: 16px 14px !important;
        border-radius: 18px;
        display: flex;
        flex-direction: column;
        justify-content: flex-end;
        align-items: flex-start;
        text-align: right;
        gap: 4px;
    }
    .row:has(> [class*="col-"] > .stat-card) .stat-value,
    .stats-container .stat-value,
    .stats-grid-6 .stat-value { font-size: 1.45rem !important; line-height: 1.2; margin: 0 !important; word-break: break-word; }
    .row:has(> [class*="col-"] > .stat-card) .stat-label,
    .stats-container .stat-label,
    .stats-grid-6 .stat-label { font-size: 0.78rem !important; line-height: 1.4; margin: 0 !important; opacity: 0.92; }

    /* Month picker card (finance / hr) */
    .card > form.form-row[method="get" i]:has(input[type="month"]) > .form-col:has(> .btn) { grid-column: auto; }
    .card > form[method="post" i] > .btn:only-of-type { width: 100%; justify-content: center; }

    /* Weekly calendar toolbar */
    .week-cal-toolbar-row { flex-direction: column; align-items: stretch !important; gap: 12px !important; }
    .week-cal-form-inline, .week-cal-form-inline .form-col { width: 100%; min-width: 0; margin: 0; }
    .week-cal-form-inline .ss-wrap, .week-cal-form-inline .ss-display { width: 100%; }
    .week-cal-jump-row { display: flex; gap: 8px; }
    .week-cal-jump-row .form-control { flex: 1 1 auto; min-width: 0; width: auto; }
    .week-cal-nav { display: grid !important; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px !important; }
    .week-cal-nav .week-cal-range { grid-column: 1 / -1; order: -1; text-align: center; }
    .week-cal-nav .btn { justify-content: center; margin: 0; }
    .week-cal-nav .btn-info { grid-column: 1 / -1; }

    /* Page-header inline filters (client divisions) */
    .page-header > div:has(> form, > .u-inline-5) {
        display: grid !important;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 10px !important;
    }
    .page-header > div:has(> form, > .u-inline-5) > form { grid-column: 1 / -1; display: flex; gap: 8px; }
    .page-header > div:has(> form, > .u-inline-5) > form .form-control { flex: 1 1 auto; width: auto !important; min-width: 0; }
    .page-header > div:has(> form, > .u-inline-5) > .u-inline-5 { display: flex; flex-direction: column; align-items: stretch; gap: 4px; }
    .page-header > div:has(> form, > .u-inline-5) > .u-inline-5 label { color: var(--text-secondary) !important; font-size: 0.8rem; }
    .page-header > div:has(> form, > .u-inline-5) > .u-inline-5 .form-control { width: 100% !important; }
    .page-header > div:has(> form, > .u-inline-5) > .btn { justify-content: center; margin: 0; }

    /* Permissions matrix */
    #permissionsForm .table-container { margin: 0 !important; padding: 12px !important; }
    #permissionsForm table.table-responsive-cards tbody tr { padding: 0; overflow: hidden; }
    #permissionsForm table.table-responsive-cards tbody td {
        display: flex !important;
        align-items: center;
        justify-content: space-between;
        gap: 10px;
        padding: 10px 12px !important;
    }
    #permissionsForm table.table-responsive-cards tbody td:first-child {
        display: block !important;
        background: var(--mk-grad);
        color: #fff;
        padding: 12px 14px !important;
    }
    #permissionsForm table.table-responsive-cards tbody td:first-child::before { display: none; }
    #permissionsForm table.table-responsive-cards tbody td:first-child .text-muted { color: rgba(255, 255, 255, 0.75) !important; }
    #permissionsForm table.table-responsive-cards tbody td:first-child br { display: none; }
    #permissionsForm table.table-responsive-cards tbody td:first-child small { margin-inline-start: 6px; }
    #permissionsForm table.table-responsive-cards tbody td::before {
        flex: 0 0 34%;
        font-size: 0.78rem;
        line-height: 1.35;
        white-space: normal;
    }
    #permissionsForm .permission-checkboxes {
        flex: 1 1 auto;
        display: grid;
        grid-template-columns: repeat(4, minmax(0, 1fr));
        gap: 4px;
    }
    #permissionsForm .permission-checkboxes label {
        display: flex !important;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 3px;
        margin: 0 !important;
        padding: 6px 2px !important;
        border-radius: 10px;
        background: var(--bg-secondary);
        border: 1px solid var(--border-color);
        font-size: 10px !important;
        line-height: 1.2;
        text-align: center;
    }
    #permissionsForm .permission-checkboxes label:has(input:checked) { background: rgba(58, 158, 165, 0.14); border-color: var(--mk-brand-3); }
    #permissionsForm .permission-checkboxes input[type="checkbox"] { margin: 0 !important; transform: none; }
    #permissionsForm .permission-checkboxes label span { margin: 0 !important; display: flex; flex-direction: column; align-items: center; gap: 2px; }
}
@media (max-width: 640px) {
    .week-cal-nav .btn { white-space: nowrap; font-size: 0.82rem; padding: 9px 8px; }
    .page-header > div:has(> form, > .u-inline-5) > .u-inline-5 label { color: rgba(255, 255, 255, 0.85) !important; }
    .page-header > div:has(> form, > .u-inline-5) > form .btn { padding-inline: 14px; }
    .card > form.form-row[method="get" i]:has(input[type="month"]) { grid-template-columns: minmax(0, 1fr) auto; }
    .card > form.form-row[method="get" i]:has(input[type="month"]) .btn { white-space: nowrap; }
}
@media (max-width: 640px) {
    .card > form.form-row[method="get" i]:has(input[type="month"]) { grid-template-columns: minmax(0, 1fr); }
    .row:has(> [class*="col-"] > .stat-card) > [class*="col-"]:last-child:nth-child(odd),
    .stats-container > .stat-card:last-child:nth-child(odd),
    .stats-grid-6 > .stat-card:last-child:nth-child(odd) { grid-column: 1 / -1; }
}
@media (max-width: 640px) {
    form.form-row[method="get" i] > .form-col.fr-span-full { grid-column: 1 / -1; }
}
@media (max-width: 640px) {
    .page-header > div:has(> form, > .u-inline-5) { gap: 12px 10px !important; align-items: end; }
    .page-header > div:has(> form, > .u-inline-5) .form-control,
    .page-header > div:has(> form, > .u-inline-5) .btn {
        height: 44px;
        min-height: 44px;
        border-radius: 12px;
        font-size: 0.88rem;
        box-sizing: border-box;
    }
    .page-header > div:has(> form, > .u-inline-5) .form-control {
        padding: 0 12px;
        border: 1px solid rgba(255, 255, 255, 0.35);
        background-color: rgba(255, 255, 255, 0.96);
        color: #1f3536;
    }
    .page-header > div:has(> form, > .u-inline-5) > form { gap: 8px; align-items: center; }
    .page-header > div:has(> form, > .u-inline-5) > form .btn {
        flex: 0 0 auto;
        padding: 0 18px;
        font-weight: 800;
        background: var(--mk-gold);
        color: #1b3a3b;
        border: 0;
    }
    .page-header > div:has(> form, > .u-inline-5) > .u-inline-5 label { font-size: 0.78rem; font-weight: 700; margin: 0; }
    .page-header > div:has(> form, > .u-inline-5) > .btn {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        gap: 6px;
        padding: 0 10px;
        font-weight: 800;
        white-space: nowrap;
    }
    .page-header > div:has(> form, > .u-inline-5) > .btn-primary { background: #fff; color: var(--mk-brand); border: 0; }
    .page-header > div:has(> form, > .u-inline-5) > .btn-info { background: rgba(255, 255, 255, 0.14); color: #fff; border: 1px solid rgba(255, 255, 255, 0.35); }
}
@media (max-width: 640px) {
    .card > form.form-row[method="get" i]:has(input[type="month"]) { grid-template-columns: repeat(2, minmax(0, 1fr)) !important; align-items: end !important; }
    .card > form.form-row[method="get" i]:has(input[type="month"]) > .form-col,
    .card > form.form-row[method="get" i]:has(input[type="month"]) > .form-col.fr-span-full,
    .card > form.form-row[method="get" i]:has(input[type="month"]) > .form-col:has(> .btn) { grid-column: auto !important; }
    .card > form.form-row[method="get" i]:has(input[type="month"]) input[type="month"] {
        height: 44px;
        padding: 0 8px !important;
        font-size: 0.8rem !important;
        letter-spacing: -0.2px;
    }
    .card > form.form-row[method="get" i]:has(input[type="month"]) > .form-col:has(> .btn) > .btn {
        height: 44px;
        width: 100%;
        font-size: 0.85rem;
        white-space: nowrap;
    }
    .card > form.form-row[method="get" i]:has(input[type="month"]) + p {
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        font-size: 0.74rem !important;
        letter-spacing: -0.2px;
    }
}
@media (max-width: 640px) {
    .card > form.form-row[method="get" i]:has(input[type="month"]) { grid-template-columns: minmax(0, 1fr) !important; gap: 10px !important; }
    .card > form.form-row[method="get" i]:has(input[type="month"]) input[type="month"] {
        width: 100% !important;
        padding: 0 14px !important;
        font-size: 0.92rem !important;
        letter-spacing: normal;
        text-align: right;
    }
    .card > form.form-row[method="get" i]:has(input[type="month"]) > .form-col:has(> .btn) { display: block !important; }
    .card > form.form-row[method="get" i]:has(input[type="month"]) > .form-col:has(> .btn) > .btn { display: flex; width: 100%; justify-content: center; }
}

/* ============ Mobile: date range filter ============ */
@media (max-width: 640px) {
    .date-filter-container { padding: 16px 14px; border-width: 1px; border-radius: 18px; }
    .date-filter-header { margin-bottom: 12px; }
    .date-filter-title { font-size: 1rem; font-weight: 800; }
    .date-filter-form {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 10px;
        align-items: end;
    }
    .date-filter-col { min-width: 0; flex: none; }
    .date-filter-col .form-label { font-size: 0.82rem; margin-bottom: 5px; }
    .date-filter-col .form-control {
        width: 100%;
        min-width: 0;
        height: 44px;
        padding: 0 10px;
        font-size: 0.85rem;
        text-align: right;
        -webkit-appearance: none;
        appearance: none;
        box-sizing: border-box;
    }
    .date-filter-col input[type="date"]::-webkit-date-and-time-value { text-align: right; }
    .date-filter-actions { grid-column: 1 / -1; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
    .date-filter-actions .btn { height: 44px; margin: 0; justify-content: center; white-space: nowrap; }
    .date-quick-filters { gap: 6px; margin-top: 12px; padding-top: 12px; border-top: 1px dashed rgba(32, 92, 94, 0.25); }
    .date-quick-btn {
        flex: 1 1 auto;
        padding: 8px 10px;
        border-radius: 99px;
        font-family: inherit;
        font-size: 0.8rem;
        font-weight: 700;
        background: #fff;
        color: var(--mk-brand);
        border: 1px solid rgba(32, 92, 94, 0.3);
        white-space: nowrap;
    }
    .date-quick-btn:hover, .date-quick-btn:active { background: var(--mk-brand); color: #fff; }
    [data-theme="dark"] .date-quick-btn { background: var(--bg-card); color: #e3eeee; border-color: var(--border-color); }
}
.inv-pay-progress { margin-top: 8px; width: 120px; }
@media (max-width: 768px) {
    .table-responsive-cards tbody td > .inv-pay-progress { grid-column: 1 / -1; width: 100%; margin-top: 2px; }
    .table-responsive-cards tbody td > .inv-pay-progress .u-progress { width: 100%; height: 22px; }
}

/* ============ Invoice payments view ============ */
.pay-view { display: flex; flex-direction: column; gap: 16px; }
.pay-sec { background: var(--bg-secondary); border: 1px solid var(--border-color); border-radius: 16px; padding: 14px; }
.pay-sec-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 10px; }
.pay-sec-title { margin: 0 0 10px; font-size: 0.98rem; font-weight: 800; color: var(--mk-brand); display: flex; align-items: center; gap: 8px; }
.pay-sec-head .pay-sec-title { margin: 0; }
[data-theme="dark"] .pay-sec-title { color: #9fd6d9; }
.pay-count { font-size: 0.78rem; font-weight: 800; color: #fff; background: var(--mk-brand); border-radius: 99px; padding: 3px 10px; }
.pay-info { margin: 0 0 12px; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.pay-info > div { background: var(--bg-card, #fff); border-radius: 12px; padding: 10px 12px; min-width: 0; }
.pay-info dt { font-size: 0.75rem; font-weight: 700; color: var(--text-secondary); margin-bottom: 3px; }
.pay-info dd { margin: 0; font-weight: 800; color: var(--text-primary); overflow-wrap: anywhere; text-align: right; }
.pay-stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; margin-bottom: 12px; }
.pay-stat { background: var(--bg-card, #fff); border-radius: 12px; padding: 10px 12px; display: flex; flex-direction: column; gap: 2px; border-inline-start: 4px solid var(--mk-brand); min-width: 0; }
.pay-stat .v { font-weight: 800; font-size: 1rem; color: var(--mk-brand); overflow-wrap: anywhere; }
.pay-stat .v small { font-size: 0.7rem; font-weight: 700; }
.pay-stat .l { font-size: 0.75rem; color: var(--text-secondary); font-weight: 700; }
.pay-stat.is-ok { border-color: var(--mk-ok); } .pay-stat.is-ok .v { color: var(--mk-ok); }
.pay-stat.is-danger { border-color: var(--mk-danger); } .pay-stat.is-danger .v { color: var(--mk-danger); }
.pay-stat.is-info { border-color: var(--mk-brand-3); } .pay-stat.is-info .v { color: var(--mk-brand-3); }
[data-theme="dark"] .pay-stat .v { filter: brightness(1.25); }
.pay-progress { height: 22px; }
.pay-list { display: flex; flex-direction: column; gap: 10px; max-height: 420px; overflow-y: auto; }
.pay-item { background: var(--bg-card, #fff); border-radius: 14px; padding: 12px; border: 1px solid var(--border-color); }
.pay-item-top { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.pay-num { font-size: 0.75rem; font-weight: 800; color: var(--text-secondary); background: var(--bg-secondary); border-radius: 8px; padding: 2px 8px; }
.pay-amt { color: var(--mk-ok); font-size: 1.05rem; }
.pay-method { margin-inline-start: auto; font-size: 0.75rem; font-weight: 700; color: var(--mk-brand); background: rgba(58, 158, 165, 0.14); border-radius: 99px; padding: 3px 10px; }
.pay-item-meta { display: flex; flex-wrap: wrap; gap: 4px 14px; margin-top: 8px; font-size: 0.8rem; color: var(--text-secondary); }
.pay-item-meta i { color: var(--mk-brand-3); margin-inline-end: 3px; }
.pay-notes { margin: 8px 0 0; font-size: 0.85rem; background: var(--bg-secondary); border-radius: 10px; padding: 8px 10px; color: var(--text-primary); overflow-wrap: anywhere; }
.pay-item-actions { display: flex; justify-content: flex-end; margin-top: 10px; }
.pay-desc { margin: 0; line-height: 1.7; overflow-wrap: anywhere; }

@media (max-width: 640px) {
    .pay-info { grid-template-columns: minmax(0, 1fr); gap: 8px; }
    .pay-info > div { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; }
    .pay-info dt { margin: 0; flex: 0 0 auto; }
    .pay-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
    .pay-stat .v { font-size: 0.92rem; }
    .pay-sec { padding: 12px; }
}

/* ============ Mobile: modals (global) ============ */
@media (max-width: 640px) {
    .modal { padding: 0 !important; }
    .modal-content {
        width: calc(100% - 16px) !important;
        max-width: none !important;
        margin: 12px auto !important;
        max-height: calc(100dvh - 24px);
        overflow-y: auto;
        overflow-x: hidden;
        padding: 16px 14px 14px !important;
        border-radius: 18px;
        box-sizing: border-box;
    }
    .modal-header {
        position: sticky;
        top: -16px;
        z-index: 3;
        background: var(--bg-card, #fff);
        margin: -16px -14px 14px;
        padding: 14px 14px 10px;
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 10px;
    }
    .modal-header h2, .modal-header h3 { font-size: 1.02rem; line-height: 1.4; }
    .modal-header .close { flex: 0 0 auto; }
    .modal-content .row { margin-inline: 0 !important; }
    .modal-content [class*="col-"] { padding-inline: 0 !important; width: 100%; max-width: 100%; flex: 1 1 100%; }
    .modal-content .form-row { flex-direction: column; gap: 0; }
    .modal-content .form-col { width: 100%; min-width: 0 !important; }
    .modal-content .form-control, .modal-content .ss-wrap { width: 100% !important; max-width: 100%; box-sizing: border-box; }
    .modal-content table { min-width: 0 !important; }
    .modal-content .table-container, .modal-content .table-responsive { overflow-x: auto; max-width: 100%; }
    .modal-content img { max-width: 100%; height: auto; }
    .modal-content :is(p, span, strong, dd, td, label) { overflow-wrap: anywhere; }
    .modal-footer, .modal-content .form-actions { position: sticky; bottom: -14px; background: var(--bg-card, #fff); margin: 10px -14px -14px; padding: 12px 14px; z-index: 2; }
    .modal-footer .btn, .modal-content .form-actions .btn { flex: 1 1 auto; justify-content: center; }
}

/* ============ Bootstrap-compat utilities (API fragments) ============ */
.d-flex { display: flex; }
.flex-wrap { flex-wrap: wrap; }
.justify-content-between { justify-content: space-between; }
.justify-content-center { justify-content: center; }
.align-items-center { align-items: center; }
.align-items-start { align-items: flex-start; }
.text-end { text-align: left; }
.text-start { text-align: right; }
.text-center { text-align: center; }
.mb-0 { margin-bottom: 0 !important; } .mb-1 { margin-bottom: 4px; } .mb-2 { margin-bottom: 8px; } .mb-3 { margin-bottom: 14px; }
.mt-1 { margin-top: 4px; } .mt-2 { margin-top: 8px; } .mt-3 { margin-top: 14px; } .mt-4 { margin-top: 20px; }
.ms-2 { margin-inline-start: 8px; } .py-4 { padding-block: 20px; } .p-2 { padding: 8px; } .ps-3 { padding-inline-start: 12px; }
.fst-italic { font-style: italic; }
.text-primary { color: var(--mk-brand) !important; }
.text-success { color: var(--mk-ok) !important; }
.text-danger { color: var(--mk-danger) !important; }
.text-warning { color: var(--mk-warn) !important; }
.text-info { color: var(--mk-brand-3) !important; }
[data-theme="dark"] .text-primary { color: #9fd6d9 !important; }
.badge.bg-primary, .bg-primary.badge { background: var(--mk-brand) !important; color: #fff; }
.badge.bg-success { background: var(--mk-ok) !important; color: #fff; }
.badge.bg-danger { background: var(--mk-danger) !important; color: #fff; }
.badge.bg-warning { background: var(--mk-warn) !important; color: #fff; }
.badge.bg-info { background: var(--mk-brand-3) !important; color: #fff; }
.badge.bg-secondary { background: #7f9596 !important; color: #fff; }
.progress { display: flex; height: 20px; border-radius: 99px; overflow: hidden; background: var(--mk-soft); }
.progress-bar { height: 100%; display: flex; align-items: center; justify-content: center; color: #fff; font-size: 11px; font-weight: 800; background: linear-gradient(90deg, var(--mk-brand), var(--mk-brand-3)); transition: width 0.3s ease; }
.progress-bar.bg-success { background: var(--mk-ok); }
.progress-bar.bg-warning { background: var(--mk-warn); }
.progress-bar.bg-danger { background: var(--mk-danger); }
.modal-body h6 { font-size: 0.95rem; font-weight: 800; margin: 0 0 8px; }
.modal-body .card-header { padding: 10px 12px; border-radius: 12px 12px 0 0; background: var(--bg-secondary); }
.modal-body .card-body { padding: 12px; }
.table-borderless td, .table-borderless th { border: 0 !important; }
.table-sm td, .table-sm th { padding: 6px 8px !important; }

@media (max-width: 640px) {
    .modal-content .table-container { margin: 0 !important; padding: 0 !important; }
    .modal-content table { width: 100% !important; }
    .modal-body .card { padding: 0; margin-bottom: 12px; }
    .modal-body .card-header.d-flex { flex-wrap: wrap; gap: 6px; }
    .modal-body .row + .row, .modal-body [class*="col-"] + [class*="col-"] { margin-top: 10px; }
}
@media (max-width: 640px) {
    .modal-content table:not(.table-responsive-cards) { display: block; max-width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; white-space: nowrap; }
    .modal-content table:not(.table-responsive-cards) td { white-space: normal; min-width: 70px; }
}
.page-header .ph-label { font-weight: 700; color: rgba(255, 255, 255, 0.92); margin: 0; }

/* Gradient card headers (banner style) */
.card > .card-header[style*="gradient"] {
    padding: 16px 20px !important;
    border-radius: 14px;
    margin-bottom: 18px;
    border: 0;
    background: var(--mk-grad) !important;
    box-shadow: 0 10px 24px rgba(32, 92, 94, 0.18);
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.card > .card-header[style*="gradient"] :is(h3, h4, h5) { margin: 0; font-weight: 800; font-size: 1.1rem; color: #fff; }
.card > .card-header[style*="gradient"] small { color: rgba(255, 255, 255, 0.82); font-size: 0.85rem; }
