:root {
    /* Premium Cafe Theme */
    --primary: #3E2723;
    --primary-light: #5B4037;
    --accent: #D4AF37;
    --bg-main: #F8F9FA;
    --bg-card: #FFFFFF;
    --text-main: #2D3436;
    --text-muted: #636E72;
    --sidebar-bg: #1A1210;
    --sidebar-text: #E0E0E0;
    --sidebar-hover: rgba(255, 255, 255, 0.08);
    --success: #00B894;
    --danger: #D63031;
    --warning: #FDCB6E;
    --info: #0984E3;
    --border: #f0f0f0;
    --shadow: 0 4px 20px rgba(0, 0, 0, 0.03), 0 2px 4px rgba(0, 0, 0, 0.02);
    --radius-sm: 8px;
    --radius-md: 16px;
    --radius-lg: 24px;
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.theme-cafe {
    --primary: #3E2723;
    --primary-light: #5B4037;
    --accent: #D4AF37;
    --bg-main: #F8F9FA;
    --bg-card: #FFFFFF;
    --text-main: #2D3436;
    --text-muted: #636E72;
    --sidebar-bg: #1A1210;
    --sidebar-text: #E0E0E0;
    --sidebar-hover: rgba(255, 255, 255, 0.08);
    --success: #00B894;
    --danger: #D63031;
    --warning: #FDCB6E;
    --info: #0984E3;
    --border: #f0f0f0;
    --shadow: 0 4px 20px rgba(0, 0, 0, 0.03), 0 2px 4px rgba(0, 0, 0, 0.02);
}

.theme-dark {
    --bg-main: #121212;
    --bg-card: #1E1E1E;
    --text-main: #F5F5F5;
    --text-muted: #B0B0B0;
    --border: #2D2D2D;
    --shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.3);
    --primary: #EAB676;
    --primary-light: #F2C991;
    --accent: #7CC6FF;
    --sidebar-bg: #0E141B;
    --sidebar-text: #EAF1F7;
    --sidebar-hover: rgba(255, 255, 255, 0.06);
    --success: #18C29C;
    --danger: #FF6B6B;
    --warning: #F6C85F;
    --info: #4DA3FF;
}

.theme-light {
    --primary: #2D3436;
    --primary-light: #526066;
    --accent: #0984E3;
    --bg-main: #F5F7FB;
    --bg-card: #FFFFFF;
    --text-main: #1F2A37;
    --text-muted: #6B7280;
    --sidebar-bg: #F8F9FA;
    --sidebar-text: #2D3436;
    --sidebar-hover: rgba(0, 0, 0, 0.05);
    --border: #E5E7EB;
    --shadow: 0 10px 24px rgba(15, 23, 42, 0.06);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Inter', sans-serif;
}

body {
    background-color: var(--bg-main);
    color: var(--text-main);
    line-height: 1.6;
    overflow-x: hidden;
}

body,
.sidebar-nav,
.table-responsive,
.modal-body,
.select-options {
    scrollbar-width: thin;
}

.sidebar-nav {
    scrollbar-color: var(--accent) var(--sidebar-hover);
}

.table-responsive,
.modal-body,
.select-options {
    scrollbar-color: var(--primary-light) var(--bg-main);
}

.sidebar-nav::-webkit-scrollbar,
.table-responsive::-webkit-scrollbar,
.modal-body::-webkit-scrollbar,
.select-options::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}

.sidebar-nav::-webkit-scrollbar-track,
.table-responsive::-webkit-scrollbar-track,
.modal-body::-webkit-scrollbar-track,
.select-options::-webkit-scrollbar-track {
    border-radius: 999px;
}

.sidebar-nav::-webkit-scrollbar-track {
    background: var(--sidebar-hover);
}

.table-responsive::-webkit-scrollbar-track,
.modal-body::-webkit-scrollbar-track,
.select-options::-webkit-scrollbar-track {
    background: var(--bg-main);
}

.sidebar-nav::-webkit-scrollbar-thumb,
.table-responsive::-webkit-scrollbar-thumb,
.modal-body::-webkit-scrollbar-thumb,
.select-options::-webkit-scrollbar-thumb {
    border-radius: 999px;
    border: 2px solid transparent;
    background-clip: padding-box;
    transition: var(--transition);
}

.sidebar-nav::-webkit-scrollbar-thumb {
    background-color: var(--accent);
}

.table-responsive::-webkit-scrollbar-thumb,
.modal-body::-webkit-scrollbar-thumb,
.select-options::-webkit-scrollbar-thumb {
    background: linear-gradient(180deg, var(--primary-light), var(--primary));
}

.sidebar-nav::-webkit-scrollbar-thumb:hover {
    background-color: var(--primary-light);
}

.table-responsive::-webkit-scrollbar-thumb:hover,
.modal-body::-webkit-scrollbar-thumb:hover,
.select-options::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(180deg, var(--primary), var(--accent));
}

h1,
h2,
h3,
.brand-info h2 {
    font-family: 'Outfit', sans-serif;
    font-weight: 700;
}

.hidden {
    display: none !important;
}

/* Login */
.login-page {
    height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--sidebar-bg), var(--primary));
}

