/* assets/css/style.css */

/* 1. Fonts & CSS Custom Properties */
@import url('https://fonts.googleapis.com/css2?family=Fraunces:opsz,wght@9..144,400;9..144,500;9..144,600;9..144,700&family=Plus+Jakarta+Sans:wght@400;500;600;700;800&family=Reem+Kufi+Fun:wght@400..700&display=swap');

:root {
    --font-primary: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --font-display: 'Fraunces', Georgia, 'Times New Roman', serif;
    --font-number: 'Reem Kufi Fun', 'Plus Jakarta Sans', sans-serif;

    /* AttendSys theme — SaaS blue + slate */
    --bg-main: #f8fafc;           /* slate-50 canvas */
    --bg-surface: #ffffff;         /* cards, panels, sidebar */
    --bg-card: #ffffff;
    --bg-subtle: #f1f5f9;          /* slate-100 inset fills */
    --border-color: #e2e8f0;       /* slate-200 hairline */
    --border-strong: #cbd5e1;      /* slate-300 */

    --ink: #2563eb;                /* blue-600 — primary brand */
    --ink-2: #1d4ed8;              /* blue-700 hover */
    --accent: #2563eb;             /* blue accent */
    --accent-strong: #1d4ed8;      /* blue-700 for links */
    --accent-soft: #eff6ff;        /* blue-50 active pill */

    --primary-gradient: linear-gradient(135deg, #2563eb, #1d4ed8);
    --primary-glow: rgba(37, 99, 235, 0.25);

    --text-main: #334155;          /* slate-700 body */
    --text-muted: #64748b;         /* slate-500 */
    --text-bright: #0f172a;        /* slate-900 headings */

    /* Semantic Colors */
    --color-success: #16a34a;
    --color-success-bg: rgba(22, 163, 74, 0.10);
    --color-warning: #d97706;
    --color-warning-bg: rgba(217, 119, 6, 0.12);
    --color-danger: #ef4444;
    --color-danger-bg: rgba(239, 68, 68, 0.10);
    --color-info: #0ea5e9;
    --color-info-bg: rgba(14, 165, 233, 0.10);

    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.04), 0 1px 3px rgba(15, 23, 42, 0.06);
    --shadow-md: 0 4px 16px -6px rgba(15, 23, 42, 0.12), 0 2px 8px -4px rgba(15, 23, 42, 0.08);
    --shadow-lg: 0 24px 48px -16px rgba(15, 23, 42, 0.18);

    --transition-fast: 0.2s ease;
    --transition-normal: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* 2. Global Reset & Body */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: var(--font-primary);
}

body {
    background-color: var(--bg-main);
    color: var(--text-main);
    min-height: 100vh;
    min-height: 100dvh; /* mobile browsers: track the dynamic toolbar */
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    transition: background-color var(--transition-normal), color var(--transition-normal);
    background-image:
        radial-gradient(at 100% 0%, rgba(37, 99, 235, 0.05) 0px, transparent 55%),
        radial-gradient(at 0% 100%, rgba(14, 165, 233, 0.04) 0px, transparent 55%);
    background-attachment: fixed;
}

a {
    color: inherit;
    text-decoration: none;
}

/* Elegant serif for section/card titles; numbers and small labels stay sans */
h3 {
    font-family: var(--font-display);
    font-weight: 600;
    letter-spacing: -0.01em;
}
.metric-info h3 {
    font-family: var(--font-primary);
    letter-spacing: 0;
}

button, input, select, textarea {
    font-family: inherit;
    font-size: inherit;
    outline: none;
}

/* The reset above strips the browser focus ring, so restore one for
   keyboard users on the elements that lost it. */
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
a:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

/* Password show/hide toggle (injected by setupPasswordToggles) */
.pwd-wrap {
    position: relative;
    display: block;
}
.pwd-wrap input {
    padding-right: 44px;
}
.pwd-toggle {
    position: absolute;
    top: 50%;
    right: 6px;
    transform: translateY(-50%);
    background: none;
    border: none;
    cursor: pointer;
    padding: 6px;
    color: var(--text-muted);
    display: inline-flex;
    align-items: center;
}
.pwd-toggle:hover {
    color: var(--text-main);
}
.pwd-toggle i, .pwd-toggle svg {
    width: 18px;
    height: 18px;
}

::selection {
    background: rgba(37, 99, 235, 0.15);
}

/* Custom Scrollbar */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}
::-webkit-scrollbar-track {
    background: transparent;
}
::-webkit-scrollbar-thumb {
    background: var(--border-strong);
    border-radius: 10px;
}
::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

/* 3. Reusable Surfaces & Core Components */
.glass-container {
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
}

.card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 1.5rem;
    box-shadow: var(--shadow-sm);
    transition: transform var(--transition-fast), box-shadow var(--transition-fast), border-color var(--transition-fast);
}
.card:hover {
    transform: translateY(-2px);
    border-color: var(--border-strong);
    box-shadow: var(--shadow-md);
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 0.75rem 1.5rem;
    font-weight: 600;
    letter-spacing: 0.01em;
    border-radius: var(--radius-md);
    border: 1px solid transparent;
    cursor: pointer;
    transition: all var(--transition-normal);
}

.btn-primary {
    background: var(--primary-gradient);
    color: #ffffff;
    box-shadow: 0 4px 14px var(--primary-glow);
}
.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 8px 22px var(--primary-glow);
    filter: brightness(1.06);
}
.btn-primary:active {
    transform: translateY(1px);
}
/* Consistent press feedback for every button variant (only primary had it) */
.btn:active { transform: translateY(1px); }

.btn-secondary {
    background: var(--bg-surface);
    border: 1px solid var(--border-strong);
    color: var(--ink);
}
.btn-secondary:hover {
    background: var(--bg-subtle);
    border-color: var(--ink);
    color: var(--ink);
}

.btn-danger {
    background: var(--color-danger);
    color: #ffffff;
    box-shadow: 0 4px 14px rgba(239, 68, 68, 0.2);
}
.btn-danger:hover {
    filter: brightness(1.05);
    box-shadow: 0 6px 20px rgba(239, 68, 68, 0.28);
}

.btn-success {
    background: var(--color-success);
    color: #ffffff;
    box-shadow: 0 4px 14px rgba(22, 163, 74, 0.2);
}
.btn-success:hover {
    filter: brightness(1.05);
    box-shadow: 0 6px 20px rgba(22, 163, 74, 0.28);
}

/* Input Fields */
.form-group {
    margin-bottom: 1.25rem;
}
.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-size: 0.8rem;
    font-weight: 600;
    letter-spacing: 0.02em;
    color: var(--text-muted);
}
.form-control {
    width: 100%;
    padding: 0.75rem 1rem;
    border-radius: var(--radius-md);
    background: var(--bg-surface);
    border: 1px solid var(--border-strong);
    color: var(--text-main);
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}
.form-control::placeholder {
    color: #a7abb2;
}
.form-control:focus {
    border-color: var(--ink);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

/* Status Badges */
.badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.25rem 0.75rem;
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 0.02em;
    border-radius: var(--radius-sm);
    text-transform: capitalize;
    white-space: nowrap;
}
/* Alert-feed action chips: one fixed width, label centered (fits the longest
   action type, geofence_breach_out) */
