/* ============================================================
   DTR System - Dashboard & Portal Styles
   ============================================================ */

/* ── App Shell Layout ── */
.app-shell {
    display: flex;
    min-height: 100vh;
    overflow-x: hidden;
}

/* ── Sidebar ── */
.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: var(--sidebar-width);
    height: 100vh;
    background: var(--sidebar-bg);
    display: flex;
    flex-direction: column;
    z-index: var(--z-sticky);
    transition: width var(--duration-base) var(--ease-out);
    overflow: hidden;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px 20px;
    border-bottom: 1px solid hsla(0, 0%, 100%, 0.06);
}

.sidebar-brand-icon {
    width: 38px;
    height: 38px;
    border-radius: var(--border-radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    overflow: hidden;
    background: transparent;
}

.sidebar-brand-icon img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}
.sidebar-brand-text {
    font-size: var(--text-md);
    font-weight: 700;
    color: var(--neutral-0);
    white-space: nowrap;
}

.sidebar-brand-sub {
    font-size: var(--text-xs);
    color: var(--sidebar-text);
    font-weight: 400;
}

/* ── Sidebar User Profile ── */
.sidebar-profile {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px 20px;
    border-bottom: 1px solid hsla(0, 0%, 100%, 0.06);
}

.sidebar-avatar {
    width: 42px;
    height: 42px;
    border-radius: var(--border-radius-full);
    background: linear-gradient(135deg, var(--primary-300), var(--accent-400));
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: var(--text-sm);
    color: var(--neutral-0);
    flex-shrink: 0;
    overflow: hidden;
}

.sidebar-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.sidebar-user-name {
    font-size: var(--text-sm);
    font-weight: 600;
    color: var(--neutral-0);
    white-space: nowrap;
}

.sidebar-user-status {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: var(--text-xs);
    color: var(--success-400);
}

.sidebar-user-status::before {
    content: '';
    width: 7px;
    height: 7px;
    background: var(--success-400);
    border-radius: 50%;
    display: inline-block;
    animation: pulse 2s ease infinite;
}

/* ── Sidebar Navigation ── */
.sidebar-nav {
    flex: 1;
    padding: 12px 0;
    overflow-y: auto;
}

.sidebar-nav::-webkit-scrollbar { width: 3px; }
.sidebar-nav::-webkit-scrollbar-thumb { background: hsla(0,0%,100%,0.1); border-radius: 2px; }

.nav-section-title {
    padding: 16px 20px 8px;
    font-size: var(--text-xs);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--neutral-500);
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 11px 20px;
    font-size: var(--text-sm);
    font-weight: 500;
    color: var(--sidebar-text);
    cursor: pointer;
    transition: all var(--duration-fast) var(--ease-out);
    border-left: 3px solid transparent;
    text-decoration: none;
    position: relative;
}

.nav-item:hover {
    background: var(--sidebar-hover);
    color: var(--neutral-0);
}

.nav-item.active {
    background: hsla(230, 72%, 50%, 0.12);
    color: var(--sidebar-text-active);
    border-left-color: var(--primary-400);
    font-weight: 600;
}

.nav-item .nav-icon {
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-size: var(--text-md);
}

.nav-item .nav-badge {
    margin-left: auto;
    background: var(--danger-500);
    color: var(--neutral-0);
    font-size: 10px;
    font-weight: 700;
    padding: 2px 7px;
    border-radius: var(--border-radius-full);
    min-width: 20px;
    text-align: center;
}

.nav-submenu {
    max-height: 0;
    overflow: hidden;
    transition: max-height var(--duration-base) var(--ease-out);
}

.nav-submenu.open {
    max-height: 200px;
}

.nav-submenu .nav-item {
    padding-left: 60px;
    font-size: var(--text-xs);
}

/* ── Main Content Area ── */
.main-content {
    margin-left: var(--sidebar-width);
    flex: 1;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    transition: margin-left var(--duration-base) var(--ease-out);
}

/* ── Top Header ── */
.top-header {
    height: var(--header-height);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 var(--content-padding);
    background: var(--glass-bg);
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    border-bottom: 1px solid var(--neutral-200);
    position: sticky;
    top: 0;
    z-index: var(--z-sticky);
    box-shadow: 0 1px 0 rgba(15, 23, 42, 0.04);
}