.login-card {
    background: var(--bg-card);
    padding: 3.5rem 2.5rem;
    border-radius: var(--radius-lg);
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    width: 100%;
    max-width: 400px;
}

/* Layout */
.app-layout {
    display: block;
    /* Removed grid for standard fixed sidebar layout */
    min-height: 100vh;
}

/* Sidebar */
.sidebar {
    width: 280px;
    height: 100vh;
    background: var(--sidebar-bg);
    color: var(--sidebar-text);
    position: fixed;
    top: 0;
    left: 0;
    display: flex;
    flex-direction: column;
    z-index: 1000;
    transition: var(--transition);
    overflow: hidden;
}

.sidebar-header {
    padding: 2.5rem 1.5rem;
    display: flex;
    align-items: center;
    gap: 1rem;
}

.sidebar-logo {
    font-size: 2rem;
    color: var(--accent);
    background: var(--sidebar-hover);
    padding: 0.6rem;
    border-radius: var(--radius-sm);
}

.brand-info h2 {
    font-size: 1.25rem;
}

.brand-info p {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.sidebar-nav {
    flex: 1;
    padding: 0 1rem;
    min-height: 0;
    overflow-y: auto;
    overscroll-behavior: contain;
    scrollbar-width: thin;
    padding-bottom: 1rem;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem 1.25rem;
    color: inherit;
    text-decoration: none;
    border-radius: var(--radius-md);
    margin-bottom: 0.5rem;
    transition: var(--transition);
    opacity: 0.7;
    font-weight: 500;
}

.nav-item:hover,
.nav-item.active {
    opacity: 1;
    background: var(--sidebar-hover);
}

.nav-item.active {
    background: var(--accent);
    color: #000;
    font-weight: 600;
}

.sidebar-bottom {
    padding: 1.5rem;
    border-top: 1px solid var(--sidebar-hover);
    margin-top: auto;
    flex-shrink: 0;
    background: var(--sidebar-bg);
    position: relative;
    z-index: 1;
}

.user-profile-bar {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    background: var(--sidebar-hover);
    padding: 0.75rem;
    border-radius: var(--radius-md);
    margin-top: 1rem;
}

.user-profile-bar img {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    object-fit: cover;
}

.user-info h4 {
    font-size: 0.85rem;
}

.user-info p {
    font-size: 0.7rem;
    opacity: 0.6;
}

/* Main Content */
.main-content {
    padding: 2rem 3rem;
    margin-left: 280px;
    /* Crucial offset */
    min-height: 100vh;
    transition: var(--transition);
    width: calc(100% - 280px);
}

.app-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 3rem;
}

.header-search {
    position: relative;
    width: 400px;
}

.header-search.header-search-select-mode {
    display: flex;
    align-items: center;
}

.header-search-field {
    position: relative;
    width: 100%;
}

#header-profile-select-wrap .custom-select {
    width: 100%;
}

#header-profile-select-wrap .select-trigger {
    min-height: 52px;
    border: none;
    padding-right: 5.75rem;
    background: var(--bg-card);
    box-shadow: var(--shadow);
}

#header-profile-select-wrap .custom-select.active .select-trigger {
    border: none;
    background: var(--bg-card);
    box-shadow: 0 0 0 2px color-mix(in srgb, var(--primary) 18%, transparent), var(--shadow);
}

.header-search-tag {
    position: absolute;
    right: 0.9rem;
    top: 50%;
    transform: translateY(-50%);
    padding: 0.28rem 0.6rem;
    border-radius: 999px;
    background: color-mix(in srgb, var(--primary) 12%, var(--bg-card));
    color: var(--primary);
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    pointer-events: none;
    z-index: 1;
}

.header-search input,
.header-search select {
    width: 100%;
    min-height: 52px;
    padding: 0.8rem 1rem 0.8rem 3rem;
    border: none;
    border-radius: var(--radius-md);
    background: var(--bg-card);
    box-shadow: var(--shadow);
    outline: none;
    color: var(--text-main);
    font: inherit;
}

.header-search select {
    padding-right: 5.75rem;
    appearance: none;
    cursor: pointer;
}

.header-search-field > i {
    position: absolute;
    left: 1.25rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 1.5rem;
    flex-wrap: wrap;
}

.theme-switch-group {
    background: var(--bg-card);
    padding: 0.4rem;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow);
    display: flex;
    gap: 4px;
}

.theme-btn {
    padding: 0.5rem 1.25rem;
    border: none;
    background: transparent;
    border-radius: 12px;
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 600;
    transition: var(--transition);
    color: var(--text-muted);
}

.theme-btn.active {
    background: var(--primary);
    color: white;
}

/* Stats Cards */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2.5rem;
}

.stat-card {
    background: var(--bg-card);
    padding: 1.5rem;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    min-height: 160px;
    transition: var(--transition);
    border: 1px solid var(--border);
}

.stat-card:hover {
    transform: translateY(-5px);
    border-color: var(--accent);
}

.stat-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
}

.stat-icon {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
}

.stat-trend {
    font-size: 0.75rem;
    font-weight: 600;
    padding: 0.2rem 0.5rem;
    border-radius: 20px;
}

.stat-info {
    margin-top: 1rem;
}

.stat-info h3 {
    font-size: 0.9rem;
    color: var(--text-muted);
    margin-bottom: 0.25rem;
    font-weight: 500;
}