.badge-action {
    width: 148px;
    justify-content: center;
}
/* Alerts feed: headers on one line and centered; short-value columns
   (Employee ID, Action Type) centered to match — long text stays left */
#dashboardAlertsTable th {
    text-align: center;
    white-space: nowrap;
}
#dashboardAlertsTable td:nth-child(2),
#dashboardAlertsTable td:nth-child(3),
#dashboardAlertsTable td:nth-child(4) {
    text-align: center;
}
.badge-present {
    background: var(--color-success-bg);
    color: var(--color-success);
}
.badge-late {
    background: var(--color-warning-bg);
    color: var(--color-warning);
}
.badge-absent {
    background: var(--color-danger-bg);
    color: var(--color-danger);
}
.badge-half-day {
    background: var(--color-info-bg);
    color: var(--color-info);
}
.badge-on-leave {
    background: rgba(13, 148, 136, 0.14);
    color: #0d9488;
}

/* "Estimated" (auto check-out) / "Fixed" (corrected) record markers */
.record-tag {
    display: inline-block;
    margin-left: 6px;
    padding: 1px 7px;
    border-radius: 999px;
    font-size: 0.62rem;
    font-weight: 700;
    letter-spacing: 0.02em;
    text-transform: uppercase;
    background: rgba(217, 119, 6, 0.14);
    color: #d97706;
    vertical-align: middle;
    white-space: nowrap;
}
.record-tag.corrected {
    background: rgba(37, 99, 235, 0.12);
    color: #2563eb;
}

/* --- Tap-target baseline (audit #7): 44px for standalone controls, 36px for
   table-inline actions (documented deviation — keeps data rows usable) --- */
.btn { min-height: 44px; }
.sidebar-menu li a,
.mobile-nav-item,
.topbar-icon-btn,
.modal-close,
.view-btn,
.mini-cal-nav button,
.profile-menu-item { min-height: 44px; min-width: 44px; }
.data-table .btn { min-height: 36px; min-width: 36px; }

/* Mini calendar: weekly-offs dimmed, holidays teal */
.mini-cal-day.offday > span:first-child { opacity: 0.45; }
.mini-cal-day.holiday > span:first-child { color: #0d9488; font-weight: 700; }

/* 4. Login Layout */
.login-wrapper {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    min-height: 100dvh;
    padding: 1.5rem;
}

.login-card {
    width: 100%;
    max-width: 440px;
    padding: 2.75rem 2.25rem;
    text-align: center;
}

.login-header {
    margin-bottom: 2rem;
}
.login-header h1 {
    font-family: var(--font-display);
    font-size: 1.9rem;
    font-weight: 600;
    letter-spacing: -0.01em;
    margin-bottom: 0.5rem;
    color: var(--ink);
}
.login-header p {
    color: var(--text-muted);
    font-size: 0.95rem;
    line-height: 1.5;
}

/* 5. Modals */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    height: 100dvh;
    background: rgba(15, 23, 42, 0.45);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    opacity: 0;
    pointer-events: none;
    visibility: hidden;
    /* visibility flips to hidden only once the fade-out finishes (CSS discrete-
       transition rule: with 'visible' as one endpoint, the non-visible value
       only takes effect at the end of the transition) — same idiom used for
       .admin-sidebar's mobile drawer below. Keeps keyboard focus out of
       inactive modals without cutting the fade animation short. */
    transition: opacity var(--transition-normal), visibility var(--transition-normal);
}
.modal-overlay.active {
    opacity: 1;
    pointer-events: auto;
    visibility: visible;
}
.modal-content {
    width: 90%;
    max-width: 600px;
    max-height: 90vh;
    overflow-y: auto;
    padding: 2rem;
    transform: translateY(20px);
    transition: transform var(--transition-normal);
}
.modal-overlay.active .modal-content {
    transform: translateY(0);
}
.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}
.modal-header h2 {
    font-family: var(--font-display);
    font-size: 1.35rem;
    font-weight: 600;
    color: var(--text-bright);
}
.modal-close {
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 1.5rem;
    line-height: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.modal-close:hover {
    color: var(--text-bright);
}

/* 6. Notification Toast */
.toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 2000;
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.toast {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 1rem 1.5rem;
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-left: 4px solid var(--color-info);
    border-radius: var(--radius-md);
    color: var(--text-main);
    box-shadow: var(--shadow-md);
    transform: translateX(120%);
    transition: transform var(--transition-normal);
}
.toast.show {
    transform: translateX(0);
}
.toast-success { border-left-color: var(--color-success); }
.toast-error { border-left-color: var(--color-danger); }
.toast-warning { border-left-color: var(--color-warning); }

/* Shimmer skeleton loaders + polished empty states for tables */
.table-state {
    text-align: center;
    color: var(--text-muted);
    padding: 2.25rem 1rem;
}
.table-state .ts-icon {
    display: inline-flex;
    width: 44px;
    height: 44px;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: var(--bg-subtle);
    color: var(--text-muted);
    margin-bottom: 0.6rem;
}
.table-state .ts-msg { font-size: 0.9rem; }
.skeleton {
    display: block;
    height: 12px;
    border-radius: 6px;
    background: linear-gradient(90deg, var(--bg-subtle) 25%, var(--border-color) 37%, var(--bg-subtle) 63%);
    background-size: 400% 100%;
    animation: skeleton-shimmer 1.4s ease infinite;
}
@keyframes skeleton-shimmer {
    0% { background-position: 100% 50%; }
    100% { background-position: 0 50%; }
}
@media (prefers-reduced-motion: reduce) {
    .skeleton { animation: none; }
}

/* Loading animations */
.spinner {
    border: 3px solid rgba(37, 99, 235, 0.15);
    width: 24px;
    height: 24px;
    border-radius: 50%;
    border-left-color: var(--ink);
    animation: spin 1s linear infinite;
}
@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* 7. ADMIN PANEL STRUCTURAL LAYOUT */
.admin-layout {
    display: flex;
    min-height: 100vh;
}

.admin-sidebar {
    width: 300px;
    padding: 2rem 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 2.5rem;
    border-right: 1px solid var(--border-color);
    box-shadow: none;
}
.sidebar-logo {
    display: flex;
    align-items: center;
    gap: 8px;
}
.logo-ca {
    height: 38px;
    width: auto;
    flex-shrink: 0;
}
.logo-ppn {
    height: 38px;
    width: auto;
    flex-shrink: 0;
}
.logo-tile {
    width: 40px;
    height: 40px;
    border-radius: 11px;
    background: var(--primary-gradient);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    font-size: 1.05rem;
    box-shadow: 0 4px 12px var(--primary-glow);
    flex-shrink: 0;
}
.sidebar-logo h2 {
    font-family: var(--font-display);
    font-size: 1.2rem;
    font-weight: 700;
    letter-spacing: -0.01em;
    color: var(--text-bright);
    line-height: 1.1;
}
.logo-sub {
    font-size: 0.7rem;
    color: var(--text-muted);
    letter-spacing: 0.02em;
    margin-top: 1px;
}
.sidebar-menu {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}
.sidebar-menu li a {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 0.7rem 0.85rem;
    border-radius: 10px;
    color: var(--text-muted);
    font-weight: 500;
    transition: all var(--transition-fast);
}
.sidebar-menu li a:hover {
    background: var(--bg-subtle);
    color: var(--text-bright);
}
.sidebar-menu li.active a {
    background: var(--accent-soft);
    color: var(--ink);
    font-weight: 600;
}

.admin-main {
    flex: 1;
    padding: 2rem;
    display: flex;
    flex-direction: column;
    gap: 2rem;
    overflow-y: auto;
}

.admin-topbar {
    display: flex;
    align-items: center;
    gap: 1.25rem;
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 0.7rem 1.1rem;
    box-shadow: var(--shadow-sm);
}
.breadcrumb {
    display: flex;
    align-items: center;
    gap: 7px;
    color: var(--text-muted);
    font-size: 0.9rem;
    white-space: nowrap;
}
.breadcrumb i { width: 15px; height: 15px; }
.breadcrumb strong { color: var(--text-bright); font-weight: 600; }
.topbar-search {
    flex: 1;
    max-width: 440px;
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--bg-subtle);
    border: 1px solid transparent;
    border-radius: 10px;
    padding: 0.5rem 0.85rem;
    transition: all var(--transition-fast);
}
.topbar-search i { width: 18px; height: 18px; color: var(--text-muted); flex-shrink: 0; }
.topbar-search input { flex: 1; background: transparent; border: none; color: var(--text-main); font-size: 0.9rem; }
.topbar-search:focus-within { background: var(--bg-surface); border-color: var(--ink); box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.10); }
.topbar-actions { display: flex; align-items: center; gap: 1rem; margin-left: auto; }
.topbar-icon-btn {
    position: relative;
    width: 40px; height: 40px;
    border-radius: 10px;
    border: 1px solid var(--border-color);
    background: var(--bg-surface);
    color: var(--text-muted);
    cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    transition: all var(--transition-fast);
}
.topbar-icon-btn:hover { background: var(--bg-subtle); color: var(--text-bright); }
.notif-dot {
    position: absolute; top: 8px; right: 9px;
    width: 8px; height: 8px; border-radius: 50%;
    background: var(--color-danger); border: 2px solid #fff;
}

