:root {
    --app-blue: #0d6efd;
    --app-blue-dark: #0b4fb3;
    --app-surface: #ffffff;
    --app-bg: #f4f8fd;
    --app-border: #dbe7f3;
    --app-text: #1f2a37;
    --app-muted: #6b7280;
    --sidebar-width: 286px;
}

* {
    box-sizing: border-box;
}

html,
body {
    min-height: 100%;
}

body {
    margin: 0;
    font-family: "Prompt", sans-serif;
    font-size: 14px;
    color: var(--app-text);
    background: var(--app-bg);
}

a {
    text-decoration: none;
}

.app-shell {
    min-height: 100vh;
    display: flex;
}

.app-sidebar {
    width: var(--sidebar-width);
    min-height: 100vh;
    background: linear-gradient(180deg, #075bc7 0%, #0d6efd 100%);
    color: #fff;
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 1040;
    padding: 18px 16px;
    transition: transform .2s ease;
}

.sidebar-close {
    display: none;
    position: absolute;
    top: 12px;
    right: 12px;
    width: 36px;
    height: 36px;
    align-items: center;
    justify-content: center;
    border: 1px solid rgba(255, 255, 255, .25);
    border-radius: 8px;
    color: #fff;
    background: rgba(255, 255, 255, .12);
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    color: #fff;
    padding: 10px 8px 18px;
    border-bottom: 1px solid rgba(255, 255, 255, .18);
}

.sidebar-brand:hover {
    color: #fff;
}

.sidebar-brand img {
    width: 46px;
    height: 46px;
    border-radius: 8px;
    object-fit: cover;
    background: #fff;
    padding: 4px;
}

.sidebar-brand strong,
.sidebar-brand small {
    display: block;
    line-height: 1.35;
}

.sidebar-brand small {
    opacity: .78;
    font-size: 12px;
    margin-top: 2px;
}

.sidebar-menu {
    padding: 14px 0 0;
}

.sidebar-link {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 10px;
    border: 0;
    color: rgba(255, 255, 255, .88);
    background: transparent;
    padding: 11px 12px;
    margin-bottom: 4px;
    border-radius: 8px;
    text-align: left;
    transition: background .18s ease, color .18s ease;
}

.sidebar-link i:first-child {
    width: 20px;
    text-align: center;
}

.sidebar-link:hover,
.sidebar-link.active {
    color: #fff;
    background: rgba(255, 255, 255, .16);
}

.sidebar-submenu {
    margin: 0 0 8px 30px;
}

.sidebar-submenu a {
    display: block;
    color: rgba(255, 255, 255, .78);
    font-size: 12px;
    padding: 8px 10px;
    border-radius: 8px;
    line-height: 1.45;
}

.sidebar-submenu a:hover,
.sidebar-submenu a.active {
    color: #fff;
    background: rgba(255, 255, 255, .13);
}

.app-main {
    width: 100%;
    min-height: 100vh;
    margin-left: var(--sidebar-width);
}

.app-topbar {
    height: 70px;
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 0 24px;
    background: var(--app-surface);
    border-bottom: 1px solid var(--app-border);
    position: sticky;
    top: 0;
    z-index: 1020;
}

.app-topbar h1 {
    margin: 0;
    font-size: 20px;
    font-weight: 600;
}

.icon-btn {
    width: 40px;
    height: 40px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--app-border);
    border-radius: 8px;
    background: #fff;
    color: var(--app-blue-dark);
}

.user-menu {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
    border: 0;
    background: transparent;
    color: var(--app-text);
}

.avatar {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: #e7f0ff;
    color: var(--app-blue-dark);
    font-weight: 700;
    overflow: hidden;
}

.avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.user-meta {
    display: block;
    text-align: left;
    line-height: 1.25;
}

.user-meta strong,
.user-meta small {
    display: block;
    max-width: 180px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.user-meta small {
    color: var(--app-muted);
    margin-top: 3px;
}

.content-wrap {
    padding: 24px;
}

.page-card {
    background: #fff;
    border: 1px solid var(--app-border);
    border-radius: 8px;
    box-shadow: 0 8px 24px rgba(15, 23, 42, .04);
}

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

.page-card-header h2 {
    font-size: 17px;
    font-weight: 600;
    margin: 0;
}

.page-card-body {
    padding: 20px;
}

.table-toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
}

.table-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
    justify-content: flex-end;
}

.filter-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(150px, 1fr));
    gap: 10px;
    margin-bottom: 16px;
}

.table-responsive {
    width: 100%;
}