.stat-value {
    font-size: 1.75rem;
    font-weight: 800;
    color: var(--text-main);
}

/* Dashboard Content */
.dashboard-middle {
    display: grid;
    grid-template-columns: 1.6fr 1fr;
    gap: 2rem;
    margin-bottom: 2.5rem;
}

.card {
    background: var(--bg-card);
    padding: 2rem;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

/* Weekly Chart */
.chart-container {
    height: 250px;
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    padding: 1rem 0;
}

.chart-bar-wrapper {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.75rem;
}

.chart-bar {
    width: 70%;
    max-width: 40px;
    background: var(--primary);
    border-radius: var(--radius-sm);
    transition: height 0.6s ease-in-out;
}

.chart-bar.weekend {
    opacity: 0.4;
}

.chart-label {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-muted);
}

/* Activity */
.activity-list {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

.activity-item {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.activity-icon {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    background: var(--bg-main);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    font-size: 0.9rem;
}

.activity-details {
    flex: 1;
}

.activity-details h4 {
    font-size: 0.9rem;
    margin-bottom: 2px;
}

.activity-details p {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.activity-time {
    text-align: right;
}

.time-val {
    display: block;
    font-size: 0.8rem;
    font-weight: 600;
}

/* Global Table Styles */
.table-responsive {
    width: 100%;
    overflow-x: auto;
    margin-top: 1rem;
    -webkit-overflow-scrolling: touch;
}

.salary-table-wrap {
    margin-top: 0;
}

.salary-table {
    min-width: 1120px;
}

.salary-row-actions {
    flex-wrap: wrap;
}

table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
    background: var(--bg-card);
}

th {
    padding: 1.25rem 1rem;
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--text-muted);
    background: var(--bg-main);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 2px solid var(--border);
}

td {
    padding: 1.25rem 1rem;
    font-size: 0.95rem;
    color: var(--text-main);
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}

tr:hover td {
    background-color: rgba(0, 0, 0, 0.01);
}

/* Status Badges */
.status-badge {
    padding: 0.5rem 1rem;
    border-radius: 30px;
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.5px;
}

.status-active {
    background: #E1F9F2;
    color: #00B894;
}

.status-inactive {
    background: #FFEBEE;
    color: #D63031;
}

/* Action Buttons */
.btn-icon {
    width: 40px;
    height: 40px;
    border-radius: 12px;
    border: 1px solid var(--border);
    background: var(--bg-card);
    color: var(--text-muted);
    cursor: pointer;
    transition: var(--transition);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-right: 5px;
}

.btn-icon:hover {
    background: var(--bg-main);
    color: var(--primary);
    border-color: var(--primary);
}

.btn-icon.text-danger:hover {
    color: white;
    background: var(--danger);
    border-color: var(--danger);
}

/* Specific to Staff Grid in Dashboard */
.staff-overview table {
    width: 100%;
}

.employee-cell {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.employee-avatar {
    width: 36px;
    height: 36px;
    border-radius: 10px;
}

/* Buttons */
.btn-primary {
    background: var(--primary);
    color: white;
    border: none;
    padding: 0.75rem 1.5rem;
    border-radius: var(--radius-md);
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.btn-outline {
    background: transparent;
    border: 1.5px solid var(--border);
    color: var(--text-main);
    padding: 0.6rem 1.2rem;
    border-radius: var(--radius-md);
    font-weight: 600;
    cursor: pointer;
}

.btn-outline:hover {
    background: var(--bg-main);
}

/* Modal Improvements */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}

.modal-card {
    background: var(--bg-card);
    padding: 2.5rem;
    border-radius: var(--radius-lg);
    width: 95%;
    max-width: 550px;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    animation: modalSlide 0.3s ease-out;
}

@keyframes modalSlide {
    from {
        transform: translateY(30px);
        opacity: 0;
    }

    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border);
}

.modal-header h3 {
    font-size: 1.5rem;
    color: var(--primary);
}

.modal-body {
    overflow-y: auto;
    padding-right: 8px;
    /* Space for scrollbar */
    flex: 1;
}

.close-modal {
    background: var(--bg-main);
    border: none;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: var(--text-muted);
    transition: var(--transition);
}

.close-modal:hover {
    background: var(--danger);
    color: white;
}

/* Form Styling */
.input-group {
    margin-bottom: 1.5rem;
}

.input-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 600;
    font-size: 0.85rem;
    color: var(--text-main);
}

.input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

.input-wrapper i {
    position: absolute;
    left: 1.25rem;
    color: var(--text-muted);
    font-size: 0.9rem;
    pointer-events: none;
    z-index: 5;
}

.input-wrapper input,
.input-wrapper select {
    width: 100%;
    padding: 0.75rem 1rem 0.75rem 3rem;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-md);
    background: var(--bg-main);
    color: var(--text-main);
    font-size: 0.95rem;
    transition: var(--transition);
    outline: none;
}

.input-wrapper input:focus,
.input-wrapper select:focus {
    border-color: var(--accent);
    background: white;
    box-shadow: 0 0 0 4px rgba(212, 175, 55, 0.1);
}

.grid-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
}