.header-left {
    display: flex;
    align-items: center;
    gap: 16px;
}

.sidebar-toggle {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    background: transparent;
    border-radius: var(--border-radius-md);
    cursor: pointer;
    color: var(--neutral-600);
    font-size: var(--text-xl);
    transition: all var(--duration-fast) var(--ease-out);
}

.sidebar-toggle:hover {
    background: var(--neutral-100);
    color: var(--neutral-800);
}

.page-title {
    font-size: var(--text-lg);
    font-weight: 700;
    color: var(--neutral-900);
}

.header-right {
    display: flex;
    align-items: center;
    gap: 8px;
}

.header-btn {
    position: relative;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    background: transparent;
    border-radius: var(--border-radius-md);
    cursor: pointer;
    color: var(--neutral-500);
    font-size: var(--text-lg);
    transition: all var(--duration-fast) var(--ease-out);
}

.header-btn:hover {
    background: var(--neutral-100);
    color: var(--neutral-800);
}

.header-btn .badge-dot {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 8px;
    height: 8px;
    background: var(--danger-500);
    border-radius: 50%;
    border: 2px solid var(--neutral-0);
}

.header-avatar {
    width: 36px;
    height: 36px;
    border-radius: var(--border-radius-full);
    background: linear-gradient(135deg, var(--primary-300), var(--accent-400));
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: var(--text-xs);
    color: var(--neutral-0);
    cursor: pointer;
    margin-left: 8px;
}

/* ── Content Wrapper ── */
.content-wrapper {
    flex: 1;
    padding: var(--content-padding);
}

/* ── Stats / KPI Cards Row ── */
.stats-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 16px;
    margin-bottom: 20px;
}

.stats-row--three {
    display: grid !important;
    grid-template-columns: repeat(3, 1fr) !important;
    gap: 16px !important;
    margin-bottom: 20px !important;
}

.stat-card {
    background: var(--neutral-0);
    border-radius: var(--border-radius-lg);
    padding: 18px 20px;
    display: flex;
    align-items: center;
    gap: 14px;
    border: 1px solid var(--neutral-200);
    box-shadow: var(--shadow-sm);
    transition: all var(--duration-base) var(--ease-out);
}

.stat-card:hover {
    box-shadow: var(--shadow-lg);
    transform: translateY(-2px);
}

.stat-icon {
    width: 52px;
    height: 52px;
    border-radius: var(--border-radius-lg);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: var(--text-2xl);
    flex-shrink: 0;
}

.stat-icon.blue {
    background: var(--primary-50);
    color: var(--primary-500);
}

.stat-icon.green {
    background: var(--success-50);
    color: var(--success-500);
}

.stat-icon.yellow {
    background: var(--warning-50);
    color: var(--warning-500);
}

.stat-icon.red {
    background: var(--danger-50);
    color: var(--danger-500);
}

.stat-icon.purple {
    background: hsla(270, 76%, 58%, 0.1);
    color: var(--accent-500);
}

.stat-info h3 {
    font-size: var(--text-2xl);
    font-weight: 800;
    color: var(--neutral-900);
    line-height: 1;
}

.stat-info p {
    font-size: var(--text-sm);
    color: var(--neutral-500);
    margin-top: 4px;
}

/* ── Section Cards ── */
.section-card {
    background: var(--neutral-0);
    border-radius: var(--border-radius-lg);
    border: 1px solid var(--neutral-200);
    box-shadow: var(--shadow-sm);
    margin-bottom: 20px;
}

.section-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--neutral-100);
}

.section-card-header h4 {
    font-size: var(--text-md);
    font-weight: 700;
    color: var(--neutral-900);
}

.section-card-body {
    padding: 20px;
}

.dashboard-grid {
    display: grid;
    grid-template-columns: 1fr 340px;
    gap: 20px;
    align-items: start;
}

/* Make chart stretch to the card edges (bleed past inner padding) */
.section-card-body .chart-bleed {
    margin: 0 -20px;
    padding: 0 20px;
}

.section-card-body canvas {
    width: 100%;
    display: block;
}