/* --- In-app notifications bell + dropdown panel --- */
.notif-wrap { position: relative; }
.notif-badge {
    position: absolute; top: 2px; right: 3px;
    min-width: 17px; height: 17px; padding: 0 4px;
    border-radius: 9px; background: var(--color-danger); color: #fff;
    border: 2px solid var(--bg-surface);
    font-size: 0.64rem; font-weight: 700; line-height: 1;
    display: flex; align-items: center; justify-content: center;
    font-variant-numeric: tabular-nums;
}
.notif-panel {
    position: absolute; top: calc(100% + 8px); right: 0;
    width: 340px; max-width: 90vw;
    background: var(--bg-surface); border: 1px solid var(--border-color);
    border-radius: var(--radius-md); box-shadow: var(--shadow-lg);
    display: none; z-index: 600; overflow: hidden;
}
.notif-panel.open { display: block; }
.notif-panel-head {
    display: flex; align-items: center; justify-content: space-between;
    padding: 0.7rem 0.9rem; border-bottom: 1px solid var(--border-color);
}
.notif-panel-head strong { font-size: 0.92rem; color: var(--text-bright); }
.notif-markall {
    border: none; background: transparent; color: var(--accent);
    font-size: 0.78rem; font-weight: 600; cursor: pointer; padding: 4px 6px; border-radius: 6px;
}
.notif-markall:hover { background: var(--bg-subtle); }
.notif-markall:disabled { color: var(--text-muted); cursor: default; background: transparent; }
.notif-list { max-height: 360px; overflow-y: auto; }
.notif-item {
    display: flex; gap: 10px; padding: 0.7rem 0.9rem;
    border-bottom: 1px solid var(--border-color);
    font-size: 0.85rem; color: var(--text-main);
    cursor: pointer; transition: background var(--transition-fast);
}
.notif-item:hover { background: var(--bg-subtle); }
.notif-item:last-child { border-bottom: none; }
.notif-item.unread { background: var(--bg-subtle); }
.notif-dotmark {
    flex-shrink: 0; width: 7px; height: 7px; border-radius: 50%;
    background: var(--accent); margin-top: 6px; visibility: hidden;
}
.notif-item.unread .notif-dotmark { visibility: visible; }
.notif-item-body { flex: 1; min-width: 0; }
.notif-item-msg { color: var(--text-bright); line-height: 1.35; }
.notif-item-time { font-size: 0.72rem; color: var(--text-muted); margin-top: 2px; }
.notif-empty { padding: 1.75rem 1rem; text-align: center; color: var(--text-muted); font-size: 0.85rem; }