.mobile-nav-toggle {
    display: none;
    width: 44px;
    height: 44px;
    border: 1px solid var(--border);
    border-radius: 14px;
    background: var(--bg-card);
    color: var(--text-main);
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: var(--shadow);
}

.mobile-sidebar-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.35);
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: var(--transition);
    z-index: 990;
}

.mobile-sidebar-backdrop.active {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
}

.full-width {
    width: 100%;
}

/* Modal Body */
/* Custom Dropdown Styling */
.custom-select {
    position: relative;
    width: 100%;
}

.select-trigger {
    width: 100%;
    padding: 0.75rem 1rem 0.75rem 3rem;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-md);
    background: var(--bg-main);
    color: var(--text-main);
    font-size: 0.95rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: space-between;
    transition: var(--transition);
}

.select-trigger:after {
    content: '\f107';
    font-family: 'Font Awesome 6 Free';
    font-weight: 900;
    font-size: 0.8rem;
    color: var(--text-muted);
}

.custom-select.active .select-trigger {
    border-color: var(--accent);
    background: var(--bg-card);
    box-shadow: 0 0 0 4px rgba(212, 175, 55, 0.1);
}

.custom-select.active .select-trigger:after {
    transform: rotate(180deg);
}

.select-options {
    position: absolute;
    top: calc(100% + 5px);
    left: 0;
    width: 100%;
    background: var(--bg-card);
    border-radius: var(--radius-md);
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1);
    z-index: 2600;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: opacity 0.3s cubic-bezier(0.4, 0, 0.2, 1), transform 0.3s cubic-bezier(0.4, 0, 0.2, 1), visibility 0.3s;
    overflow-y: auto;
    overflow-x: hidden;
    max-height: 260px;
    border: 1px solid var(--border);
}

.select-search {
    position: sticky;
    top: 0;
    z-index: 2;
    display: flex;
    align-items: center;
    gap: 0.7rem;
    padding: 0.8rem 0.9rem;
    background: color-mix(in srgb, var(--bg-card) 88%, var(--bg-main));
    border-bottom: 1px solid var(--border);
    backdrop-filter: blur(10px);
}

.select-search i {
    color: var(--text-muted);
    font-size: 0.85rem;
}

.select-search-input {
    width: 100%;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--bg-main);
    color: var(--text-main);
    padding: 0.7rem 0.9rem;
    outline: none;
    font: inherit;
    transition: var(--transition);
}

.select-search-input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 16%, transparent);
}

.select-options.select-options-floating {
    position: fixed;
    top: 0;
    left: 0;
    width: auto;
}

.select-options.select-options-portal {
    position: absolute;
}

.custom-select.open-up .select-options {
    top: auto;
    bottom: calc(100% + 5px);
    transform: translateY(10px);
}