/* ── Filter Bar ── */
.filter-bar {
    background: var(--neutral-0);
    border-radius: var(--border-radius-lg);
    border: 1px solid var(--neutral-200);
    padding: 18px 20px;
    margin-bottom: 20px;
    box-shadow: var(--shadow-xs);
}

.filter-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 16px;
    align-items: end;
}

/* ── Time Clock Display ── */
.clock-display {
    text-align: center;
    padding: 28px 20px;
}

.clock-date {
    font-size: var(--text-lg);
    font-weight: 500;
    color: var(--primary-500);
    margin-bottom: 8px;
}

.clock-time {
    font-family: var(--font-mono);
    font-size: var(--text-5xl);
    font-weight: 700;
    color: var(--neutral-900);
    letter-spacing: -0.02em;
    margin-bottom: 16px;
}

.clock-schedule {
    font-size: var(--text-base);
    color: var(--neutral-500);
    margin-bottom: 20px;
}

.clock-actions {
    display: flex;
    justify-content: center;
    gap: 16px;
    flex-wrap: wrap;
}

.clock-btn {
    padding: 16px 36px;
    font-size: var(--text-lg);
    font-weight: 700;
    border: none;
    border-radius: var(--border-radius-lg);
    cursor: pointer;
    transition: all var(--duration-base) var(--ease-spring);
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 200px;
    justify-content: center;
    position: relative;
    overflow: hidden;
}

.clock-btn-in {
    background: linear-gradient(135deg, var(--success-400), hsl(152, 68%, 34%));
    color: var(--neutral-0);
    box-shadow: 0 4px 20px hsla(152, 65%, 40%, 0.35);
}

.clock-btn-in:hover:not(:disabled) {
    transform: translateY(-3px) scale(1.02);
    box-shadow: 0 8px 30px hsla(152, 65%, 40%, 0.45);
}

.clock-btn-out {
    background: linear-gradient(135deg, var(--danger-400), hsl(0, 78%, 44%));
    color: var(--neutral-0);
    box-shadow: 0 4px 20px hsla(0, 75%, 50%, 0.35);
}

.clock-btn-out:hover:not(:disabled) {
    transform: translateY(-3px) scale(1.02);
    box-shadow: 0 8px 30px hsla(0, 75%, 50%, 0.45);
}

.clock-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    transform: none !important;
    box-shadow: none !important;
}

.clock-status {
    margin-top: 20px;
    font-size: var(--text-sm);
    color: var(--neutral-500);
}

.clock-status .status-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    margin-right: 6px;
}

.clock-status .status-dot.active {
    background: var(--success-400);
    animation: pulse 2s ease infinite;
}

.clock-status .status-dot.inactive {
    background: var(--neutral-300);
}

/* ── Break Timer ── */
.break-timer {
    text-align: center;
    padding: 28px 20px;
}

.break-timer-title {
    font-size: var(--text-xl);
    font-weight: 700;
    color: var(--neutral-900);
    margin-bottom: 8px;
}

.break-timer-title span {
    color: var(--danger-500);
}

.timer-digits {
    display: flex;
    justify-content: center;
    gap: 16px;
    margin: 24px 0;
}

.timer-block {
    text-align: center;
}

.timer-block-label {
    font-size: var(--text-xs);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--neutral-500);
    margin-bottom: 8px;
}

.timer-block-digits {
    display: flex;
    gap: 6px;
}

.timer-digit {
    width: 64px;
    height: 80px;
    background: var(--neutral-0);
    border: 2px solid var(--neutral-200);
    border-radius: var(--border-radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: var(--font-mono);
    font-size: var(--text-3xl);
    font-weight: 700;
    color: var(--neutral-900);
    box-shadow: var(--shadow-sm);
}

.timer-separator {
    display: flex;
    align-items: center;
    font-family: var(--font-mono);
    font-size: var(--text-3xl);
    font-weight: 700;
    color: var(--neutral-400);
    padding-top: 20px;
}

.break-sessions-left {
    font-size: var(--text-md);
    color: var(--neutral-600);
    margin-bottom: 20px;
}

.break-sessions-left span {
    font-weight: 800;
    color: var(--primary-500);
    font-size: var(--text-xl);
}

/* ── Login Page ── */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, hsl(225, 30%, 12%) 0%, hsl(240, 25%, 18%) 50%, hsl(260, 22%, 16%) 100%);
    position: relative;
    overflow: hidden;
}