/* --- Custom themed date picker (enhances hidden date inputs) --- */
.dp-field { position: relative; }
.dp-trigger {
    display: inline-flex; align-items: center; justify-content: space-between; gap: 8px;
    width: 100%; text-align: left; cursor: pointer;
    color: var(--text-bright);
}
.dp-trigger .dp-trigger-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dp-trigger.dp-empty .dp-trigger-label { color: var(--text-muted); }
.dp-trigger i, .dp-trigger svg { width: 16px; height: 16px; color: var(--text-muted); flex-shrink: 0; }
.dp-pop {
    position: fixed; z-index: 1200;  /* on <body>, anchored via JS — escapes card overflow/stacking */
    width: 280px; max-width: 92vw;
    background: var(--bg-surface); border: 1px solid var(--border-color);
    border-radius: var(--radius-md); box-shadow: var(--shadow-lg);
    padding: 12px; display: none;
}
.dp-pop.open { display: block; }
.dp-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.dp-head strong { font-size: 0.9rem; color: var(--text-bright); }
.dp-nav {
    width: 30px; height: 30px; border-radius: 8px; border: 1px solid var(--border-color);
    background: var(--bg-surface); color: var(--text-main); cursor: pointer;
    display: inline-flex; align-items: center; justify-content: center;
    transition: background var(--transition-fast);
}
.dp-nav:hover { background: var(--bg-subtle); color: var(--text-bright); }
.dp-nav i, .dp-nav svg { width: 16px; height: 16px; }
.dp-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; }
.dp-wd { text-align: center; font-size: 0.68rem; font-weight: 700; color: var(--text-muted); padding: 4px 0; }
.dp-day {
    aspect-ratio: 1 / 1; border: none; background: transparent; border-radius: 8px;
    color: var(--text-main); font-size: 0.82rem; cursor: pointer;
    display: inline-flex; align-items: center; justify-content: center;
    transition: background var(--transition-fast);
}
.dp-day:hover:not(.dp-disabled):not(.dp-selected) { background: var(--bg-subtle); }
.dp-day.dp-today { box-shadow: inset 0 0 0 1.5px var(--accent); font-weight: 700; }
.dp-day.dp-selected { background: var(--accent); color: #fff; font-weight: 700; }
.dp-day.dp-disabled { color: var(--text-muted); opacity: 0.4; cursor: default; }
.dp-blank { visibility: hidden; }
.dp-foot { display: flex; justify-content: space-between; margin-top: 8px; padding-top: 8px; border-top: 1px solid var(--border-color); }
.dp-action { border: none; background: transparent; color: var(--accent); font-size: 0.8rem; font-weight: 600; cursor: pointer; padding: 5px 8px; border-radius: 6px; }
.dp-action:hover { background: var(--bg-subtle); }

/* --- Custom themed time picker (enhances hidden time inputs) --- */
.tp-field { position: relative; }
.tp-trigger {
    display: inline-flex; align-items: center; justify-content: space-between; gap: 8px;
    width: 100%; text-align: left; cursor: pointer; color: var(--text-bright);
}
.tp-trigger .tp-trigger-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tp-trigger.tp-empty .tp-trigger-label { color: var(--text-muted); }
.tp-trigger i, .tp-trigger svg { width: 16px; height: 16px; color: var(--text-muted); flex-shrink: 0; }
.tp-pop {
    position: fixed; z-index: 1200;
    width: 240px; max-width: 92vw;
    background: var(--bg-surface); border: 1px solid var(--border-color);
    border-radius: var(--radius-md); box-shadow: var(--shadow-lg);
    padding: 8px; display: none;
}
.tp-pop.open { display: block; }
.tp-cols { display: grid; grid-template-columns: 1fr 1fr auto; gap: 6px; }
.tp-col { max-height: 208px; overflow-y: auto; display: flex; flex-direction: column; gap: 2px; scrollbar-width: thin; }
.tp-col::-webkit-scrollbar { width: 6px; }
.tp-ampm { justify-content: flex-start; }
.tp-opt {
    border: none; background: transparent; border-radius: 8px;
    padding: 7px 6px; font-size: 0.85rem; color: var(--text-main); cursor: pointer;
    font-variant-numeric: tabular-nums; text-align: center;
    transition: background var(--transition-fast);
}
.tp-opt:hover { background: var(--bg-subtle); }
.tp-opt.tp-selected { background: var(--accent); color: #fff; font-weight: 700; }
.tp-ampm .tp-opt { padding: 9px 12px; }
.tp-foot { display: flex; justify-content: space-between; margin-top: 6px; padding-top: 6px; border-top: 1px solid var(--border-color); }
.tp-action { border: none; background: transparent; color: var(--accent); font-size: 0.8rem; font-weight: 600; cursor: pointer; padding: 5px 8px; border-radius: 6px; }
.tp-action:hover { background: var(--bg-subtle); }

/* --- Custom themed select (listbox) --- */
.sel-field { position: relative; }
.sel-trigger {
    display: inline-flex; align-items: center; justify-content: space-between; gap: 8px;
    width: 100%; text-align: left; cursor: pointer; color: var(--text-bright);
}
.sel-trigger .sel-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sel-trigger.sel-empty .sel-label { color: var(--text-muted); }
.sel-trigger i, .sel-trigger svg {
    width: 16px; height: 16px; color: var(--text-muted); flex-shrink: 0;
    transition: transform var(--transition-fast);
}
.sel-trigger[aria-expanded="true"] i, .sel-trigger[aria-expanded="true"] svg { transform: rotate(180deg); }
.sel-pop {
    position: fixed; z-index: 1200;
    min-width: 180px; max-width: 92vw; max-height: 288px; overflow-y: auto;
    background: var(--bg-surface); border: 1px solid var(--border-color);
    border-radius: var(--radius-md); box-shadow: var(--shadow-lg);
    padding: 6px; display: none;
}
.sel-pop.open { display: block; }
.sel-opt {
    display: flex; align-items: center; width: 100%; text-align: left;
    border: none; background: transparent; border-radius: 8px;
    padding: 10px 12px; min-height: 44px;      /* comfortable touch target */
    font-size: 0.88rem; color: var(--text-main); cursor: pointer;
    transition: background var(--transition-fast);
}
.sel-opt:hover:not(:disabled) { background: var(--bg-subtle); }
.sel-opt.sel-active:not(:disabled):not(.sel-selected) { background: var(--bg-subtle); }
.sel-opt.sel-selected { background: var(--accent); color: #fff; font-weight: 600; }
.sel-opt.sel-selected.sel-active { box-shadow: inset 0 0 0 2px var(--accent-strong); }
.sel-opt:disabled { color: var(--text-muted); opacity: 0.55; cursor: default; }

/* Pending-request count dot on sidebar nav items */
.nav-dot {
    margin-left: auto;
    min-width: 18px; height: 18px; padding: 0 5px;
    border-radius: 9px; background: var(--color-danger); color: #fff;
    font-size: 0.66rem; font-weight: 700; line-height: 1;
    display: inline-flex; align-items: center; justify-content: center;
    font-variant-numeric: tabular-nums;
}
.topbar-role { font-size: 0.75rem; color: var(--text-muted); }
.admin-header h1 { font-family: var(--font-display); font-size: 1.4rem; font-weight: 700; color: var(--text-bright); }
.admin-profile {
    display: flex;
    align-items: center;
    gap: 12px;
}
.admin-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--primary-gradient);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-weight: 600;
    font-size: 0.9rem;
}

/* KPI Stats cards */
.metrics-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1.5rem;
}
/* Admin overview: all 6 KPI tiles on one row; 3+3 on narrower screens (never an orphan row) */
#tab-overview .metrics-grid {
    grid-template-columns: repeat(6, minmax(0, 1fr));
    gap: 1.25rem;
}
@media (max-width: 1500px) {
    #tab-overview .metrics-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
}
@media (max-width: 700px) {
    #tab-overview .metrics-grid {
        grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    }
}
/* Reports summary: all 5 KPI cards on one row; 3+2 on narrower screens */
#reportSummary {
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 1.25rem;
}
@media (max-width: 1300px) {
    #reportSummary {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
}
@media (max-width: 700px) {
    #reportSummary {
        grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    }
}
.metric-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.metric-clickable {
    cursor: pointer;
    transition: transform 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
}
.metric-clickable:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}
.metric-clickable:hover {
    transform: translateY(-3px);
    border-color: var(--accent);
    box-shadow: var(--shadow-md);
}
.metric-info h3 {
    font-size: 0.8rem;
    color: var(--text-muted);
    font-weight: 600;
    letter-spacing: 0.02em;
    margin-bottom: 0.5rem;
}
.metric-info p {
    font-family: var(--font-number);
    font-size: 1.85rem;
    font-weight: 600;
    letter-spacing: 0;
    color: var(--text-bright);
    font-variant-numeric: tabular-nums;
}
.metric-icon {
    width: 48px;
    height: 48px;
    flex-shrink: 0; /* never squished into a rectangle by tight tiles */
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Admin KPI tiles (dashboard overview + reports summary): compact equal boxes;
   one-line label across the full tile width, number below-left, icon square
   floating bottom-right */
#tab-overview .metric-card,
#reportSummary .metric-card {
    display: block;
    position: relative;
    min-height: 96px;
    padding: 1rem 1.1rem;
}
#tab-overview .metric-card .metric-info h3,
#reportSummary .metric-card .metric-info h3 {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-bottom: 0.4rem;
}
#tab-overview .metric-card .metric-info p,
#reportSummary .metric-card .metric-info p {
    margin: 0;
}
#tab-overview .metric-card .metric-icon,
#reportSummary .metric-card .metric-icon {
    position: absolute;
    right: 14px;
    bottom: 14px;
}