.form-label {
    font-weight: 500;
    color: #344054;
}

.form-control,
.form-select {
    border-radius: 8px;
    border-color: var(--app-border);
    min-height: 42px;
    font-size: 14px;
}

.btn {
    border-radius: 8px;
    font-size: 14px;
    min-height: 36px;
    padding: .375rem .75rem;
}

.btn-sm {
    min-height: 30px;
    padding: .25rem .5rem;
}

.btn-primary {
    background: var(--app-blue);
    border-color: var(--app-blue);
}

.badge {
    font-weight: 500;
}

.empty-state {
    min-height: calc(100vh - 140px);
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    flex-direction: column;
    gap: 10px;
    color: var(--app-muted);
}

.empty-icon {
    width: 64px;
    height: 64px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    background: #e7f0ff;
    color: var(--app-blue);
    font-size: 28px;
}

.empty-state h2 {
    color: var(--app-text);
    font-size: 20px;
    margin: 6px 0 0;
}

.profile-hero {
    display: grid;
    grid-template-columns: 260px minmax(0, 1fr);
    gap: 20px;
}

.profile-photo-card {
    background: #fff;
    border: 1px solid var(--app-border);
    border-radius: 8px;
    padding: 22px;
    text-align: center;
    box-shadow: 0 8px 24px rgba(15, 23, 42, .04);
}

.profile-photo {
    width: 116px;
    height: 116px;
    margin: 0 auto 14px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #0d6efd, #14b8a6);
    color: #fff;
    font-size: 52px;
    font-weight: 700;
    overflow: hidden;
}

.table-avatar {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    background: #e7f0ff;
    color: var(--app-blue-dark);
    font-weight: 700;
}

.table-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.profile-avatar-lg {
    width: 84px;
    height: 84px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    background: #e7f0ff;
    color: var(--app-blue-dark);
    font-size: 34px;
    font-weight: 700;
    flex: 0 0 auto;
}

.profile-avatar-lg img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.drag-handle {
    cursor: grab;
    color: var(--app-muted);
}

.sortable-row.dragging {
    opacity: .45;
}

.profile-photo img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.profile-preview {
    width: 116px;
    height: 116px;
    border-radius: 50%;
    border: 1px solid var(--app-border);
    object-fit: cover;
    background: #fff;
    padding: 4px;
}

.profile-name {
    font-size: 20px;
    font-weight: 700;
    color: var(--app-text);
}

.profile-position {
    color: var(--app-muted);
    margin-top: 4px;
}

.info-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
}

.info-item {
    border: 1px solid var(--app-border);
    border-radius: 8px;
    padding: 14px 16px;
    background: #fff;
}

.info-label {
    color: var(--app-muted);
    font-size: 12px;
    margin-bottom: 5px;
}

.info-value {
    font-weight: 600;
    overflow-wrap: anywhere;
}

.header-table th {
    white-space: nowrap;
}

.app-loading-overlay {
    position: fixed;
    inset: 0;
    z-index: 3000;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, .72);
}

.sticky-action-bar {
    position: sticky;
    bottom: 0;
    z-index: 1010;
    padding: 14px 0;
    background: linear-gradient(180deg, rgba(244, 248, 253, 0), var(--app-bg) 35%);
}

.calendar-month-header {
    background: var(--app-blue);
    color: #fff;
    border-bottom: 0;
}

.calendar-card .card-body {
    background: #fbfdff;
}

.file-picker {
    display: flex;
    align-items: center;
    gap: 8px;
    border: 1px solid var(--app-border);
    border-radius: 8px;
    background: #fff;
    padding: 6px;
    min-height: 42px;
}

.file-picker-input {
    position: absolute;
    width: 1px;
    height: 1px;
    opacity: 0;
    pointer-events: none;
}

.file-picker-label {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    border-radius: 8px;
    padding: 6px 10px;
    background: #e7f0ff;
    color: var(--app-blue-dark);
    font-weight: 500;
    cursor: pointer;
    white-space: nowrap;
}