.login-page::before {
    content: '';
    position: absolute;
    width: 600px;
    height: 600px;
    background: radial-gradient(circle, hsla(230, 72%, 50%, 0.15) 0%, transparent 70%);
    top: -200px;
    right: -200px;
    animation: float 8s ease-in-out infinite;
}

.login-page::after {
    content: '';
    position: absolute;
    width: 400px;
    height: 400px;
    background: radial-gradient(circle, hsla(270, 72%, 50%, 0.1) 0%, transparent 70%);
    bottom: -100px;
    left: -100px;
    animation: float 10s ease-in-out infinite reverse;
}

@keyframes float {
    0%, 100% { transform: translate(0, 0); }
    50% { transform: translate(30px, -30px); }
}

.login-container {
    width: 100%;
    max-width: 520px;
    padding: 16px;
    position: relative;
    z-index: 1;
}

.login-card {
    background: hsla(0, 0%, 100%, 0.06);
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
    border: 1px solid hsla(0, 0%, 100%, 0.1);
    border-radius: var(--border-radius-xl);
    padding: 30px 26px;
    box-shadow: 0 20px 40px hsla(0, 0%, 0%, 0.22);
}

.login-logo {
    text-align: center;
    margin-bottom: 8px;
}

.login-logo-icon {
    width: 56px;
    height: 56px;
    margin: 0 auto 16px;
    background: linear-gradient(135deg, var(--primary-400), var(--accent-500));
    border-radius: var(--border-radius-lg);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: var(--text-2xl);
    font-weight: 800;
    color: var(--neutral-0);
}

.login-logo h1 {
    color: var(--neutral-0);
    font-size: var(--text-2xl);
    font-weight: 800;
    margin-bottom: 4px;
}

.login-logo p {
    color: hsla(0, 0%, 100%, 0.5);
    font-size: var(--text-sm);
}

.login-form {
    margin-top: 32px;
}

.login-input-group {
    position: relative;
    margin-bottom: 20px;
}

.login-input-group .input-icon {
    position: absolute;
    left: 18px;
    top: 50%;
    transform: translateY(-50%);
    z-index: 10 !important;
    color: #475569 !important;
    font-size: 1rem;
    line-height: 1;
    pointer-events: none;
    transition: color var(--duration-fast) var(--ease-out);
}

.login-input,
.login-input.form-control {
    width: 100%;
    padding: 14px 16px 14px 52px !important;
    font-family: var(--font-sans);
    font-size: var(--text-base);
    color: var(--neutral-0);
    background: hsla(0, 0%, 100%, 0.07) !important;
    border: 1.5px solid hsla(0, 0%, 100%, 0.12) !important;
    border-radius: var(--border-radius-md);
    outline: none;
    transition: all var(--duration-base) var(--ease-out);
}

.login-input::placeholder {
    color: hsla(0, 0%, 100%, 0.3);
}

.login-input:focus {
    border-color: var(--primary-400);
    background: hsla(0, 0%, 100%, 0.1);
    box-shadow: 0 0 0 3px hsla(230, 72%, 50%, 0.2);
}

.login-input:focus + .input-icon,
.login-input:focus ~ .input-icon {
    color: var(--primary-400);
}

.login-btn {
    width: 100%;
    padding: 14px;
    font-family: var(--font-sans);
    font-size: var(--text-md);
    font-weight: 700;
    color: var(--neutral-0);
    background: linear-gradient(135deg, var(--primary-500), var(--accent-500));
    border: none;
    border-radius: var(--border-radius-md);
    cursor: pointer;
    transition: all var(--duration-base) var(--ease-out);
    box-shadow: 0 4px 20px hsla(230, 72%, 50%, 0.35);
    margin-top: 8px;
}

.login-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 30px hsla(230, 72%, 50%, 0.5);
}

.login-btn:active {
    transform: scale(0.98);
}