/* Dashboard Charts Grid */
.charts-grid {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 1.5rem;
}
@media (max-width: 1024px) {
    .charts-grid {
        grid-template-columns: 1fr;
    }
}

/* Leaflet maps container */
.map-frame {
    height: 380px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
    z-index: 10;
}

/* Beautiful Table Styling */
.table-container {
    overflow: auto;              /* both axes; enables sticky header + horizontal scroll */
    max-height: 72vh;            /* long tables scroll inside; short ones stay natural height */
    -webkit-overflow-scrolling: touch;
    margin-top: 1rem;
}
.data-table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
}
.data-table th {
    padding: 0.85rem 1rem;
    border-bottom: 1px solid var(--border-strong);
    color: var(--text-muted);
    font-weight: 600;
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    white-space: nowrap;    /* headers never wrap; the table scrolls if it must */
    text-align: center;     /* headers centred; row values stay left-aligned */
}
.data-table td {
    padding: 1rem;
    border-bottom: 1px solid var(--border-color);
    vertical-align: middle;
}
.data-table tbody tr {
    transition: background var(--transition-fast);
}
.data-table tr:hover {
    background: var(--bg-subtle);
}

/* Employee Directory grid */
.directory-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 1.25rem;
}
.directory-card {
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 1.25rem;
    box-shadow: var(--shadow-sm);
    transition: transform var(--transition-fast), box-shadow var(--transition-fast), border-color var(--transition-fast);
}
.directory-card:hover {
    transform: translateY(-2px);
    border-color: var(--border-strong);
    box-shadow: var(--shadow-md);
}
.directory-avatar {
    width: 52px;
    height: 52px;
    border-radius: 14px;
    background: var(--accent-soft);
    color: var(--ink);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 1.05rem;
    flex-shrink: 0;
}
.directory-contact {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-top: 6px;
    overflow-wrap: anywhere;
}
.directory-contact i { width: 15px; height: 15px; flex-shrink: 0; }

/* Table <-> Cards segmented toggle */
.view-toggle {
    display: inline-flex;
    background: var(--bg-subtle);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 3px;
    gap: 3px;
}
.view-btn {
    width: 34px;
    height: 30px;
    border: none;
    background: transparent;
    border-radius: 7px;
    color: var(--text-muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-fast);
}
.view-btn i { width: 17px; height: 17px; }
.view-btn.active {
    background: var(--bg-surface);
    color: var(--ink);
    box-shadow: var(--shadow-sm);
}

/* Leave balance progress bars */
.leave-progress {
    height: 6px;
    background: var(--bg-subtle);
    border-radius: 999px;
    overflow: hidden;
    margin-top: 8px;
}
.leave-progress-fill {
    height: 100%;
    border-radius: 999px;
    transition: width 0.4s ease;
}

/* 8. EMPLOYEE MOBILE PANEL STRUCTURAL LAYOUT */
.employee-mobile-wrapper {
    display: flex;
    justify-content: center;
    align-items: flex-start;
    padding: 1.5rem 0;
    min-height: 100vh;
}

.employee-mobile-frame {
    width: 100%;
    max-width: 480px;
    padding: 1.5rem;
    border-radius: var(--radius-lg);
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    min-height: 90vh;
    justify-content: flex-start;
}

.employee-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.employee-info h2 {
    font-family: var(--font-display);
    font-size: 1.3rem;
    font-weight: 600;
    color: var(--text-bright);
}
.employee-info p {
    font-size: 0.85rem;
    color: var(--text-muted);
}

/* Circular Clocking Button */
.clock-section {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
    margin: 1rem 0;
}

.clock-btn-container {
    position: relative;
    width: 180px;
    height: 180px;
}

.clock-btn {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    background: var(--primary-gradient);
    border: 6px solid #ffffff;
    color: white;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 6px;
    cursor: pointer;
    font-weight: 700;
    letter-spacing: 0.03em;
    font-size: 1.15rem;
    box-shadow: 0 10px 30px -8px var(--primary-glow), 0 0 0 1px var(--border-color);
    transition: all var(--transition-normal);
}
.clock-btn:hover {
    transform: scale(1.02);
    box-shadow: 0 16px 38px -10px var(--primary-glow), 0 0 0 1px var(--border-color);
}
.clock-btn.checked-in {
    background: linear-gradient(135deg, #16a34a, #15803d);
    box-shadow: 0 12px 32px -10px rgba(22, 163, 74, 0.45), 0 0 0 1px var(--border-color);
}

.pulse-ring {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    border: 2px solid var(--accent);
    opacity: 0;
    animation: pulse 2.5s infinite;
    pointer-events: none;
}
.clock-btn.checked-in ~ .pulse-ring {
    border-color: var(--color-success);
}

@keyframes pulse {
    0% { transform: scale(1); opacity: 0.5; }
    100% { transform: scale(1.3); opacity: 0; }
}

.live-time {
    font-family: var(--font-number);
    font-size: 2rem;
    font-weight: 600;
    letter-spacing: 0;
    color: var(--text-bright);
    font-variant-numeric: tabular-nums;
}
.live-date {
    font-size: 0.85rem;
    color: var(--text-muted);
}

/* Webcam capture layout */
.webcam-container {
    width: 100%;
    height: 240px;
    border-radius: var(--radius-md);
    background: #000;
    position: relative;
    overflow: hidden;
    border: 1px solid var(--border-color);
}
.webcam-video {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transform: scaleX(-1); /* Mirror view */
}
.webcam-canvas {
    display: none;
}
.webcam-overlay {
    position: absolute;
    bottom: 10px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0,0,0,0.6);
    padding: 4px 12px;
    border-radius: 50px;
    font-size: 0.75rem;
    color: white;
}

