body {
    background: #f0f4f8;
    overflow-x: hidden;
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
}
#wrapper {
    min-height: 100vh;
    width: 100%;
    max-width: 100vw;
    overflow-x: hidden;
}
#sidebar-wrapper {
    flex: 0 0 260px;
    width: 260px;
    min-height: 100vh;
    transition: flex-basis .3s ease, width .3s ease, min-width .3s ease, opacity .3s ease, margin-left .3s ease;
    z-index: 1050;
    background: linear-gradient(180deg, #0f2744 0%, #1a3a5c 100%) !important;
    overflow-x: hidden;
}
#sidebar-wrapper .list-group-item.active {
    background: rgba(255,255,255,.15) !important;
    border-color: transparent !important;
    font-weight: 600;
}
#sidebar-wrapper .list-group-item:hover {
    background: rgba(255,255,255,.08) !important;
    transform: translateX(4px);
    transition: all .2s ease;
}
#page-content-wrapper {
    flex: 1 1 0;
    min-width: 0;
    width: auto;
    max-width: 100%;
}
.page-content { animation: fadeInOnly .4s ease; max-width: 100%; overflow-x: auto; }
.stat-card {
    border: none;
    border-radius: 16px;
    box-shadow: 0 4px 20px rgba(26,58,92,.08);
    transition: transform .25s ease, box-shadow .25s ease;
    background: #fff;
    overflow: hidden;
}
.stat-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 30px rgba(26,58,92,.12);
}
.stat-card .stat-icon {
    width: 52px; height: 52px;
    border-radius: 14px;
    display: flex; align-items: center; justify-content: center;
    font-size: 1.5rem;
}
.table th { font-weight: 600; font-size: .8rem; text-transform: uppercase; letter-spacing: .03em; color: #64748b; white-space: nowrap; }
.page-header { margin-bottom: 1.5rem; }
.page-header h2 { color: #1a3a5c; font-weight: 700; font-size: 1.4rem; }
.card { border-color: #dee2e6; box-shadow: 0 4px 20px rgba(26,58,92,.06); border-radius: 16px; }
.btn-primary { background: linear-gradient(135deg, #1a3a5c, #2c5f8a); border: none; }
.btn-primary:hover { background: linear-gradient(135deg, #2c4a6e, #3a7ab8); transform: translateY(-1px); box-shadow: 0 4px 12px rgba(26,58,92,.3); }
.login-wrapper {
    min-height: 100vh;
    display: flex; align-items: center; justify-content: center;
    background: linear-gradient(135deg, #0f2744 0%, #1a3a5c 40%, #2c6eaa 100%);
    background-size: 200% 200%;
    animation: gradientShift 8s ease infinite;
    padding: 1rem;
}
.login-card {
    max-width: 420px; width: 100%;
    border-radius: 20px;
    box-shadow: 0 20px 60px rgba(0,0,0,.25);
    animation: fadeInUp .6s ease;
    border: 1px solid rgba(255,255,255,.1);
}
.table-responsive { -webkit-overflow-scrolling: touch; }
.navbar-top {
    backdrop-filter: blur(8px);
    position: sticky;
    top: 0;
    z-index: 1060;
    background: #fff;
    overflow: visible !important;
    display: flex;
    flex-wrap: nowrap;
    align-items: center;
    gap: 0.5rem;
}
.navbar-top .dropdown-menu {
    z-index: 1070 !important;
    box-shadow: 0 8px 30px rgba(0,0,0,.15);
}
.navbar-top .dropdown {
    position: static;
}
@media (min-width: 992px) {
    .navbar-top .dropdown {
        position: relative;
    }
}
#menu-toggle {
    flex-shrink: 0;
    min-width: 44px;
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.navbar-top .navbar-actions {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 0.35rem;
    flex-wrap: nowrap;
    flex-shrink: 1;
    min-width: 0;
}
@media (min-width: 768px) {
    .navbar-top .user-info {
        display: inline-flex !important;
        align-items: center;
        gap: 0.25rem;
    }
}
#page-content-wrapper {
    position: relative;
    overflow: visible;
}
/* Bootstrap modals must sit above sidebar/navbar */
body.modal-open { overflow: hidden; }
body.modal-open #sidebar-overlay { display: none !important; }
.modal-backdrop { z-index: 2050 !important; }
.modal { z-index: 2055 !important; }
.modal-dialog {
    margin: 1.75rem auto;
    max-width: calc(100vw - 2rem);
}
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.5);
    z-index: 1040;
}
#wrapper.toggled .sidebar-overlay { display: block; }
#sidebar-wrapper { z-index: 1050; }
.user-info {
    flex-shrink: 0;
    white-space: nowrap;
    overflow: visible;
    max-width: none;
    text-overflow: clip;
}
.action-btns { display: flex; flex-wrap: wrap; gap: .25rem; }
.notification-badge.pulse { animation: pulse 2s infinite; }
.notification-dropdown { min-width: min(320px, 92vw); border-radius: 12px; border: none; }
.notification-item { transition: background .2s; border-radius: 8px; margin: 2px 8px; }
.notification-item:hover { background: #f0f7ff; }
.alert-animate { animation: slideDown .4s ease; }
.success-toast { border-left: 4px solid #198754; }
.btn-submit-loading { position: relative; pointer-events: none; opacity: .85; }
.btn-submit-loading::after {
    content: '';
    width: 18px; height: 18px;
    border: 2px solid rgba(255,255,255,.3);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin .7s linear infinite;
    display: inline-block;
    margin-left: 8px;
    vertical-align: middle;
}
.form-control:focus, .form-select:focus {
    border-color: #2c6eaa;
    box-shadow: 0 0 0 .2rem rgba(44,110,170,.15);
}

@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(16px); }
    to { opacity: 1; transform: translateY(0); }
}
@keyframes fadeInOnly {
    from { opacity: 0; }
    to { opacity: 1; }
}
@keyframes slideDown {
    from { opacity: 0; transform: translateY(-12px); }
    to { opacity: 1; transform: translateY(0); }
}
@keyframes gradientShift {
    0%, 100% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
}
@keyframes pulse {
    0%, 100% { transform: translate(-50%, -50%) scale(1); }
    50% { transform: translate(-50%, -50%) scale(1.1); }
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Desktop sidebar collapse */
@media (min-width: 992px) {
    #wrapper.sidebar-collapsed #sidebar-wrapper {
        flex: 0 0 0;
        width: 0;
        min-width: 0;
        opacity: 0;
        pointer-events: none;
        overflow: hidden;
        border: none;
    }
    #wrapper.sidebar-collapsed #page-content-wrapper {
        flex: 1 1 100%;
        max-width: 100%;
    }
}

/* Auto-wrap tables inside cards for mobile scroll */
.card-body.p-0:not(:has(.table-responsive)) {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}
.table-responsive {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}
.table-responsive > .table {
    margin-bottom: 0;
    min-width: 560px;
}

@media (max-width: 991.98px) {
    #sidebar-wrapper {
        position: fixed;
        left: 0;
        top: 0;
        flex: none;
        width: min(280px, 85vw);
        margin-left: calc(-1 * min(280px, 85vw));
        height: 100vh;
        height: 100dvh;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }
    #wrapper.toggled #sidebar-wrapper { margin-left: 0; }
    #page-content-wrapper {
        flex: 1 1 100%;
        width: 100%;
        max-width: 100vw;
    }
    .page-header { flex-direction: column !important; align-items: flex-start !important; gap: .75rem; }
    .page-header .btn { width: 100%; }
    .navbar-top { padding-left: 0.75rem !important; padding-right: 0.75rem !important; }
    .navbar-top .user-info { display: none; }
    .navbar-top .navbar-actions .btn { padding: 0.35rem 0.5rem; }
    .navbar-top .notification-bell {
        min-width: 44px;
        min-height: 44px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }
    .container-fluid.p-4 { padding: 1rem !important; }
    body.sidebar-open { overflow: hidden; }
}

.password-toggle-group .password-toggle-btn {
    border-color: #1a3a5c;
    color: #1a3a5c;
    background: #e8f0fa;
    font-weight: 600;
    white-space: nowrap;
}
.password-toggle-group .password-toggle-btn:hover,
.password-toggle-group .password-toggle-btn:focus {
    background: #1a3a5c;
    color: #fff;
    border-color: #1a3a5c;
}
.request-details-table,
.request-details-table th,
.request-details-table td {
    border: 1px solid #64748b !important;
}
.request-details-table th {
    background: #e8f0fa;
    color: #1a3a5c;
    width: 32%;
    white-space: normal;
}
.approval-history-table,
.approval-history-table th,
.approval-history-table td {
    border: 1px solid #64748b !important;
}
.approval-history-table thead th {
    background: #1a3a5c;
    color: #fff;
}

#uvms-loading-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(15, 39, 68, .58);
    z-index: 4000;
    align-items: center;
    justify-content: center;
}
body.uvms-submitting #uvms-loading-overlay {
    display: flex;
}
.uvms-loading-box {
    text-align: center;
    color: #fff;
    font-weight: 600;
    font-size: 1.05rem;
}
.card.request-form-internal,
.card.request-form-internal > .card-body {
    background: #f4fbf7 !important;
    border-color: #198754 !important;
}
.card.request-form-outstation,
.card.request-form-outstation > .card-body {
    background: #f4f8fc !important;
    border-color: #2c6eaa !important;
}
.card.request-form-internal {
    border: 2px solid #198754 !important;
    box-shadow: 0 4px 20px rgba(25, 135, 84, .1);
}
.card.request-form-outstation {
    border: 2px solid #2c6eaa !important;
    box-shadow: 0 4px 20px rgba(26, 58, 92, .1);
}
.request-form-internal .request-form-banner.card-header {
    background: #198754 !important;
    color: #fff !important;
    border-bottom: none !important;
}
.request-form-outstation .request-form-banner.card-header {
    background: linear-gradient(135deg, #1a3a5c, #2c5f8a) !important;
    color: #fff !important;
    border-bottom: none !important;
}
.request-form-internal .form-label {
    color: #146c43;
}
.request-form-outstation .form-label {
    color: #1a3a5c;
}
.request-type-card {
    position: relative;
    display: flex;
    align-items: flex-start;
    gap: 0.9rem;
    width: 100%;
    min-height: 100%;
    margin: 0;
    padding: 1.1rem 1.15rem;
    cursor: pointer;
    border: 1px solid #dee2e6;
    border-radius: 16px;
    background: #fff;
    box-shadow: 0 4px 20px rgba(26, 58, 92, .06);
    transition: border-color .2s ease, background-color .2s ease, box-shadow .2s ease, opacity .2s ease, transform .2s ease;
}
.request-type-card:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 18px rgba(26, 58, 92, .1);
}
.request-type-radio {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}
.request-type-icon {
    flex: 0 0 48px;
    width: 48px;
    height: 48px;
    border-radius: 14px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 1.35rem;
}
.request-type-copy {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
    min-width: 0;
    padding-right: 1.5rem;
}
.request-type-title {
    font-weight: 700;
    font-size: .92rem;
    letter-spacing: .03em;
    color: #1a3a5c;
}
.request-type-code {
    font-size: .75rem;
    font-weight: 600;
    color: #64748b;
}
.request-type-desc {
    font-size: .82rem;
    color: #64748b;
    line-height: 1.4;
}
.request-type-check {
    position: absolute;
    top: 0.7rem;
    right: 0.7rem;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    display: none;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: .8rem;
}
.request-type-card.is-selected .request-type-check {
    display: inline-flex;
}
.request-type-internal .request-type-icon {
    background: #e8f6ee;
    color: #198754;
}
.request-type-outstation .request-type-icon {
    background: #e8f1f8;
    color: #2c6eaa;
}
.request-type-internal.is-selected {
    background: #e8f6ee;
    border: 2px solid #198754;
    box-shadow: 0 4px 16px rgba(25, 135, 84, .16);
    opacity: 1;
}
.request-type-internal.is-selected .request-type-check {
    background: #198754;
}
.request-type-internal.is-selected .request-type-title {
    color: #146c43;
}
.request-type-outstation.is-selected {
    background: #e8f1f8;
    border: 2px solid #2c6eaa;
    box-shadow: 0 4px 16px rgba(26, 58, 92, .16);
    opacity: 1;
}
.request-type-outstation.is-selected .request-type-check {
    background: #2c6eaa;
}
.request-type-outstation.is-selected .request-type-title {
    color: #1a3a5c;
}
.request-type-card:not(.is-selected) {
    opacity: .72;
    background: #fff;
    border-color: #dee2e6;
}
.field-autofilled {
    background: #d1fae5 !important;
    border-color: #059669 !important;
    color: #065f46;
}
.field-user-empty {
    background: #fff7ed !important;
    border-color: #fb923c !important;
}
.field-user-filled {
    background: #dbeafe !important;
    border-color: #3b82f6 !important;
}