/* ── Responsive ── */
@media (max-width: 768px) {
    body {
        overflow-x: hidden;
    }

    .app-shell {
        display: block;
    }

    .sidebar {
        width: min(280px, 84vw);
        transform: translateX(-100%);
        transition: transform var(--duration-base, 250ms) var(--ease-out, ease-out);
        z-index: 1001 !important;
    }
    
    body.sidebar-open .sidebar {
        transform: translateX(0) !important;
    }
    
    body.sidebar-open::after {
        content: '';
        position: fixed;
        top: 0;
        left: 0;
        width: 100vw;
        height: 100vh;
        background: rgba(0, 0, 0, 0.4);
        z-index: 1000;
        pointer-events: auto;
    }
    
    .main-content {
        margin-left: 0 !important;
        width: 100%;
    }
}

@media screen and (min-width: 360px) and (max-width: 430px) {
    body {
        overflow-x: hidden;
        padding: 0 8px;
    }

    .login-container {
        max-width: 100%;
        width: min(420px, 100%);
        margin: 0 auto;
        padding: 0 6px;
        transform: none !important;
    }

    .login-card {
        padding: 22px 18px;
        border-radius: calc(var(--border-radius-xl) - 4px);
        box-shadow: 0 18px 36px hsla(0, 0%, 0%, 0.22);
    }

    .login-logo h1 {
        font-size: 1.05rem;
        margin-bottom: 6px;
    }

    .login-logo p {
        font-size: 0.88rem;
    }

    .login-form {
        margin-top: 24px;
    }

    .login-input-group {
        margin-bottom: 16px;
    }

    .login-input,
    .login-input.form-control {
        padding: 12px 14px 12px 48px !important;
        font-size: 0.95rem;
    }

    .login-input-group .input-icon {
        left: 14px;
        font-size: 0.95rem;
    }

    .login-btn {
        padding: 12px;
        font-size: 1rem;
    }

    .login-page::before,
    .login-page::after {
        display: none;
    }

    #starCanvas {
        display: block;
        opacity: 1;
    }

    .alert {
        margin-bottom: 16px;
        font-size: 0.94rem;
    }
}


    .top-header {
        padding: 0 16px;
        gap: 12px;
        min-height: 64px;
    }

    .header-left {
        min-width: 0;
        flex: 1;
    }

    .page-title {
        font-size: var(--text-md);
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .header-right {
        gap: 6px;
        flex-shrink: 0;
    }

    .messages-dropdown {
        width: min(320px, calc(100vw - 24px));
        right: -8px;
        max-height: calc(100vh - 120px);
        overflow-y: auto;
    }

    .content-wrapper {
        padding: 16px;
    }

    .chart-bleed {
        width: 100%;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        padding-bottom: 8px;
    }

    .chart-bleed canvas {
        min-width: 560px;
        display: block;
    }
    
    .stats-row.stats-row--three {
        grid-template-columns: 1fr !important;
        gap: 14px !important;
    }

    .stats-row:not(.stats-row--three),
    .dashboard-main-grid,
    .admin-dashboard-grid,
    .dashboard-grid,
    .filter-grid {
        grid-template-columns: 1fr !important;
        gap: 14px !important;
    }

    .stats-row .stat-card {
        padding: 16px;
    }

    .stats-row .stat-card .stat-info h3 {
        font-size: 1.25rem;
    }

    .dashboard-grid {
        grid-template-columns: 1fr !important;
    }

    .section-card,
    .card {
        padding: 16px;
    }

    .section-card-body {
        padding: 16px;
    }

    .section-card-header {
        flex-wrap: wrap;
        gap: 10px;
        align-items: flex-start;
    }

    .section-card form[method="POST"] {
        width: 100%;
    }

    #messageManagerCard {
        overflow: hidden;
        min-width: 0;
    }

    #messageManagerCard .section-card-header {
        flex-direction: column;
        align-items: stretch;
    }

    #messageManagerCard .section-card-header .btn {
        width: 100%;
        justify-content: center;
    }

    #messageManagerCard .message-action-group {
        flex-direction: column;
        align-items: stretch;
        width: 100%;
    }

    #messageManagerCard .message-action-group .btn,
    #messageManagerCard .message-action-form {
        width: 100%;
    }

    #messageManagerCard .message-action-form .btn {
        width: 100%;
        justify-content: center;
    }

    #messageForm .modal-actions {
        flex-direction: column-reverse;
        align-items: stretch;
    }

    #messageForm .modal-actions .btn {
        width: 100%;
        justify-content: center;
    }

    #branches form,
    #schedules form,
    .schedule-form {
        flex-direction: column;
        align-items: stretch;
    }

    #branches.section-card {
        overflow: hidden;
        min-width: 0;
    }

    #branches .table-container {
        width: 100%;
        max-width: 100%;
        overflow-x: auto;
        overflow-y: hidden;
        border-radius: 0 0 var(--border-radius-lg) var(--border-radius-lg);
    }

    #branches .data-table {
        width: 100%;
        min-width: 280px;
    }

    #branches .data-table th,
    #branches .data-table td {
        white-space: nowrap;
    }

    #branches form .form-control,
    #schedules form .form-control,
    #branches form .btn,
    #schedules form .btn,
    .schedule-form .form-control,
    .schedule-form .btn {
        width: 100%;
        max-width: 100%;
    }

    .schedule-form {
        display: flex;
        gap: 12px;
        align-items: flex-start;
        flex-wrap: wrap;
        width: 100%;
    }

    .schedule-field {
        flex: 1 1 100%;
        min-width: 0;
        margin: 0;
        width: 100%;
    }

    .schedule-submit {
        height: 40px;
        margin: 0;
        width: 100%;
        max-width: 100%;
    }

    #schedules .table-container {
        margin: 0;
        border-radius: 0 0 var(--border-radius-lg) var(--border-radius-lg);
        border: 1px solid var(--neutral-200);
        background: var(--neutral-0);
    }

    #schedules .data-table {
        min-width: 620px;
        width: 100%;
    }

    #schedules .data-table th,
    #schedules .data-table td {
        white-space: nowrap;
    }

    .table-container {
        overflow-x: auto;
        overflow-y: hidden;
        -webkit-overflow-scrolling: touch;
        display: block;
        width: 100%;
        max-width: 100%;
        scrollbar-width: thin;
    }

    .table-container::-webkit-scrollbar {
        height: 8px;
    }

    .table-container::-webkit-scrollbar-thumb {
        background: rgba(15, 23, 42, 0.2);
        border-radius: 999px;
    }

    .data-table {
        min-width: 700px;
        width: 100%;
    }

    .admin-dashboard-grid > .section-card:first-child {
        min-width: 0;
        overflow: hidden;
    }

    .data-table th,
    .data-table td {
        white-space: nowrap;
    }

    .admin-page-toolbar,
    .request-filter-toolbar {
        flex-direction: column;
        align-items: stretch;
    }

    .request-filter-tabs {
        width: 100%;
        display: flex;
        flex-wrap: wrap;
        gap: 8px;
    }

    .request-filter-tabs a {
        flex: 1 1 calc(50% - 8px);
        justify-content: center;
    }

    .table-actions {
        flex-wrap: wrap;
        gap: 8px;
        justify-content: center;
    }

    .table-actions .btn,
    .request-action-form .btn,
    .user-action-form .btn {
        width: 100%;
        justify-content: center;
    }

    .request-action-form,
    .user-action-form {
        flex-wrap: wrap;
        width: 100%;
    }

    .user-action-form {
        display: flex;
        justify-content: center;
    }

    #employeeModal {
        padding: 12px;
    }

    #employeeModal > div {
        max-height: 95vh;
        width: 100%;
    }

    #employeeModal [style*="grid-template-columns:1fr 1fr 1fr"] {
        grid-template-columns: 1fr !important;
    }

    #employeeModal [style*="grid-template-columns:1fr 1fr"] {
        grid-template-columns: 1fr !important;
    }

    .clock-actions {
        flex-direction: column;
        align-items: center;
    }
    
    .clock-btn {
        min-width: 0;
        width: 100%;
    }
    
    .timer-digit {
        width: 48px;
        height: 60px;
        font-size: var(--text-xl);
    }