.custom-select.active .select-options {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.select-options.select-options-floating.active {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.select-options.select-options-floating.open-up {
    transform: translateY(10px);
}

.select-options.select-options-floating.open-up.active {
    transform: translateY(0);
}

.custom-select.open-up.active .select-options {
    transform: translateY(0);
}

.select-option {
    padding: 0.75rem 1.25rem;
    cursor: pointer;
    font-size: 0.9rem;
    transition: var(--transition);
    border-bottom: 1px solid var(--bg-main);
}

.select-option:last-child {
    border-bottom: none;
}

.select-option:hover {
    background: var(--bg-main);
    color: var(--primary);
    padding-left: 1.5rem;
}

.select-option.selected {
    background: var(--primary);
    color: white;
}

.select-option-empty {
    padding: 1rem 1.1rem;
    color: var(--text-muted);
    font-size: 0.9rem;
}

/* Badges */
.badge {
    padding: 0.25rem 0.75rem;
    border-radius: 12px;
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
}

.badge-success {
    background: #E1F9F2;
    color: #00B894;
}

.badge-warning {
    background: #FFF9E6;
    color: #F57F17;
}

.badge-info {
    background: #E3F2FD;
    color: #1976D2;
}

/* Attendance Tracking Specifics */
.attendance-toggle {
    display: flex;
    gap: 0.5rem;
}

.toggle-btn {
    padding: 0.5rem 1.5rem;
    border: 1px solid var(--border);
    border-radius: 25px;
    cursor: pointer;
    font-weight: 600;
    transition: var(--transition);
}

.toggle-btn.active[data-val="present"] {
    background: var(--success);
    color: white;
    border-color: var(--success);
}

.toggle-btn.active[data-val="absent"] {
    background: var(--danger);
    color: white;
    border-color: var(--danger);
}

/* Responsive */
@media (max-width: 1024px) {
    .sidebar {
        width: 80px;
    }

    .sidebar .brand-info,
    .sidebar span,
    .sidebar .user-info {
        display: none;
    }

    .main-content {
        margin-left: 80px;
        width: calc(100% - 80px);
        padding: 1.75rem;
    }

    .dashboard-middle {
        grid-template-columns: 1fr;
    }

    .app-header {
        gap: 1rem;
        align-items: flex-start;
    }

    .header-search {
        width: min(100%, 420px);
    }
}

@media (max-width: 900px) {
    .sidebar {
        left: 0;
        width: min(82vw, 300px);
        height: 100dvh;
        max-height: 100dvh;
        display: grid;
        grid-template-rows: auto minmax(0, 1fr) auto;
        transform: translateX(-100%);
        box-shadow: 0 20px 40px rgba(0, 0, 0, 0.18);
    }

    .sidebar .brand-info,
    .sidebar .nav-item span,
    .sidebar .user-info {
        display: block !important;
        visibility: visible !important;
        opacity: 1 !important;
    }

    .sidebar-header {
        padding: 1.2rem 1rem 1rem;
        gap: 0.85rem;
        align-items: flex-start;
    }

    .sidebar-logo {
        font-size: 1.6rem;
        padding: 0.55rem;
    }

    .brand-info {
        min-width: 0;
    }

    .brand-info h2 {
        font-size: 1.1rem;
        line-height: 1.15;
        overflow-wrap: anywhere;
    }

    .brand-info p {
        font-size: 0.72rem;
        margin-top: 0.2rem;
        overflow-wrap: anywhere;
    }

    .sidebar-nav {
        min-height: 0;
        padding: 0 0.75rem 0.75rem;
    }

    .sidebar-bottom {
        margin-top: 0;
        padding: 0.9rem 0.75rem calc(0.9rem + env(safe-area-inset-bottom, 0px));
    }

    .nav-item {
        display: flex !important;
        justify-content: flex-start;
        min-height: 52px;
        opacity: 1;
        gap: 0.9rem;
        margin-bottom: 0.4rem;
        padding: 0.9rem 1rem;
    }

    .nav-item i {
        width: 1.25rem;
        text-align: center;
        flex-shrink: 0;
    }

    .nav-item span {
        display: block !important;
        flex: 1;
        min-width: 0;
    }

    .user-profile-bar {
        display: flex !important;
        margin-top: 0.75rem;
        min-width: 0;
    }

    .brand-info h2,
    .brand-info p,
    .user-info h4,
    .user-info p {
        display: block !important;
        visibility: visible !important;
        opacity: 1 !important;
    }

    .user-info h4,
    .user-info p {
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .main-content {
        margin-left: 0;
        width: 100%;
        padding: 1rem;
    }

    body.sidebar-open .sidebar {
        transform: translateX(0);
    }

    .mobile-nav-toggle {
        display: inline-flex;
        flex: 0 0 auto;
    }

    .app-header {
        flex-wrap: wrap;
        gap: 0.9rem;
        margin-bottom: 1.5rem;
        position: sticky;
        top: 0;
        z-index: 20;
        padding: 0.75rem;
        background: color-mix(in srgb, var(--bg-main) 88%, transparent);
        backdrop-filter: blur(10px);
        border-radius: 18px;
    }

    .header-search {
        order: 3;
        width: 100%;
    }

    .header-actions {
        width: calc(100% - 56px);
        justify-content: space-between;
        gap: 0.75rem;
    }

    .theme-switch-group {
        flex: 1;
        min-width: 0;
        overflow-x: auto;
        white-space: nowrap;
    }

    .theme-btn {
        flex: 1 0 auto;
        padding: 0.5rem 0.9rem;
    }

    .card,
    .modal-card {
        padding: 1.25rem;
    }

    .card-header,
    .view-header,
    .attendance-actions,
    .settings-tab-btn {
        gap: 0.75rem;
    }

    .card-header,
    .view-header,
    .attendance-actions {
        flex-wrap: wrap;
    }

    .grid-2,
    .detail-grid,
    .stats-grid {
        grid-template-columns: 1fr;
    }

    .settings-tab-btn {
        min-width: 180px;
    }

    #settings-tab-content > div[style*="grid-template-columns: 280px 1fr"],
    #view-container div[style*="grid-template-columns: 350px 1fr"],
    #view-container div[style*="grid-template-columns: 1fr 1fr"],
    #view-container div[style*="grid-template-columns: repeat(2, 1fr)"],
    #view-container div[style*="grid-template-columns: repeat(4, 1fr)"] {
        display: grid !important;
        grid-template-columns: 1fr !important;
    }

    #view-container div[style*="justify-content:space-between"] {
        flex-wrap: wrap;
    }

    .calendar-grid {
        grid-template-columns: repeat(7, minmax(38px, 1fr)) !important;
        overflow-x: auto;
        padding: 12px !important;
    }

    table {
        min-width: 760px;
    }

    .salary-table {
        min-width: 1040px;
    }

    .modal-card {
        width: calc(100% - 20px);
        max-width: none;
        max-height: calc(100vh - 20px);
        border-radius: 20px;
    }

    .modal-header {
        margin-bottom: 1rem;
        padding-bottom: 0.75rem;
    }

    .login-page {
        padding: 1rem;
        min-height: 100vh;
        height: auto;
    }

    .login-card {
        padding: 2rem 1.25rem;
        max-width: 100%;
    }

    .sidebar-bottom {
        padding: 1rem;
    }

    .sidebar-nav {
        padding: 0 0.75rem;
    }
}

@media (max-width: 640px) {
    .main-content {
        padding: 0.85rem;
    }

    .app-header {
        padding: 0.7rem;
        border-radius: 16px;
    }

    .header-actions {
        width: 100%;
    }

    .theme-switch-group {
        width: 100%;
    }

    .notification-btn {
        margin-left: auto;
    }

    .card {
        padding: 1rem;
        border-radius: 18px;
    }

    .stat-card {
        min-height: auto;
        padding: 1.1rem;
    }

    .stat-value {
        font-size: 1.45rem;
    }

    .btn-primary,
    .btn-outline {
        width: 100%;
        justify-content: center;
    }

    .btn-icon,
    .btn-icon-sm {
        flex-shrink: 0;
    }

    .nav-item {
        padding: 0.9rem 1rem;
    }

    .settings-tab-btn {
        min-width: 145px;
        font-size: 0.85rem;
    }

    th,
    td {
        padding: 0.9rem 0.75rem;
        font-size: 0.85rem;
    }

    .toggle-btn {
        padding: 0.45rem 0.9rem;
        min-width: 44px;
        text-align: center;
    }

    .attendance-toggle {
        flex-wrap: wrap;
    }

    .user-profile-bar {
        padding: 0.65rem;
    }

    .salary-table,
    .salary-table thead,
    .salary-table tbody,
    .salary-table tr,
    .salary-table th,
    .salary-table td {
        display: block;
        width: 100%;
    }

    .salary-table {
        min-width: 0;
        border-collapse: separate;
        background: transparent;
    }

    .salary-table thead {
        display: none;
    }

    .salary-table tbody {
        display: flex;
        flex-direction: column;
        gap: 0.85rem;
        padding: 0.85rem;
    }

    .salary-table .salary-row {
        background: var(--bg-card);
        border: 1px solid var(--border);
        border-radius: 16px;
        padding: 0.25rem 0;
        box-shadow: var(--shadow);
    }

    .salary-table .salary-row td {
        border-bottom: 1px solid var(--border);
        padding: 0.8rem 1rem !important;
        text-align: left !important;
    }

    .salary-table .salary-row td:last-child {
        border-bottom: none;
    }

    .salary-table .salary-row td:not(:first-child) {
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 1rem;
    }

    .salary-table .salary-row td:not(:first-child)::before {
        content: attr(data-label);
        color: var(--text-muted);
        font-size: 0.72rem;
        font-weight: 700;
        text-transform: uppercase;
        letter-spacing: 0.04em;
        flex: 0 0 104px;
    }

    .salary-table .salary-row td[data-label="Action"] {
        display: block;
        text-align: left !important;
    }

    .salary-table .salary-row td[data-label="Action"]::before {
        content: attr(data-label);
        display: block;
        color: var(--text-muted);
        font-size: 0.72rem;
        font-weight: 700;
        text-transform: uppercase;
        letter-spacing: 0.04em;
        margin-bottom: 0.7rem;
    }

    .salary-table .salary-row td:first-child {
        padding-bottom: 0.95rem !important;
    }

    .salary-table .salary-row td:first-child > div {
        align-items: flex-start !important;
    }

    .salary-table .salary-row td:last-child .salary-row-actions {
        width: 100%;
        display: flex;
        justify-content: stretch !important;
        flex-direction: column;
        gap: 0.65rem !important;
    }

    .salary-table .salary-row td:last-child .salary-row-actions > * {
        width: 100%;
    }
}

@media (max-width: 420px) {
    .main-content {
        padding: 0.75rem;
    }

    .app-header {
        margin-bottom: 1rem;
    }

    .sidebar {
        width: min(88vw, 300px);
    }

    .sidebar-header {
        padding: 1rem 0.85rem 0.85rem;
    }

    .brand-info h2 {
        font-size: 1rem;
    }

    .brand-info p {
        font-size: 0.68rem;
    }

    .sidebar-bottom {
        padding: 0.8rem 0.65rem calc(0.8rem + env(safe-area-inset-bottom, 0px));
    }

    .nav-item {
        padding: 0.82rem 0.9rem;
    }

    .header-search input,
    .input-wrapper input,
    .input-wrapper select,
    .select-trigger {
        font-size: 16px;
    }

    .mobile-nav-toggle {
        width: 42px;
        height: 42px;
    }
}

/* Toggle Switch */
.switch-toggle {
    position: relative;
    display: inline-block;
    width: 44px;
    height: 24px;
}

.switch-toggle input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider-round {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #ccc;
    transition: .4s;
    border-radius: 24px;
}

.slider-round:before {
    position: absolute;
    content: "";
    height: 18px;
    width: 18px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: .4s;
    border-radius: 50%;
}

input:checked+.slider-round {
    background-color: #00B894;
}

input:checked+.slider-round:before {
    transform: translateX(20px);
}

/* Clickable Table Row */
tbody tr {
    cursor: pointer;
    transition: var(--transition);
}

tbody tr:hover {
    background-color: rgba(0, 0, 0, 0.02) !important;
}

tbody tr td:last-child {
    cursor: default;
    /* Actions shouldn't trigger row click if implemented via JS event bubbling */
}

/* Profile Modal Styling */
.profile-modal {
    text-align: center;
}

.profile-avatar-large {
    width: 100px;
    height: 100px;
    border-radius: 50%;
    margin: 0 auto 1.5rem;
    border: 4px solid var(--border);
}

.detail-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
    text-align: left;
    margin-top: 1.5rem;
}