/* Summary stats layout for mobile */
.stats-summary-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.75rem;
    text-align: center;
}
.stat-item {
    background: var(--bg-subtle);
    border: 1px solid var(--border-color);
    padding: 0.85rem 0.5rem;
    border-radius: var(--radius-md);
}
.stat-item h4 {
    font-size: 0.72rem;
    color: var(--text-muted);
    font-weight: 600;
    letter-spacing: 0.02em;
    margin-bottom: 0.25rem;
}
.stat-item p {
    font-family: var(--font-number);
    font-size: 1.3rem;
    font-weight: 600;
    color: var(--text-bright);
    font-variant-numeric: tabular-nums;
}

/* History logs list */
.history-logs-wrapper {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}
.history-log-card {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem;
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    transition: border-color var(--transition-fast);
}
.history-log-card:hover {
    border-color: var(--border-strong);
}
.log-date-info h4 {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-bright);
}
.log-date-info p {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 0.15rem;
}
.log-status-info {
    text-align: right;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 4px;
}
.log-status-info span {
    font-size: 0.75rem;
    color: var(--text-muted);
}
.photo-thumbnail {
    width: 32px;
    height: 32px;
    border-radius: 4px;
    object-fit: cover;
    border: 1px solid var(--border-color);
    cursor: pointer;
}

/* Responsive filters */
.filter-form {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    align-items: flex-end;
}
.filter-form .form-group {
    margin-bottom: 0;
    flex: 1;
    min-width: 150px;
}
/* Date fields keep a fixed comfortable width so dd-mm-yyyy never truncates;
   the search box absorbs the leftover space instead. */
.filter-form .form-group.fg-date { flex: 0 0 180px; min-width: 180px; }
.filter-form .form-group.fg-search { flex: 3; min-width: 180px; }
@media (max-width: 640px) {
    .filter-form .form-group.fg-date { flex: 1 1 150px; min-width: 150px; }
}

/* 8b. Profile chip + dropdown (employee header) */
.profile-chip-wrap {
    position: relative;
}
.profile-chip {
    display: flex;
    align-items: center;
    gap: 14px;
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: 999px;
    padding: 8px 8px 8px 20px;
    cursor: pointer;
    box-shadow: var(--shadow-sm);
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}
.profile-chip:hover {
    border-color: var(--border-strong);
    box-shadow: var(--shadow-md);
}
.profile-chip .admin-avatar {
    width: 46px;
    height: 46px;
    font-size: 1rem;
}
.profile-chip-text {
    text-align: right;
}
.profile-chip-text h4 {
    font-size: 1rem;
    color: var(--text-bright);
    font-weight: 600;
    line-height: 1.25;
    white-space: nowrap;
}
.profile-chip-text p {
    font-size: 0.78rem;
    color: var(--text-muted);
    white-space: nowrap;
}
.profile-menu {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    min-width: 185px;
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    padding: 6px;
    display: none;
    z-index: 600;
}
.profile-menu.open {
    display: block;
}
.profile-menu-item {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 0.6rem 0.75rem;
    border: none;
    background: transparent;
    border-radius: 8px;
    color: var(--text-main);
    font-size: 0.88rem;
    font-weight: 500;
    cursor: pointer;
    text-align: left;
    transition: background var(--transition-fast), color var(--transition-fast);
}
.profile-menu-item:hover {
    background: var(--bg-subtle);
    color: var(--text-bright);
}
.profile-menu-item.danger {
    color: var(--color-danger);
}
.profile-menu-item.danger:hover {
    background: var(--color-danger-bg);
    color: var(--color-danger);
}
.profile-menu-item i,
.profile-menu-item svg {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
}

/* 8c. Mini attendance calendar (Today's Status card) */
.mini-calendar {
    margin-top: 1.4rem;
    border-top: 1px solid var(--border-color);
    padding-top: 1.1rem;
}
.mini-cal-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.7rem;
}
.mini-cal-kicker {
    font-size: 0.62rem;
    font-weight: 700;
    letter-spacing: 0.09em;
    text-transform: uppercase;
    color: var(--text-muted);
    margin-bottom: 2px;
}
.mini-cal-head h4 {
    font-family: var(--font-display);
    font-size: 1.05rem;
    font-weight: 600;
    color: var(--text-bright);
    letter-spacing: -0.01em;
}
.mini-cal-nav {
    display: flex;
    gap: 6px;
}
.mini-cal-nav button {
    width: 28px;
    height: 28px;
    border: 1px solid var(--border-color);
    background: var(--bg-surface);
    border-radius: 8px;
    color: var(--text-muted);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-fast);
}
.mini-cal-nav button:hover {
    background: var(--bg-subtle);
    color: var(--text-bright);
}
.mini-cal-nav button i,
.mini-cal-nav button svg {
    width: 15px;
    height: 15px;
}
.mini-cal-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 2px;
    text-align: center;
}
.mini-cal-dow {
    font-size: 0.64rem;
    font-weight: 700;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    padding: 4px 0;
}
.mini-cal-day {
    height: 40px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--text-main);
    border-radius: 10px;
    font-variant-numeric: tabular-nums;
    transition: background var(--transition-fast);
}
.mini-cal-day:not(.empty):hover { background: var(--bg-subtle); }
.mini-cal-num {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    line-height: 1;
}
.mini-cal-day .dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
}
.mini-cal-day.today .mini-cal-num {
    background: var(--accent);
    color: #fff;
    font-weight: 700;
    box-shadow: 0 2px 8px var(--primary-glow);
}
.mini-cal-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 6px 12px;
    margin-top: 0.7rem;
    font-size: 0.68rem;
    color: var(--text-muted);
}
.mini-cal-legend span {
    display: inline-flex;
    align-items: center;
    gap: 4px;
}
.mini-cal-legend .dot {
    width: 9px;
    height: 9px;
    border-radius: 50%;
    flex-shrink: 0;
}

/* Profile modal detail rows */
.profile-detail-list {
    display: flex;
    flex-direction: column;
}
.profile-detail-row {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 1rem;
    padding: 0.65rem 0;
    border-bottom: 1px solid var(--border-color);
    font-size: 0.9rem;
}
.profile-detail-row:last-child {
    border-bottom: none;
}
.profile-detail-row .label {
    color: var(--text-muted);
    font-size: 0.8rem;
    font-weight: 600;
    flex-shrink: 0;
}
.profile-detail-row .value {
    color: var(--text-bright);
    text-align: right;
    overflow-wrap: anywhere;
}

/* 9. RESPONSIVE — MOBILE & TABLET OPTIMIZATION */

/* Grid children can contain wide tables/canvases — let them shrink so
   inner scroll containers work instead of blowing the column out */
.charts-grid > *,
.dash-grid > *,
.metrics-grid > *,
.directory-grid > * { min-width: 0; }

/* Mobile-only chrome — hidden on desktop */
.sidebar-toggle { display: none; }
.mobile-topbar { display: none; }
.mobile-bottom-nav { display: none; }

/* Backdrop behind the mobile drawer */
.sidebar-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.45);
    z-index: 1150;
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--transition-normal);
}