.file-picker-name {
    min-width: 0;
    color: var(--app-muted);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.searchable-select {
    position: relative;
}

.searchable-select-toggle {
    min-height: 38px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.searchable-select-menu {
    display: none;
    position: absolute;
    inset: calc(100% + 4px) 0 auto 0;
    z-index: 1060;
    overflow: hidden;
    border: 1px solid var(--app-border);
    border-radius: 8px;
    background: #fff;
}

.searchable-select.open .searchable-select-menu {
    display: block;
}

.searchable-select-options {
    max-height: 280px;
    overflow-y: auto;
}

.searchable-select-option {
    width: 100%;
    display: block;
    border: 0;
    border-bottom: 1px solid #edf2f7;
    background: #fff;
    padding: 9px 12px;
    text-align: left;
    color: var(--app-text);
}

.searchable-select-option:hover,
.searchable-select-option.active {
    background: #eef6ff;
    color: var(--app-blue-dark);
}

.searchable-select-option small {
    display: block;
    margin-top: 2px;
    color: var(--app-muted);
}

.logo-preview {
    width: 92px;
    height: 92px;
    border: 1px solid var(--app-border);
    border-radius: 8px;
    object-fit: contain;
    background: #fff;
    padding: 8px;
}

.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background:
        radial-gradient(circle at top left, rgba(13, 110, 253, .15), transparent 32%),
        linear-gradient(135deg, #eef6ff 0%, #ffffff 46%, #edf5ff 100%);
}

.login-card {
    width: min(100%, 430px);
    background: #fff;
    border: 1px solid var(--app-border);
    border-radius: 8px;
    box-shadow: 0 18px 48px rgba(13, 82, 171, .12);
    padding: 28px;
}

.login-logo {
    width: 76px;
    height: 76px;
    display: block;
    margin: 0 auto 14px;
    object-fit: contain;
    border-radius: 8px;
    border: 1px solid var(--app-border);
    padding: 8px;
    background: #fff;
}

.login-title {
    text-align: center;
    margin-bottom: 24px;
}

.login-title h1 {
    font-size: 22px;
    font-weight: 700;
    margin: 0 0 6px;
    color: var(--app-blue-dark);
}

.login-title p {
    margin: 0;
    color: var(--app-muted);
}

.sidebar-backdrop {
    display: none;
}

.modal {
    --app-modal-space: 1rem;
}

.modal .modal-dialog {
    height: calc(100dvh - var(--app-modal-space));
    max-height: calc(100dvh - var(--app-modal-space));
    display: flex;
    align-items: stretch;
}

.modal .modal-content {
    max-height: 100%;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.modal .modal-content > form {
    max-height: 100%;
    min-height: 0;
    display: flex;
    flex: 1 1 auto;
    flex-direction: column;
    overflow: hidden;
}

.modal .modal-header,
.modal .modal-footer {
    flex: 0 0 auto;
}

.modal .modal-body {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
}

.pdf-preview-frame {
    width: 100%;
    height: min(72vh, 760px);
    min-height: 520px;
    border: 1px solid #dbe4f0;
    border-radius: 8px;
    background: #f8fafc;
}

.certificate-toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: flex-end;
}

.salary-certificate-preview {
    background: #f8fafc;
    border: 1px solid var(--app-border);
    border-radius: 8px;
    padding: 12px;
}

.slot-grid {
    display: grid;
    grid-template-columns: repeat(5, minmax(92px, 1fr));
    gap: 8px;
}

.slot-toggle {
    display: flex;
    align-items: center;
    gap: 6px;
    border: 1px solid var(--app-border);
    border-radius: 8px;
    padding: 8px;
    background: #fff;
}

@media (min-width: 576px) {
    .modal {
        --app-modal-space: 3.5rem;
    }
}

@media (max-width: 991.98px) {
    .app-sidebar {
        transform: translateX(-100%);
        padding-top: 58px;
    }

    body.sidebar-open .app-sidebar {
        transform: translateX(0);
    }

    .sidebar-close {
        display: inline-flex;
    }

    body.sidebar-open .sidebar-backdrop {
        display: block;
        position: fixed;
        inset: 0;
        background: rgba(15, 23, 42, .45);
        z-index: 1030;
    }

    .app-main {
        margin-left: 0;
    }

    .app-topbar {
        padding: 0 14px;
    }

    .content-wrap {
        padding: 16px;
    }

    .user-meta {
        display: none;
    }

    .profile-hero {
        grid-template-columns: 1fr;
    }

    .filter-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 575.98px) {
    .pdf-preview-frame {
        min-height: 420px;
    }

    .login-card {
        padding: 22px;
    }

    .app-topbar h1 {
        font-size: 17px;
    }

    .page-card-header,
    .page-card-body {
        padding: 16px;
    }

    .filter-grid,
    .info-grid {
        grid-template-columns: 1fr;
    }

    .table-toolbar {
        align-items: stretch;
        flex-direction: column;
    }

    .table-actions {
        justify-content: flex-start;
    }
}