.detail-item label {
    font-size: 0.75rem;
    color: var(--text-muted);
    font-weight: 600;
    display: block;
    margin-bottom: 4px;
}

.detail-item span {
    font-weight: 600;
    color: var(--text-main);
}

.mini-calendar {
    background: var(--bg-main);
    border-radius: 12px;
    padding: 15px;
    margin-top: 10px;
}

.cal-header {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    text-align: center;
    font-size: 0.7rem;
    font-weight: 700;
    color: var(--text-muted);
    margin-bottom: 10px;
    text-transform: uppercase;
}

.cal-body {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 5px;
}

.cal-cell {
    aspect-ratio: 1/1;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    font-weight: 600;
    border-radius: 8px;
    background: var(--bg-card);
    transition: 0.3s;
}

.cal-cell.empty {
    background: transparent;
}

.cal-cell.present {
    background: #00B894;
    color: white;
}

.cal-cell.absent {
    background: #D63031;
    color: white;
}

.cal-cell.halfday {
    background: #FF9F43;
    color: white;
}

.cal-cell.holiday {
    background: #0ABDE3;
    color: white;
}

.cal-cell:hover:not(.empty) {
    transform: scale(1.1);
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
}

/* Attendance Marking Toggles */
.attendance-toggle {
    display: flex;
    background: var(--bg-main);
    padding: 5px;
    border-radius: 12px;
    gap: 5px;
    margin-top: 5px;
}