/* Bottom navigation items (employee app shell) */
.mobile-nav-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    min-height: 52px;
    padding: 0.3rem 0.25rem;
    background: none;
    border: none;
    border-radius: 12px;
    color: var(--text-muted);
    font-size: 0.68rem;
    font-weight: 600;
    letter-spacing: 0.01em;
    cursor: pointer;
    transition: color var(--transition-fast), background var(--transition-fast);
}
.mobile-nav-item i,
.mobile-nav-item svg {
    width: 22px;
    height: 22px;
}
.mobile-nav-item.active {
    color: var(--ink);
    background: var(--accent-soft);
}

/* Large tablets / small desktops: slim the sidebar down */
@media (max-width: 1100px) {
    .admin-sidebar {
        width: 240px;
        padding: 1.5rem 1rem;
    }
}

/* ===== Tablets & phones (≤ 900px): app-shell layout ===== */
@media (max-width: 900px) {

    /* -- Admin: sidebar becomes a slide-in drawer -- */
    .admin-page .admin-sidebar {
        position: fixed;
        top: 0;
        left: 0;
        bottom: 0;
        z-index: 1200;
        width: min(300px, 85vw);
        padding: 1.5rem 1.25rem calc(1.5rem + env(safe-area-inset-bottom));
        background: var(--bg-surface);
        transform: translateX(-105%);
        visibility: hidden;
        transition: transform var(--transition-normal), visibility var(--transition-normal);
        overflow-y: auto;
    }
    body.sidebar-open .admin-sidebar {
        transform: translateX(0);
        visibility: visible;
        box-shadow: var(--shadow-lg);
    }
    body.sidebar-open {
        overflow: hidden;
    }
    body.sidebar-open .sidebar-backdrop {
        opacity: 1;
        pointer-events: auto;
    }
    .admin-page .sidebar-toggle {
        display: inline-flex;
        flex-shrink: 0;
    }

    /* -- Employee: hide sidebar, use compact top bar + bottom tabs -- */
    .employee-page .admin-sidebar { display: none; }
    .employee-page .mobile-topbar {
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 0.75rem;
        background: var(--bg-surface);
        border: 1px solid var(--border-color);
        border-radius: var(--radius-lg);
        padding: 0.6rem 0.9rem;
        box-shadow: var(--shadow-sm);
    }
    .mobile-topbar .logo-ca,
    .mobile-topbar .logo-ppn { height: 30px; }
    .employee-page .mobile-bottom-nav {
        display: flex;
        position: fixed;
        left: 0;
        right: 0;
        bottom: 0;
        z-index: 950;
        gap: 4px;
        background: var(--bg-surface);
        border-top: 1px solid var(--border-color);
        padding: 0.4rem max(0.6rem, env(safe-area-inset-right)) max(0.4rem, env(safe-area-inset-bottom)) max(0.6rem, env(safe-area-inset-left));
        box-shadow: 0 -6px 20px rgba(15, 23, 42, 0.07);
    }
    /* Keep content clear of the fixed bottom nav */
    .employee-page .admin-main {
        padding-bottom: calc(4.75rem + env(safe-area-inset-bottom));
    }

    /* -- Shared density -- */
    .admin-main {
        padding: 1rem;
        gap: 1.25rem;
    }

    /* Topbar wraps; search drops to its own full-width row */
    .admin-topbar {
        flex-wrap: wrap;
        gap: 0.6rem 0.75rem;
        padding: 0.6rem 0.75rem;
    }
    .topbar-search {
        order: 5;
        flex-basis: 100%;
        max-width: none;
    }
    .topbar-actions { gap: 0.6rem; }

    /* Forms: 16px font prevents iOS auto-zoom on focus */
    .form-control { font-size: 1rem; }
    .topbar-search input { font-size: 1rem; }
    .filter-form { gap: 0.75rem; }
    .filter-form .form-group { min-width: calc(50% - 0.375rem); }

    /* Tables scroll sideways instead of crushing columns */
    .data-table { min-width: 640px; }
    .data-table th {
        white-space: nowrap;
        padding: 0.7rem 0.85rem;
    }
    .data-table td { padding: 0.75rem 0.85rem; }

    /* Comfortable touch targets */
    .view-btn { width: 40px; height: 36px; }
}

/* ===== Phones (≤ 640px): component fit & typography ===== */
@media (max-width: 640px) {
    .admin-main {
        padding: 0.85rem;
        gap: 1rem;
    }
    .card { padding: 1.1rem; }

    /* KPI cards: two per row; an odd trailing card spans the full width */
    .metrics-grid,
    #tab-overview .metrics-grid,
    #reportSummary {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 0.75rem;
    }
    .metrics-grid > .card:last-child:nth-child(odd),
    #reportSummary > .card:last-child:nth-child(odd) { grid-column: 1 / -1; }
    /* Narrow 2-up cards can't hold the desktop single-line labels — let them
       wrap again (undo the overview/reports nowrap) and grow to fit. */
    #tab-overview .metric-card .metric-info h3,
    #reportSummary .metric-card .metric-info h3 {
        white-space: normal;
    }
    #tab-overview .metric-card,
    #reportSummary .metric-card { min-height: 92px; }
    .metric-info h3 {
        font-size: 0.72rem;
        margin-bottom: 0.35rem;
    }
    .metric-info p { font-size: 1.45rem; }
    .metric-icon {
        width: 38px;
        height: 38px;
        border-radius: 10px;
    }
    .metric-icon i,
    .metric-icon svg {
        width: 19px;
        height: 19px;
    }

    .charts-grid { gap: 1rem; }
    .map-frame { height: 300px; }

    /* Topbar: essentials only */
    .breadcrumb span,
    .breadcrumb i,
    .breadcrumb svg { display: none; }
    .breadcrumb strong { font-size: 1rem; }
    .admin-profile > div:first-child { display: none; }

    /* Modals: near-full-width sheets */
    .modal-content {
        width: calc(100vw - 1.5rem);
        max-height: calc(100dvh - 1.5rem);
        padding: 1.25rem;
    }
    .modal-header h2 { font-size: 1.15rem; }

    /* Toasts become full-width banners */
    .toast-container {
        left: 12px;
        right: 12px;
        top: 12px;
    }
    .toast {
        width: 100%;
        padding: 0.85rem 1rem;
        font-size: 0.9rem;
    }

    /* Login card */
    .login-card { padding: 2rem 1.4rem; }

    /* Employee dashboard bits */
    .live-time { font-size: 1.7rem; }
    .dash-grid { gap: 1rem; }

    /* Profile chip: avatar only on phones */
    .profile-chip-text { display: none; }
    .profile-chip { padding: 5px; }
}

/* Respect users who prefer reduced motion */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* ============================================================
   UI/UX Upgrade — motion + glassmorphism (bold, reversible).
   One self-contained block; delete it to fully revert. Motion is
   transform/opacity only and auto-disabled by the reduced-motion
   block above. Glass is limited to chrome + floating overlays
   (sidebar, topbar, modals, menus, popovers) — never data cards.
   ============================================================ */