@media (max-width: 480px) {
    .stats-row {
        grid-template-columns: 1fr;
    }

    .top-header {
        padding: 0 12px;
    }

    .header-btn {
        width: 36px;
        height: 36px;
    }

    .page-title {
        font-size: 0.95rem;
    }
    
    .login-card {
        padding: 26px 18px;
    }
}

@media screen and (min-width: 360px) and (max-width: 430px) {
    .mobile-table-container {
        overflow-x: hidden;
        padding: 0;
        margin: 0 -8px;
    }

    .mobile-payroll-table {
        display: block;
        width: 100%;
        border: none;
    }

    .mobile-payroll-table thead {
        display: none;
    }

    .mobile-payroll-table tr {
        display: block;
        width: 100%;
        margin-bottom: 18px;
        border: 1px solid var(--neutral-200);
        border-radius: var(--border-radius-lg);
        background: var(--neutral-0);
        box-shadow: 0 1px 3px rgba(15, 23, 42, 0.08);
        overflow: hidden;
    }

    .mobile-payroll-table td {
        display: block;
        width: 100%;
        padding: 12px 14px;
        border-bottom: 1px solid var(--neutral-100);
        text-align: left;
        white-space: normal;
    }

    .mobile-payroll-table td:last-child {
        border-bottom: none;
    }

    .mobile-payroll-table td::before {
        content: attr(data-label);
        display: block;
        margin-bottom: 6px;
        font-size: 0.72rem;
        font-weight: 700;
        color: var(--neutral-500);
        text-transform: uppercase;
        letter-spacing: 0.06em;
    }

    .mobile-payroll-table td > * {
        margin: 0;
    }

    .mobile-payroll-table td .btn {
        width: 100%;
    }

    .mobile-payroll-table td[data-label="Action"] {
        padding-bottom: 14px;
    }
}