.toggle-btn {
    flex: 1;
    text-align: center;
    padding: 8px 5px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.75rem;
    font-weight: 700;
    transition: var(--transition);
    color: var(--text-muted);
}

.toggle-btn input {
    display: none;
}

.toggle-btn.active {
    background: var(--active-bg, var(--primary));
    color: white;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
}

/* Attendance Popup Styling */
.attendance-popup-container {
    padding: 0.5rem;
}

.popup-subtitle {
    text-align: center;
    color: var(--text-muted);
    margin-bottom: 1.5rem;
    font-size: 0.9rem;
}

.attendance-options-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
}

.att-choice-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.8rem;
    padding: 1.5rem 1rem;
    border-radius: 16px;
    border: 2px solid var(--bg-main);
    background: var(--bg-card);
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    color: var(--text-main);
}

.att-choice-btn i {
    font-size: 1.5rem;
    color: var(--choice-color);
}

.att-choice-btn span {
    font-weight: 700;
    font-size: 0.85rem;
}

.att-choice-btn:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.1);
    border-color: var(--choice-color);
}

.att-choice-btn.active {
    background: var(--choice-color);
    border-color: var(--choice-color);
    color: white;
}

.att-choice-btn.active i {
    color: white;
}

/* Month Picker Style */
#profile-month-picker {
    border: 1px solid var(--border);
    padding: 0.4rem 0.8rem;
    border-radius: 8px;
    font-size: 0.85rem;
    font-weight: 600;
    background: var(--bg-main);
    color: var(--text-main);
    cursor: pointer;
    transition: var(--transition);
}

#profile-month-picker:hover {
    border-color: var(--primary);
    background: white;
}

/* Flatpickr MonthSelect Theming */
.flatpickr-monthSelect-month {
    background: transparent;
    border: none;
    border-radius: 8px;
    margin: 2px;
    padding: 10px 5px;
    font-weight: 600;
}

.flatpickr-monthSelect-month.selected,
.flatpickr-monthSelect-month:hover {
    background: var(--primary) !important;
    color: white !important;
    box-shadow: 0 4px 10px rgba(200, 169, 126, 0.3);
}

.flatpickr-calendar.hasMonthSelect {
    width: 250px;
    border-radius: 12px;
    border: none;
    box-shadow: var(--shadow-lg);
    background: var(--bg-card);
}

.flatpickr-monthSelect-months {
    padding: 10px;
}

/* Status Badges */
.badge {
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    display: inline-block;
}

.badge-success {
    background: rgba(0, 184, 148, 0.1);
    color: #00B894;
}

.badge-danger {
    background: rgba(214, 48, 49, 0.1);
    color: #D63031;
}

.badge-warning {
    background: rgba(255, 159, 67, 0.1);
    color: #FF9F43;
}

.badge-info {
    background: rgba(10, 189, 227, 0.1);
    color: #0ABDE3;
}

/* Attendance Row Hover */
.attendance-row td[onclick]:hover {
    background-color: rgba(62, 39, 35, 0.03);
}

.staff-link:hover span {
    text-decoration: underline;
}

/* Toast Notification */
#toast-container {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 999999 !important;
    display: flex;
    flex-direction: column;
    gap: 10px;
    pointer-events: none;
}

.toast {
    background: #3E2723;
    color: white;
    padding: 1rem 2rem;
    border-radius: 50px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2);
    font-weight: 600;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    gap: 10px;
    animation: toastIn 0.3s cubic-bezier(0.4, 0, 0.2, 1), toastOut 0.3s cubic-bezier(0.4, 0, 0.2, 1) 2.7s forwards;
    pointer-events: auto;
}

.toast i {
    color: #D4AF37;
}

.sync-status-chip {
    position: fixed;
    top: 18px;
    right: 24px;
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    border-radius: 999px;
    border: 1px solid rgba(0, 0, 0, 0.08);
    background: rgba(255, 255, 255, 0.96);
    color: var(--text-main);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.12);
    backdrop-filter: blur(8px);
    z-index: 3200;
    font-size: 0.82rem;
    font-weight: 700;
    transition: opacity 0.2s ease, transform 0.2s ease;
}