:root {
    --ease-out-soft: cubic-bezier(0.16, 1, 0.3, 1);
    --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
    --glass: saturate(1.4) blur(16px);
}

/* --- Glassmorphism: chrome + floating overlays --- */
.admin-sidebar {
    background: rgba(255, 255, 255, 0.72);
    -webkit-backdrop-filter: var(--glass);
    backdrop-filter: var(--glass);
}
.mobile-topbar {
    background: rgba(255, 255, 255, 0.70);
    -webkit-backdrop-filter: var(--glass);
    backdrop-filter: var(--glass);
}
.modal-content.glass-container,
.profile-menu,
.notif-panel,
.dp-pop,
.tp-pop,
.sel-pop {
    background: rgba(255, 255, 255, 0.82);
    -webkit-backdrop-filter: var(--glass);
    backdrop-filter: var(--glass);
}
.modal-overlay {
    background: rgba(15, 23, 42, 0.50);
    -webkit-backdrop-filter: blur(8px);
    backdrop-filter: blur(8px);
}

/* --- Richer hover / press micro-interactions --- */
.card { transition: transform 0.3s var(--ease-out-soft), box-shadow 0.3s var(--ease-out-soft), border-color var(--transition-fast); }
.card:hover { transform: translateY(-4px); box-shadow: var(--shadow-lg); }
.metric-card:hover { transform: translateY(-4px); box-shadow: var(--shadow-lg); }
.btn { transition: transform 0.18s var(--ease-out-soft), box-shadow 0.18s var(--ease-out-soft), filter 0.18s ease, background 0.18s ease; }
.btn-secondary:hover { transform: translateY(-1px); box-shadow: var(--shadow-md); }
.sidebar-menu li a { transition: background var(--transition-fast), color var(--transition-fast), transform var(--transition-fast); }
.sidebar-menu li a:hover { transform: translateX(3px); }
.topbar-icon-btn { transition: transform var(--transition-fast), background var(--transition-fast), color var(--transition-fast); }
.topbar-icon-btn:hover { transform: translateY(-2px); }
.data-table tbody tr { transition: background var(--transition-fast); }
.data-table tbody tr:hover { background: var(--bg-subtle); }

/* --- Motion keyframes (killed under prefers-reduced-motion above) --- */
@keyframes uiFadeUp { from { opacity: 0; transform: translateY(16px); } to { opacity: 1; transform: none; } }
@keyframes uiPop { from { opacity: 0; transform: scale(0.94) translateY(10px); } to { opacity: 1; transform: none; } }
@keyframes uiDrift { 0%, 100% { transform: translate3d(-1%, -1%, 0) scale(1); } 50% { transform: translate3d(2%, 2%, 0) scale(1.08); } }

/* Staggered entrance of each top-level block when a tab becomes active */
.tab-content.active > * { animation: uiFadeUp 0.5s var(--ease-out-soft) both; }
.tab-content.active > *:nth-child(1) { animation-delay: 0.03s; }
.tab-content.active > *:nth-child(2) { animation-delay: 0.08s; }
.tab-content.active > *:nth-child(3) { animation-delay: 0.13s; }
.tab-content.active > *:nth-child(4) { animation-delay: 0.18s; }
.tab-content.active > *:nth-child(5) { animation-delay: 0.23s; }
.tab-content.active > *:nth-child(6) { animation-delay: 0.28s; }
.tab-content.active > *:nth-child(n+7) { animation-delay: 0.32s; }

/* Modal: spring scale-in */
.modal-overlay.active .modal-content { animation: uiPop 0.36s var(--ease-spring) both; }

/* Login card entrance */
.login-card { animation: uiPop 0.5s var(--ease-spring) both; }

/* Ambient drifting brand glow — GPU-composited transform (cheap on mobile) */
body::before {
    content: '';
    position: fixed;
    inset: -25%;
    z-index: 0;
    pointer-events: none;
    background:
        radial-gradient(closest-side, rgba(37, 99, 235, 0.10), transparent 72%) 18% 22% / 60% 60% no-repeat,
        radial-gradient(closest-side, rgba(14, 165, 233, 0.09), transparent 72%) 82% 78% / 60% 60% no-repeat;
    animation: uiDrift 26s ease-in-out infinite;
    will-change: transform;
}
.admin-layout, .login-wrapper { position: relative; z-index: 1; }

/* --- "Undo" action inside a toast --- */
.toast-undo {
    margin-left: auto;
    flex-shrink: 0;
    border: 1px solid var(--border-color);
    background: var(--bg-surface);
    color: var(--accent);
    font-weight: 700;
    font-size: 0.78rem;
    padding: 5px 12px;
    border-radius: 8px;
    cursor: pointer;
    transition: background var(--transition-fast), transform var(--transition-fast);
}
.toast-undo:hover { background: var(--bg-subtle); transform: translateY(-1px); }
.toast-undo:active { transform: translateY(0); }

/* --- Sticky table headers (stay visible while scrolling long tables) --- */
.data-table thead th {
    position: sticky;
    top: 0;
    z-index: 2;
    background: var(--bg-surface);
}

/* --- Sortable table headers (Employees registry) --- */
.data-table th.sortable { cursor: pointer; user-select: none; white-space: nowrap; }
.data-table th.sortable:hover { color: var(--text-bright); }
.data-table th.sortable::after { content: "↕"; opacity: 0.35; margin-left: 5px; font-size: 0.8em; }
.data-table th.sortable[aria-sort="ascending"]::after { content: "▲"; opacity: 1; }
.data-table th.sortable[aria-sort="descending"]::after { content: "▼"; opacity: 1; }
.data-table th.sortable:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; border-radius: 4px; }

/* --- Phone card layout for employee data tables (no sideways scroll) --- */
@media (max-width: 640px) {
    .employee-page .data-table thead { display: none; }
    .employee-page .data-table,
    .employee-page .data-table tbody,
    .employee-page .data-table tr,
    .employee-page .data-table td { display: block; width: 100%; }
    .employee-page .data-table tr {
        margin-bottom: 12px;
        border: 1px solid var(--border-color);
        border-radius: 12px;
        padding: 4px 12px;
        background: var(--bg-surface);
        box-shadow: var(--shadow-sm);
    }
    .employee-page .data-table td {
        display: flex; align-items: center; justify-content: space-between; gap: 12px;
        padding: 9px 0; text-align: right; border: none;
        border-bottom: 1px solid var(--border-color);
    }
    .employee-page .data-table tr td:last-child { border-bottom: none; }
    .employee-page .data-table td[data-label]::before {
        content: attr(data-label);
        font-weight: 600; color: var(--text-muted);
        font-size: 0.74rem; text-transform: uppercase; letter-spacing: 0.03em;
        text-align: left; flex-shrink: 0;
    }
    /* empty/loading (colspan) rows: keep as a simple centered message */
    .employee-page .data-table td:not([data-label]) { justify-content: center; text-align: center; }
}