/* Messages Dropdown Styles */
.header-btn-container {
    position: relative;
    display: inline-block;
}

.messages-dropdown {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    width: 320px;
    background: var(--neutral-0);
    border: 1px solid var(--neutral-200);
    border-radius: var(--border-radius-md);
    box-shadow: var(--shadow-lg);
    z-index: var(--z-dropdown);
    padding: 16px;
    font-family: var(--font-sans);
    display: none;
    text-align: left;
    animation: fadeInDropdown 0.2s var(--ease-out);
}

.messages-dropdown.show {
    display: block;
}

.messages-dropdown-title {
    margin: 0 0 12px 0;
    font-size: var(--text-sm);
    font-weight: 700;
    color: var(--neutral-900);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 1px solid var(--neutral-100);
    padding-bottom: 8px;
}

.messages-dropdown-list {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.messages-dropdown-item {
    border-radius: var(--border-radius-sm);
    transition: background var(--duration-fast) var(--ease-out);
}

.messages-dropdown-item:hover {
    background: var(--neutral-50);
}

.messages-dropdown-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 12px;
    text-decoration: none;
    color: var(--neutral-700);
    font-size: var(--text-sm);
    font-weight: 500;
    transition: color var(--duration-fast) var(--ease-out);
}

.messages-dropdown-link:hover {
    color: var(--primary-600);
}

.pdf-icon {
    font-size: var(--text-md);
    color: var(--danger-500);
    display: flex;
    align-items: center;
    justify-content: center;
}

.pdf-name {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    display: block;
    max-width: 240px;
}