.sync-status-chip.hidden {
    opacity: 0;
    pointer-events: none;
    transform: translateY(-8px);
}

.sync-status-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: currentColor;
    flex-shrink: 0;
}

.sync-status-info {
    color: var(--primary);
}

.sync-status-saving {
    color: #b26a00;
}

.sync-status-success {
    color: var(--success);
}

.sync-status-error {
    color: var(--danger);
}

@keyframes toastIn {
    from {
        transform: translateY(-100%);
        opacity: 0;
    }

    to {
        transform: translateY(0);
        opacity: 1;
    }
}

@keyframes toastOut {
    from {
        transform: translateY(0);
        opacity: 1;
    }

    to {
        transform: translateY(-100%);
        opacity: 0;
    }
}


/* Settings Page Styles */
.theme-option-card {
    position: relative;
    overflow: hidden;
}

.theme-option-card.active {
    background: var(--bg-main) !important;
    border-color: var(--primary) !important;
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.05);
}

.theme-option-card.active::before {
    content: '\f058';
    font-family: 'Font Awesome 6 Free';
    font-weight: 900;
    position: absolute;
    top: 8px;
    right: 8px;
    color: var(--primary);
    font-size: 1rem;
}

.theme-option-card:hover:not(.active) {
    border-color: var(--primary);
    transform: translateY(-2px);
}

/* Settings Tab Styles */
.settings-tab-btn {
    flex: 1;
    padding: 12px 15px;
    border: none;
    background: transparent;
    color: var(--text-muted);
    font-weight: 700;
    font-size: 0.9rem;
    border-radius: 10px;
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.settings-tab-btn i {
    font-size: 1.1rem;
}

.settings-tab-btn:hover {
    background: rgba(var(--primary-rgb), 0.05);
    color: var(--primary);
}

.settings-tab-btn.active {
    background: white;
    color: var(--primary);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
}

.btn-icon-sm {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: white;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: var(--transition);
}

.btn-icon-sm:hover {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Print Styles for A4 Staff Profile */
@media print {

    /* Hide non-printable elements */
    .sidebar,
    .app-header,
    .header-search,
    .header-actions,
    .btn-icon,
    .btn-outline,
    .btn-primary,
    .theme-switch-group,
    .month-selector,
    #profile-month-picker,
    .card-header .btn-primary,
    .signature-actions {
        display: none !important;
    }

    /* Reset main layout */
    .app-layout {
        display: block !important;
    }

    .main-content {
        margin-left: 0 !important;
        padding: 0 !important;
        width: 100% !important;
        background: white !important;
    }

    body {
        background: white !important;
        color: black !important;
        font-size: 10pt !important;
    }

    /* Page Setup */
    @page {
        size: A4;
        margin: 1.5cm;
    }

    /* Profile Specific Layout */
    .view-header {
        margin-bottom: 1rem !important;
        border-bottom: 2px solid #333;
        padding-bottom: 10px;
    }

    .view-header img {
        width: 50px !important;
        height: 50px !important;
    }

    /* Side-by-side grid adjustment for print */
    div[style*="display:grid; grid-template-columns: 350px 1fr"] {
        display: flex !important;
        flex-direction: column !important;
        gap: 1rem !important;
    }

    .card {
        box-shadow: none !important;
        border: 1px solid #eee !important;
        padding: 1rem !important;
        margin-bottom: 1rem !important;
        break-inside: avoid;
    }

    /* Force tables to fit */
    .table-responsive {
        overflow: visible !important;
        max-height: none !important;
    }

    table {
        border-collapse: collapse !important;
        width: 100% !important;
    }

    th,
    td {
        padding: 4pt 6pt !important;
        border: 1px solid #ddd !important;
        font-size: 9pt !important;
    }

    th {
        background: #f5f5f5 !important;
        color: black !important;
    }

    /* Financial Logs Grid Adjustment */
    div[style*="display:grid; grid-template-columns: 1fr 1fr"] {
        display: grid !important;
        grid-template-columns: 1fr 1fr !important;
        gap: 1rem !important;
    }

    /* Status Badges for Print */
    .badge {
        border: 1px solid #ccc !important;
        background: transparent !important;
        color: black !important;
    }

    /* Attendance Calendar - Often too big for single page if shown with tables */
    .mini-calendar {
        display: none !important;
        /* Hide calendar in favor of table report for space */
    }

    /* Signatures Section for Physical Signing */
    .print-only-signatures {
        display: flex !important;
        justify-content: space-between;
        margin-top: 3rem;
        padding-top: 1rem;
        border-top: 1px dashed #333;
    }

    .sig-box {
        text-align: center;
        width: 200px;
    }

    .sig-line {
        border-bottom: 1px solid black;
        height: 40px;
        margin-bottom: 5px;
    }
}

.theme-option-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
    border-color: var(--primary) !important;
}

.theme-option-card.active {
    border-color: var(--primary) !important;
    background: rgba(var(--primary-rgb), 0.05);
    box-shadow: 0 0 0 1px var(--primary);
}

/* Screen only visual for signature boxes (hidden by default) */
.print-only-signatures {
    display: none;
}