@keyframes fadeInDropdown {
    from {
        opacity: 0;
        transform: translateY(-8px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Sidebar collapsed state (desktop) */
@media (min-width: 769px) {
    .sidebar {
        transition: width var(--duration-base, 250ms) var(--ease-out, ease-out);
    }
    
    .main-content {
        transition: margin-left var(--duration-base, 250ms) var(--ease-out, ease-out);
    }

    body.sidebar-collapsed .sidebar {
        width: var(--sidebar-width-collapsed, 72px) !important;
        overflow: visible !important;
    }

    body.sidebar-collapsed .sidebar-nav {
        overflow-x: visible !important;
        overflow-y: auto !important;
    }
    
    body.sidebar-collapsed .main-content {
        margin-left: var(--sidebar-width-collapsed, 72px) !important;
    }
    
    /* Hide texts when collapsed */
    body.sidebar-collapsed .sidebar-brand-text,
    body.sidebar-collapsed .sidebar-brand-sub,
    body.sidebar-collapsed .sidebar-profile div:last-child,
    body.sidebar-collapsed .nav-section-title,
    body.sidebar-collapsed .nav-item > span:last-child {
        display: none !important;
    }
    
    body.sidebar-collapsed .sidebar-brand {
        padding: 20px 0;
        justify-content: center;
    }
    
    body.sidebar-collapsed .sidebar-profile {
        padding: 16px 0;
        justify-content: center;
    }
    
    body.sidebar-collapsed .nav-item {
        justify-content: center;
        padding: 12px 0;
        margin: 4px 12px;
    }
    
    /* Hide only the label text and toggle arrow when collapsed; keep icons visible */
    body.sidebar-collapsed .nav-item > span:not(.nav-icon),
    body.sidebar-collapsed .nav-item-toggle > .nav-toggle-icon {
        display: none !important;
    }

    body.sidebar-collapsed .nav-submenu {
        max-height: 0;
        overflow: hidden;
        display: none;
    }

    body.sidebar-collapsed .nav-item-group {
        position: relative;
    }

    body.sidebar-collapsed .nav-tooltip {
        opacity: 0;
        visibility: hidden;
        pointer-events: none;
        transform: translateY(-50%) translateX(-4px);
        transition: all 180ms ease;
        z-index: 70;
    }

    body.sidebar-collapsed .group:hover > .nav-tooltip,
    body.sidebar-collapsed .group:focus-within > .nav-tooltip,
    body.sidebar-collapsed .group.show-tooltip > .nav-tooltip,
    body.sidebar-collapsed .nav-item-group:hover > .nav-tooltip,
    body.sidebar-collapsed .nav-item-group:focus-within > .nav-tooltip,
    body.sidebar-collapsed .nav-item-group.show-tooltip > .nav-tooltip {
        opacity: 1;
        visibility: visible;
        pointer-events: auto;
        transform: translateY(-50%) translateX(0);
    }

    body.sidebar-collapsed .nav-item-group .settings-submenu {
        display: none;
        opacity: 0;
        visibility: hidden;
        pointer-events: none;
        transform: translateX(-4px);
        transition: opacity 180ms ease, transform 180ms ease, visibility 180ms ease;
    }

    body.sidebar-collapsed .nav-item-group.submenu-open .settings-submenu,
    body.sidebar-collapsed .nav-item-group:hover .settings-submenu,
    body.sidebar-collapsed .nav-item-group:focus-within .settings-submenu,
    body.sidebar-collapsed .nav-item-group.show-submenu .settings-submenu {
        display: flex !important;
        opacity: 1 !important;
        visibility: visible !important;
        pointer-events: auto !important;
        transform: translateX(0) !important;
        max-height: 220px !important;
        overflow: visible !important;
        position: absolute !important;
        top: 0 !important;
        left: calc(var(--sidebar-width-collapsed, 72px) + 8px) !important;
        min-width: 220px !important;
        background: rgba(15, 23, 42, 0.98) !important;
        border: 1px solid rgba(255,255,255,0.08) !important;
        box-shadow: 0 16px 40px rgba(0,0,0,0.22) !important;
        margin: 0 !important;
        padding: 8px !important;
        border-radius: var(--border-radius-lg) !important;
        z-index: 60 !important;
        flex-direction: column !important;
    }

    body.sidebar-collapsed .nav-item-group:hover .settings-submenu .nav-item,
    body.sidebar-collapsed .nav-item-group.submenu-open .settings-submenu .nav-item {
        display: flex !important;
        justify-content: flex-start !important;
        padding-left: 16px !important;
        padding-right: 16px !important;
        width: 100% !important;
        margin: 0 !important;
        font-size: 13px !important;
        border-radius: 10px !important;
    }

    body.sidebar-collapsed .nav-item-group:hover .settings-submenu .nav-item span:not(.nav-icon),
    body.sidebar-collapsed .nav-item-group.submenu-open .settings-submenu .nav-item span:not(.nav-icon) {
        display: inline !important;
    }

    body.sidebar-collapsed .nav-item-group:hover .settings-submenu .nav-icon,
    body.sidebar-collapsed .nav-item-group.submenu-open .settings-submenu .nav-icon {
        margin-right: 8px !important;
    }
    
    body.sidebar-collapsed .nav-icon {
        margin-right: 0;
        font-size: 20px;
    }
}
