/* =========================================================
   EMS Premium Light SaaS Design System (2026)
   Inspired by Arc / Linear / Stripe / Notion / Vercel
   ========================================================= */

:root {
    /* Surfaces */
    --ems-bg: #F7F8FC;
    --ems-bg-secondary: #FBFCFF;
    --ems-bg-section: #F3F6FD;
    --ems-card: #FFFFFF;
    --ems-surface: #FFFFFF;
    --ems-surface-elevated: #FFFFFF;
    --ems-topbar-bg: rgba(255, 255, 255, .92);
    --ems-tabs-bg: rgba(255, 255, 255, .92);
    --ems-header-bg: linear-gradient(135deg, rgba(243, 238, 255, .85), rgba(237, 245, 255, .9) 55%, rgba(236, 255, 245, .75));
    --ems-header-border: rgba(108, 99, 255, .08);
    --ems-card-header-bg: linear-gradient(180deg, var(--ems-bg-secondary), #fff);
    --ems-sidebar-hover: #F4F6FF;
    --ems-sidebar-active: #ECE8FF;
    --ems-table-head: #F8FAFF;
    --ems-table-stripe: #FCFCFF;
    --ems-table-hover: #F4F6FF;
    --ems-input-bg: #FFFFFF;
    --ems-muted: #98A2B3;
    --ems-soft-violet: #F3EEFF;
    --ems-soft-blue: #EDF5FF;
    --ems-soft-cyan: #ECFCFB;
    --ems-soft-mint: #ECFFF5;
    --ems-soft-orange: #FFF5E8;
    --ems-soft-pink: #FFF1F8;
    --ems-soft-yellow: #FFFCEB;

    /* Brand */
    --ems-primary: #6C63FF;
    --ems-primary-dark: #574FE6;
    --ems-primary-soft: rgba(108, 99, 255, .12);
    --ems-primary-shadow: rgba(108, 99, 255, .22);
    --ems-secondary: #4FC3F7;
    --ems-accent: #00C896;
    --ems-orange: #FFB547;
    --ems-pink: #F35BA6;
    --ems-sky: #3BA4FF;
    --ems-purple: #8E6BFF;

    /* Text */
    --ems-text-heading: #1D2333;
    --ems-text: #2E3445;
    --ems-text-secondary: #667085;
    --ems-text-muted: var(--ems-muted);
    --ems-text-light: #B4BAC6;

    /* Status */
    --ems-success: #22C55E;
    --ems-success-soft: rgba(34, 197, 94, .14);
    --ems-warning: #F59E0B;
    --ems-warning-soft: rgba(245, 158, 11, .14);
    --ems-danger: #EF4444;
    --ems-danger-soft: rgba(239, 68, 68, .12);
    --ems-info: #3B82F6;
    --ems-info-soft: rgba(59, 130, 246, .12);
    --ems-pending: #8B5CF6;
    --ems-pending-soft: rgba(139, 92, 246, .12);

    /* Structure */
    --ems-border: #E8ECF4;
    --ems-border-soft: #F0F3FA;
    --ems-sidebar-width: 268px;
    --ems-sidebar-collapsed: 84px;
    --ems-topbar-height: 56px;
    --ems-radius: 14px;
    --ems-radius-md: 14px;
    --ems-radius-sm: 12px;
    --ems-radius-xs: 10px;
    --ems-radius-pill: 999px;
    --ems-shadow-xs: 0 1px 2px rgba(29, 35, 51, .04);
    --ems-shadow-sm: 0 4px 16px rgba(29, 35, 51, .05);
    --ems-shadow-md: 0 10px 30px rgba(29, 35, 51, .07);
    --ems-shadow-lg: 0 18px 48px rgba(29, 35, 51, .09);
    --ems-ease: cubic-bezier(.22, 1, .36, 1);
    --ems-duration: .24s;
    --ems-space: 8px;

    /* Charts */
    --chart-present: #22C55E;
    --chart-absent: #EF4444;
    --chart-late: #F59E0B;
    --chart-leave: #FFB547;
    --chart-half: #3BA4FF;
    --chart-payroll: #6C63FF;
    --chart-loan: #3BA4FF;
    --chart-document: #00C896;
    --chart-chat: #F35BA6;
    --chart-neutral: #98A2B3;

    /* Bootstrap bridges */
    --bs-primary: var(--ems-primary);
    --bs-body-color: var(--ems-text);
    --bs-body-bg: var(--ems-bg);
    --bs-border-color: var(--ems-border);
    --bs-link-color: var(--ems-primary);
    --bs-link-hover-color: var(--ems-primary-dark);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }

body, .app-body {
    margin: 0;
    font-family: "Plus Jakarta Sans", Inter, system-ui, -apple-system, Segoe UI, sans-serif;
    font-size: .9rem;
    font-weight: 500;
    color: var(--ems-text);
    background:
        radial-gradient(circle at 12% -10%, rgba(108, 99, 255, .08), transparent 34%),
        radial-gradient(circle at 88% 0%, rgba(79, 195, 247, .08), transparent 28%),
        radial-gradient(circle at 70% 100%, rgba(0, 200, 150, .05), transparent 30%),
        var(--ems-bg);
    -webkit-font-smoothing: antialiased;
    letter-spacing: -.01em;
}

a { color: var(--ems-primary); text-decoration: none; transition: color .15s ease; }
a:hover { color: var(--ems-primary-dark); }

h1, h2, h3, h4, h5, .page-header h1, .topbar-title {
    color: var(--ems-text-heading);
    font-weight: 700;
    letter-spacing: -.02em;
}

/* Reserve scrollbar space so short/long pages don't shift width between tabs. */
html { scrollbar-gutter: stable; }
/* Icons are swapped for SVGs after load; reserve their box so layout doesn't move. */
i[data-lucide] { display: inline-block; width: 1em; height: 1em; vertical-align: -0.125em; }

/* Sidebar collapsed FOUC guard — paint collapsed width before JS runs (admin + employee). */
html.ems-sidebar-collapsed-pending .app-shell { --ems-sidebar-width: var(--ems-sidebar-collapsed); }
html.ems-sidebar-collapsed-pending .app-shell .sidebar-brand span:not(.sidebar-brand-mark),
html.ems-sidebar-collapsed-pending .app-shell .sidebar-link span:not(.sidebar-icon),
html.ems-sidebar-collapsed-pending .app-shell .nav-section-label,
html.ems-sidebar-collapsed-pending .app-shell .sidebar-footer-meta,
html.ems-sidebar-collapsed-pending .app-shell .sidebar-footer .btn span,
html.ems-sidebar-collapsed-pending .app-shell .sidebar-badge { display: none !important; }
html.ems-sidebar-collapsed-pending .app-shell .sidebar-link { justify-content: center; padding-inline: .7rem; }
html.ems-sidebar-collapsed-pending .app-shell .sidebar-link .sidebar-icon { display: grid !important; }
html.ems-sidebar-collapsed-pending .app-sidebar,
html.ems-sidebar-collapsed-pending .app-main {
    transition: none !important;
}

/* Chrome autofill: keep solid fill so fields don't flash yellow / paint garbled after redirect. */
input.form-control:-webkit-autofill,
input.form-control:-webkit-autofill:hover,
input.form-control:-webkit-autofill:focus,
input.form-control:-webkit-autofill:active {
    -webkit-text-fill-color: var(--ems-text-heading, #20283d) !important;
    caret-color: var(--ems-text-heading, #20283d);
    box-shadow: 0 0 0 1000px #fff inset !important;
    -webkit-box-shadow: 0 0 0 1000px #fff inset !important;
    background-color: #fff !important;
    background-image: none !important;
    transition: background-color 99999s ease-out;
}
html[data-theme="dark"] input.form-control:-webkit-autofill,
html[data-theme="dark"] input.form-control:-webkit-autofill:hover,
html[data-theme="dark"] input.form-control:-webkit-autofill:focus,
html[data-theme="dark"] input.form-control:-webkit-autofill:active {
    -webkit-text-fill-color: #E2E8F0 !important;
    caret-color: #E2E8F0;
    box-shadow: 0 0 0 1000px #121e2b inset !important;
    -webkit-box-shadow: 0 0 0 1000px #121e2b inset !important;
    background-color: #121e2b !important;
}

/* ---------- Motion ---------- */
.motion-fade-in { animation: emsFadeIn var(--ems-duration) var(--ems-ease) both; }
.motion-fade-up { animation: emsFadeUp .32s var(--ems-ease) both; }
/* Main content: opacity-only fade — never use transform here.
   Transform on .app-content creates a containing block that traps
   position:fixed Bootstrap modals under the body-appended backdrop. */
.app-content.motion-fade-up { animation: none; }
.motion-scale-in { animation: emsScaleIn .28s var(--ems-ease) both; }
.stagger-item { opacity: 0; animation: emsFadeUp .34s var(--ems-ease) both; }
.stagger-item:nth-child(1) { animation-delay: .02s; }
.stagger-item:nth-child(2) { animation-delay: .06s; }
.stagger-item:nth-child(3) { animation-delay: .1s; }
.stagger-item:nth-child(4) { animation-delay: .14s; }
.stagger-item:nth-child(5) { animation-delay: .18s; }
.stagger-item:nth-child(6) { animation-delay: .22s; }
.stagger-item:nth-child(7) { animation-delay: .26s; }
.stagger-item:nth-child(8) { animation-delay: .3s; }

@keyframes emsFadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes emsFadeUp { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }
@keyframes emsScaleIn { from { opacity: 0; transform: scale(.96); } to { opacity: 1; transform: none; } }
@keyframes shimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation: none !important;
        transition: none !important;
        scroll-behavior: auto !important;
    }
    .stagger-item { opacity: 1; }
}

/* ---------- Auth ---------- */
.auth-page {
    min-height: 100vh;
    background:
        radial-gradient(circle at 15% 20%, rgba(108, 99, 255, .16), transparent 36%),
        radial-gradient(circle at 85% 10%, rgba(79, 195, 247, .14), transparent 32%),
        radial-gradient(circle at 70% 90%, rgba(0, 200, 150, .1), transparent 34%),
        var(--ems-bg);
}
.auth-wrapper {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
}
.auth-card {
    width: 100%;
    max-width: 440px;
    background: var(--ems-card);
    border: 1px solid var(--ems-border);
    border-radius: 20px;
    padding: 2rem;
    box-shadow: var(--ems-shadow-md);
}
.auth-logo {
    width: 56px;
    height: 56px;
    margin: 0 auto .85rem;
    border-radius: 16px;
    background: linear-gradient(135deg, var(--ems-soft-violet), var(--ems-soft-blue));
    color: var(--ems-primary);
    display: grid;
    place-items: center;
    font-size: 1.4rem;
    box-shadow: var(--ems-shadow-sm);
}

/* ---------- App shell ---------- */
.app-shell {
    display: flex;
    min-height: 100vh;
    padding: 12px;
    gap: 12px;
}
.app-sidebar {
    width: var(--ems-sidebar-width);
    background: var(--ems-card);
    border: 1px solid var(--ems-border);
    border-radius: 24px;
    position: fixed;
    top: 12px;
    left: 12px;
    bottom: 12px;
    z-index: 1040;
    display: flex;
    flex-direction: column;
    box-shadow: var(--ems-shadow-sm);
    /* Width change on collapse must not animate on page load — that reads as a nav jerk. */
    transition: transform var(--ems-duration) var(--ems-ease);
    overflow: hidden;
}
@media (min-width: 992px) {
    .app-shell.sidebar-collapsed .app-sidebar:hover {
        width: 268px;
        z-index: 1100;
        overflow: visible;
    }
}
.app-shell.sidebar-collapsed { --ems-sidebar-width: var(--ems-sidebar-collapsed); }
.app-shell.sidebar-collapsed .sidebar-brand span:not(.sidebar-brand-mark),
.app-shell.sidebar-collapsed .sidebar-link span:not(.sidebar-icon),
.app-shell.sidebar-collapsed .nav-section-label,
.app-shell.sidebar-collapsed .sidebar-footer-meta,
.app-shell.sidebar-collapsed .sidebar-footer .btn span { display: none; }
.app-shell.sidebar-collapsed .sidebar-link { justify-content: center; padding-inline: .7rem; }
.app-shell.sidebar-collapsed .sidebar-link .sidebar-icon { display: grid; }
.app-shell.sidebar-collapsed .sidebar-brand { justify-content: center; padding-inline: .75rem; }
.app-shell.sidebar-collapsed .sidebar-footer .btn { padding-inline: .55rem; }

.sidebar-brand {
    min-height: 64px;
    display: flex;
    align-items: center;
    gap: .75rem;
    padding: 1rem 1.1rem .85rem;
    font-weight: 700;
    font-size: .95rem;
    color: var(--ems-text-heading);
    flex-shrink: 0;
}
.sidebar-brand-mark {
    width: 36px;
    height: 36px;
    border-radius: 12px;
    background: linear-gradient(135deg, #6C63FF, #8E6BFF);
    color: #fff;
    display: grid;
    place-items: center;
    flex-shrink: 0;
    box-shadow: 0 8px 18px rgba(108, 99, 255, .28);
}
.sidebar-nav {
    padding: .35rem .75rem 1rem;
    overflow-y: auto;
    flex: 1;
}
.nav-section { margin-bottom: 1.1rem; }
.nav-section-label {
    font-size: .68rem;
    font-weight: 700;
    letter-spacing: .08em;
    text-transform: uppercase;
    color: var(--ems-text-muted);
    padding: .25rem .85rem .55rem;
}
.sidebar-link {
    display: flex;
    align-items: center;
    gap: .7rem;
    padding: .58rem .75rem;
    border-radius: 14px;
    color: var(--ems-text-secondary);
    margin-bottom: 4px;
    font-size: .84rem;
    font-weight: 550;
    position: relative;
    transition: background .18s ease, color .18s ease, transform .18s ease;
}
.sidebar-link:hover {
    background: var(--ems-sidebar-hover);
    color: var(--ems-text-heading);
    transform: translateX(2px);
}
.sidebar-link.active {
    background: var(--ems-sidebar-active);
    color: var(--ems-primary);
    font-weight: 700;
}
/* .sidebar-link::before (the slim accent indicator bar) — canonical animated
   definition lives in design-system.css (grows on .active via a height
   transition instead of this static top/bottom box). */
.sidebar-icon {
    width: 30px;
    height: 30px;
    border-radius: 10px;
    display: grid;
    place-items: center;
    flex-shrink: 0;
    background: var(--ems-bg-section);
    color: var(--ems-text-secondary);
    transition: inherit;
}
.sidebar-link.active .sidebar-icon {
    background: rgba(108, 99, 255, .16);
    color: var(--ems-primary);
}
.sidebar-icon i, .sidebar-icon svg { width: 16px; height: 16px; }
.sidebar-link[data-tone="mint"] .sidebar-icon { background: var(--ems-soft-mint); color: var(--ems-accent); }
.sidebar-link[data-tone="orange"] .sidebar-icon { background: var(--ems-soft-orange); color: var(--ems-orange); }
.sidebar-link[data-tone="purple"] .sidebar-icon { background: var(--ems-soft-violet); color: var(--ems-primary); }
.sidebar-link[data-tone="blue"] .sidebar-icon { background: var(--ems-soft-blue); color: var(--ems-sky); }
.sidebar-link[data-tone="cyan"] .sidebar-icon { background: var(--ems-soft-cyan); color: #1098AD; }
.sidebar-link[data-tone="pink"] .sidebar-icon { background: var(--ems-soft-pink); color: var(--ems-pink); }
.sidebar-link[data-tone="yellow"] .sidebar-icon { background: var(--ems-soft-yellow); color: #D97706; }

.sidebar-group { margin-bottom: 4px; }
.sidebar-group-toggle {
    width: 100%;
    border: 0;
    background: transparent;
    text-align: left;
    cursor: pointer;
}
.sidebar-group-toggle .sidebar-label { flex: 1; }
.sidebar-caret {
    width: 18px;
    height: 18px;
    display: grid;
    place-items: center;
    color: var(--ems-text-muted);
    transition: transform .2s ease;
}
.sidebar-caret i, .sidebar-caret svg { width: 14px; height: 14px; }
.sidebar-group.is-open > .sidebar-group-toggle .sidebar-caret { transform: rotate(180deg); }
.sidebar-submenu {
    display: none;
    padding: .15rem 0 .35rem .95rem;
    margin-left: .85rem;
    border-left: 2px solid var(--ems-border);
}
.sidebar-group.is-open > .sidebar-submenu { display: block; }
.sidebar-sublink {
    display: block;
    padding: .42rem .7rem;
    border-radius: 10px;
    color: var(--ems-text-secondary);
    font-size: .8rem;
    font-weight: 500;
    margin-bottom: 2px;
}
.sidebar-sublink:hover {
    background: var(--ems-sidebar-hover);
    color: var(--ems-text-heading);
}
.sidebar-sublink.active {
    background: var(--ems-sidebar-active);
    color: var(--ems-primary);
    font-weight: 700;
}
.app-shell.sidebar-collapsed .sidebar-submenu,
.app-shell.sidebar-collapsed .sidebar-caret { display: none !important; }

.sidebar-footer {
    border-top: 1px solid var(--ems-border-soft);
    padding: .85rem .8rem 1rem;
    flex-shrink: 0;
    background: linear-gradient(180deg, transparent, var(--ems-bg-secondary));
}
.sidebar-footer-user {
    display: flex;
    align-items: center;
    gap: .65rem;
    padding: .55rem .65rem;
    border-radius: 14px;
    background: var(--ems-soft-violet);
    margin-bottom: .55rem;
}
.sidebar-footer-meta { min-width: 0; }
.sidebar-footer-meta .name {
    font-weight: 700;
    font-size: .8rem;
    color: var(--ems-text-heading);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.sidebar-footer-meta .role { font-size: .68rem; color: var(--ems-text-muted); }

.app-main {
    flex: 1;
    margin-left: calc(var(--ems-sidebar-width) + 12px);
    min-width: 0;
    /* No margin transition — animating content width on every nav/refresh felt like a jerk. */
    display: flex;
    flex-direction: column;
}
.app-topbar {
    min-height: var(--ems-topbar-height);
    background: var(--ems-topbar-bg);
    backdrop-filter: blur(16px);
    border: 1px solid var(--ems-border);
    border-radius: 20px;
    display: flex;
    align-items: center;
    gap: .75rem;
    padding: .55rem .9rem;
    position: sticky;
    top: 0;
    z-index: 1020;
    box-shadow: var(--ems-shadow-xs);
    margin-bottom: 12px;
    color: var(--ems-text);
}
.topbar-title-wrap { min-width: 0; }
.topbar-title { font-weight: 700; font-size: 1rem; line-height: 1.2; }
.topbar-breadcrumb { font-size: .72rem; color: var(--ems-text-muted); margin-top: 1px; }
.topbar-search { max-width: 300px; flex: 1; }
.topbar-search .form-control {
    background: var(--ems-bg-section);
    border: 1px solid transparent;
    border-radius: var(--ems-radius-pill);
    padding-left: 2.2rem;
    height: 34px;
    font-size: .84rem;
    box-shadow: none;
}
.topbar-search .form-control:focus {
    background: var(--ems-surface);
    border-color: color-mix(in srgb, var(--ems-primary) 28%, transparent);
    box-shadow: 0 0 0 .2rem var(--ems-primary-soft);
}
.topbar-search .bi-search,
.topbar-search .search-icon {
    position: absolute;
    left: .9rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--ems-text-muted);
    width: 16px;
    height: 16px;
}
.app-content {
    padding: .25rem .15rem 1.25rem;
    flex: 1;
}

/* ---------- Cards ---------- */
.card, .card-compact, .ems-card {
    background: var(--ems-card);
    border: 1px solid var(--ems-border);
    border-radius: var(--ems-radius);
    box-shadow: var(--ems-shadow-xs);
    overflow: hidden;
    transition: transform .2s var(--ems-ease), box-shadow .2s var(--ems-ease), border-color .2s ease;
}
.ems-card:hover, .card:hover {
    box-shadow: var(--ems-shadow-sm);
}
.card-header, .ems-card-header {
    background: var(--ems-card-header-bg);
    border-bottom: 1px solid var(--ems-border-soft);
    font-size: .84rem;
    font-weight: 700;
    color: var(--ems-text-heading);
    padding: .9rem 1.05rem;
}
.card-body { padding: 1.05rem; }

/* ---------- KPI / Metric cards ---------- */
.stat-card, .metric-card {
    position: relative;
    background: var(--ems-card);
    border: 1px solid var(--ems-border);
    border-radius: var(--ems-radius);
    padding: 1rem 1rem .95rem;
    height: 100%;
    overflow: hidden;
    box-shadow: var(--ems-shadow-xs);
    transition: transform .2s var(--ems-ease), box-shadow .2s var(--ems-ease), border-color .2s ease;
}
.metric-card::before {
    content: "";
    position: absolute;
    inset: 0 0 auto 0;
    height: 3px;
    background: linear-gradient(90deg, var(--tone, var(--ems-primary)), transparent 85%);
}
.metric-card:hover {
    transform: translateY(-3px);
    box-shadow: var(--ems-shadow-md);
    border-color: rgba(108, 99, 255, .18);
}
.metric-card.clickable { cursor: pointer; color: inherit; }
.metric-card .metric-icon {
    width: 40px;
    height: 40px;
    border-radius: 14px;
    display: grid;
    place-items: center;
    margin-bottom: .7rem;
    background: var(--tone-soft, var(--ems-soft-violet));
    color: var(--tone, var(--ems-primary));
    box-shadow: inset 0 0 0 1px rgba(255,255,255,.55);
}
.metric-card .metric-icon i,
.metric-card .metric-icon svg,
.metric-card .metric-icon [data-lucide] {
    width: 18px;
    height: 18px;
    color: inherit;
    stroke: currentColor;
}
.metric-card.tone-mint { --tone: #00C896; --tone-soft: var(--ems-soft-mint); }
.metric-card.tone-purple { --tone: #6C63FF; --tone-soft: var(--ems-soft-violet); }
.metric-card.tone-orange { --tone: #FFB547; --tone-soft: var(--ems-soft-orange); }
.metric-card.tone-blue { --tone: #3BA4FF; --tone-soft: var(--ems-soft-blue); }
.metric-card.tone-red { --tone: #EF4444; --tone-soft: var(--ems-danger-soft); }
.metric-card.tone-yellow { --tone: #F59E0B; --tone-soft: var(--ems-soft-yellow); }
.metric-card.tone-cyan { --tone: #14B8A6; --tone-soft: var(--ems-soft-cyan); }
.metric-card.tone-pink { --tone: #F35BA6; --tone-soft: var(--ems-soft-pink); }
.metric-card.tone-sky { --tone: #3BA4FF; --tone-soft: var(--ems-soft-blue); }

.stat-label, .metric-label {
    font-size: .72rem;
    text-transform: uppercase;
    letter-spacing: .05em;
    color: var(--ems-text-muted);
    font-weight: 700;
}
.stat-value, .metric-value {
    font-size: 1.55rem;
    font-weight: 700;
    color: var(--ems-text-heading);
    line-height: 1.15;
    margin-top: .28rem;
}
.metric-delta {
    display: inline-flex;
    align-items: center;
    gap: .25rem;
    font-size: .74rem;
    font-weight: 650;
    margin-top: .45rem;
    padding: .2rem .5rem;
    border-radius: 999px;
    background: var(--ems-bg-section);
    color: var(--ems-text-secondary);
}
.metric-delta.up { color: var(--ems-success); background: var(--ems-success-soft); }
.metric-delta.down { color: var(--ems-danger); background: var(--ems-danger-soft); }
.metric-delta.flat { color: var(--ems-text-secondary); }
.metric-spark { height: 30px; margin-top: .45rem; opacity: .9; }
.metric-spark .ds-sparkline { display: block; width: 100%; height: 100%; color: var(--tone, var(--ems-primary)); }
.metric-sub { font-size: .78rem; color: var(--ems-text-secondary); margin-top: .2rem; }

/* ---------- Quick action cards ---------- */
.action-grid { display: grid; gap: .85rem; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); }
.action-center-card { overflow: hidden; }
.action-center-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: .75rem; padding: .9rem; }
.action-center-item { display: flex; align-items: center; gap: .7rem; min-width: 0; padding: .8rem; border: 1px solid var(--ems-border); border-radius: var(--ems-radius-sm); color: var(--ems-text); background: var(--ems-bg-secondary); transition: transform .2s ease, border-color .2s ease, box-shadow .2s ease; }
.action-center-item:hover { color: var(--ems-text-heading); transform: translateY(-2px); border-color: color-mix(in srgb, var(--tone) 35%, var(--ems-border)); box-shadow: var(--ems-shadow-sm); }
.action-center-item .action-icon { flex: 0 0 34px; width: 34px; height: 34px; }
.action-center-item.tone-orange { --tone: #FFB547; }
.action-center-item.tone-red { --tone: #EF4444; }
.action-center-item.tone-yellow { --tone: #F59E0B; }
.action-center-item.tone-blue { --tone: #3BA4FF; }
.action-center-item strong, .action-center-item small { display: block; }
.action-center-item strong { font-size: 1.15rem; color: var(--tone); line-height: 1.1; }
.action-center-item small { color: var(--ems-text-secondary); font-size: .72rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.action-center-arrow { width: 14px; margin-left: auto; color: var(--ems-text-muted); }
.password-toggle { border-left: 0 !important; border-radius: 0 var(--ems-radius) var(--ems-radius) 0 !important; }
.global-search-results { position: absolute; z-index: 1050; top: calc(100% + 6px); left: 0; right: 0; padding: .35rem; border: 1px solid var(--ems-border); border-radius: var(--ems-radius-sm); background: var(--ems-card); box-shadow: var(--ems-shadow-md); }
.global-search-result { display: block; padding: .55rem .65rem; border-radius: 8px; color: var(--ems-text); }
.global-search-result:hover { background: var(--ems-bg-section); color: var(--ems-text-heading); }
.global-search-result strong, .global-search-result small { display: block; }
.global-search-result strong { font-size: .78rem; }
.global-search-result small, .global-search-empty { color: var(--ems-text-secondary); font-size: .7rem; }
.global-search-empty { padding: .7rem; }
.attendance-actions { z-index: 10; }
.onboarding-checklist { display: grid; gap: .45rem; }
.onboarding-check { display: flex; align-items: center; gap: .55rem; padding: .55rem .6rem; border-radius: 9px; color: var(--ems-text); font-size: .78rem; background: var(--ems-bg-section); }
.onboarding-check:hover { color: var(--ems-primary); background: var(--ems-primary-soft); }
.onboarding-check > svg:first-child { width: 16px; height: 16px; color: var(--ems-warning); }
.onboarding-check.is-done > svg:first-child { color: var(--ems-success); }
.onboarding-check.is-done { color: var(--ems-text-secondary); }
.onboarding-arrow { width: 13px; color: var(--ems-text-muted) !important; }
@media (max-width: 767.98px) {
    .attendance-actions { position: sticky; bottom: calc(var(--ws-bottom-nav-h, 64px) + .5rem); padding: .65rem; margin-inline: -.65rem; border: 1px solid var(--ems-border); border-radius: var(--ems-radius-sm); background: color-mix(in srgb, var(--ems-card) 92%, transparent); backdrop-filter: blur(12px); box-shadow: var(--ems-shadow-md); }
    .attendance-actions .btn { min-height: 46px; font-size: .95rem; }
}
@media (max-width: 991.98px) { .action-center-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 575.98px) { .action-center-grid { grid-template-columns: 1fr; } }
.action-card {
    display: flex;
    flex-direction: column;
    gap: .7rem;
    padding: 1rem;
    border-radius: 18px;
    border: 1px solid var(--ems-border);
    background: var(--ems-card);
    color: var(--ems-text-heading);
    text-decoration: none;
    box-shadow: var(--ems-shadow-xs);
    transition: transform .2s var(--ems-ease), box-shadow .2s ease;
}
.action-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--ems-shadow-md);
    color: var(--ems-text-heading);
}
.action-card .action-icon {
    width: 42px;
    height: 42px;
    border-radius: 14px;
    display: grid;
    place-items: center;
    color: #fff;
    background: linear-gradient(135deg, var(--ems-primary), var(--ems-purple));
    box-shadow: 0 10px 20px rgba(108, 99, 255, .22);
}
.action-card .action-icon i,
.action-card .action-icon svg,
.action-card .action-icon [data-lucide] {
    width: 18px;
    height: 18px;
    color: inherit;
    stroke: currentColor;
}
.action-card.tone-mint .action-icon { background: linear-gradient(135deg, #00C896, #3BA4FF); box-shadow: 0 10px 20px rgba(0,200,150,.22); }
.action-card.tone-orange .action-icon { background: linear-gradient(135deg, #FFB547, #F35BA6); box-shadow: 0 10px 20px rgba(255,181,71,.25); }
.action-card.tone-blue .action-icon { background: linear-gradient(135deg, #3BA4FF, #6C63FF); }
.action-card.tone-cyan .action-icon { background: linear-gradient(135deg, #14B8A6, #4FC3F7); }
.action-card.tone-pink .action-icon { background: linear-gradient(135deg, #F35BA6, #8E6BFF); }
.action-card .action-title { font-weight: 700; font-size: .88rem; }
.action-card .action-sub { font-size: .74rem; color: var(--ems-text-muted); }

/* ---------- Page header ---------- */
.page-header {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: flex-start;
    gap: .85rem;
    margin-bottom: 1.15rem;
    padding: 1rem 1.15rem;
    border-radius: 20px;
    background: var(--ems-header-bg);
    border: 1px solid var(--ems-header-border);
    color: var(--ems-text);
}
.page-header h1 { font-size: 1.4rem; font-weight: 700; margin: 0; color: var(--ems-text-heading); }
.page-header .subtitle { font-size: .84rem; color: var(--ems-text-secondary); margin: .28rem 0 0; font-weight: 500; }

/* ---------- Filters ---------- */
.filter-bar {
    background: var(--ems-card);
    border: 1px solid var(--ems-border);
    border-radius: 18px;
    padding: 1rem;
    margin-bottom: 1rem;
    position: sticky;
    top: calc(var(--ems-topbar-height) + 18px);
    z-index: 20;
    box-shadow: var(--ems-shadow-sm);
}

/* Compact inline filter bar */
.filter-bar.filter-bar-compact {
    padding: .5rem .75rem;
    overflow: visible;
}
.filter-bar.filter-bar-compact::-webkit-scrollbar { height: 4px; }
.filter-bar.filter-bar-compact::-webkit-scrollbar-thumb { background: var(--ems-border); border-radius: 999px; }
.filter-bar-inner {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: .5rem .6rem;
}
.filter-field {
    display: flex;
    align-items: center;
    gap: .35rem;
}
.filter-field-dates {
    gap: .3rem;
}
.filter-label {
    font-size: .7rem;
    font-weight: 600;
    color: var(--ems-text-secondary);
    white-space: nowrap;
    letter-spacing: .02em;
    text-transform: uppercase;
}
.filter-label-mid {
    font-size: .75rem;
    color: var(--ems-text-secondary);
}
.filter-select {
    min-width: 0;
    width: auto;
    max-width: 140px;
    font-size: .78rem !important;
    padding: .3rem .5rem !important;
    height: 30px !important;
    border-radius: 8px !important;
}
.filter-input-date {
    width: 110px !important;
    font-size: .78rem !important;
    padding: .3rem .4rem !important;
    height: 30px !important;
    border-radius: 8px !important;
    cursor: pointer;
}
.filter-field-employee .filter-select {
    max-width: 160px;
}
.filter-sep {
    width: 1px;
    height: 20px;
    background: var(--ems-border);
    margin: 0 .15rem;
    flex-shrink: 0;
}
.filter-actions {
    display: flex;
    align-items: center;
    gap: .4rem;
    flex-shrink: 0;
    margin-left: auto;
}

.filter-apply-btn,
.filter-reset-btn {
    font-size: .78rem !important;
    padding: .3rem .7rem !important;
    height: 30px !important;
    white-space: nowrap;
}
.filter-chips-row {
    display: flex;
    flex-wrap: wrap;
    gap: .35rem;
    margin-top: .4rem;
    padding-top: .4rem;
    border-top: 1px solid var(--ems-border);
}

.filter-chip {
    display: inline-flex;
    align-items: center;
    gap: .35rem;
    padding: .28rem .65rem;
    border-radius: 999px;
    background: var(--ems-soft-violet);
    color: var(--ems-primary);
    font-size: .72rem;
    font-weight: 700;
}

/* ---------- Charts ---------- */
.chart-panel {
    min-height: 280px;
    background: var(--ems-card-header-bg);
    border-radius: 0 0 var(--ems-radius) var(--ems-radius);
}
.chart-panel canvas { max-height: 320px; }
.heatmap-wrap { overflow-x: auto; padding-bottom: .25rem; }
.heatmap-table { border-collapse: separate; border-spacing: 3px; min-width: 720px; }
.heatmap-table th, .heatmap-table td { font-size: .65rem; text-align: center; color: var(--ems-text-muted); }
.heatmap-cell {
    width: 18px;
    height: 18px;
    border-radius: 6px;
    display: inline-block;
}
.hm-present { background: var(--chart-present); }
.hm-absent { background: var(--chart-absent); }
.hm-late { background: var(--chart-late); }
.hm-leave { background: var(--chart-leave); }
.hm-half { background: var(--chart-half); }
.hm-empty { background: #EEF2F8; }

/* ---------- Empty / loading ---------- */
.empty-state, .error-state {
    text-align: center;
    padding: 2.4rem 1.2rem;
    color: var(--ems-text-secondary);
    background: radial-gradient(circle at top, var(--ems-soft-violet), transparent 55%);
    border-radius: 16px;
}
.empty-state i, .error-state i,
.empty-state svg, .error-state svg {
    width: 42px;
    height: 42px;
    display: block;
    margin: 0 auto .7rem;
    color: var(--ems-primary);
    opacity: .85;
}
.skeleton {
    background: linear-gradient(90deg, #EEF1F8 25%, #F8FAFF 50%, #EEF1F8 75%);
    background-size: 200% 100%;
    animation: shimmer 1.2s infinite;
    border-radius: 12px;
}

/* ---------- Buttons ---------- */
.btn {
    border-radius: var(--ems-radius-sm) !important;
    font-weight: 650;
    letter-spacing: -.01em;
    transition: transform .15s ease, box-shadow .15s ease, background .15s ease !important;
}
.btn:hover { transform: translateY(-1px); }
.btn-primary {
    --bs-btn-bg: var(--ems-primary);
    --bs-btn-border-color: var(--ems-primary);
    --bs-btn-hover-bg: var(--ems-primary-dark);
    --bs-btn-hover-border-color: var(--ems-primary-dark);
    --bs-btn-active-bg: var(--ems-primary-dark);
    box-shadow: 0 8px 18px var(--ems-primary-shadow);
}
.btn-success {
    --bs-btn-bg: var(--ems-success);
    --bs-btn-border-color: var(--ems-success);
}
.btn-danger {
    --bs-btn-bg: var(--ems-danger);
    --bs-btn-border-color: var(--ems-danger);
}
.btn-soft {
    background: var(--ems-surface);
    border: 1px solid var(--ems-border) !important;
    color: var(--ems-text);
    box-shadow: var(--ems-shadow-xs);
}
.btn-soft:hover {
    background: var(--ems-soft-violet);
    color: var(--ems-primary);
    border-color: color-mix(in srgb, var(--ems-primary) 22%, transparent) !important;
}

/* Compact icon actions used in tables */
.table-actions {
    display: inline-flex;
    align-items: center;
    justify-content: flex-end;
    gap: .28rem;
    flex-wrap: nowrap;
}
.table-action-form {
    display: inline;
    margin: 0;
}
.action-btn {
    width: 30px;
    height: 30px;
    padding: 0;
    display: inline-grid;
    place-items: center;
    border-radius: 10px;
    border: 1px solid var(--ems-border);
    background: var(--ems-surface);
    color: var(--ems-text-secondary);
    box-shadow: var(--ems-shadow-xs);
    text-decoration: none;
    transition: background .15s ease, color .15s ease, border-color .15s ease, transform .15s ease;
}
.action-btn:hover,
.action-btn:focus-visible {
    background: var(--ems-soft-violet);
    color: var(--ems-primary);
    border-color: color-mix(in srgb, var(--ems-primary) 22%, transparent);
    transform: translateY(-1px);
}
.action-btn-success {
    color: var(--ems-accent);
    border-color: rgba(18, 184, 134, .2);
    background: var(--ems-soft-mint);
}
.action-btn-success:hover,
.action-btn-success:focus-visible {
    background: var(--ems-soft-mint);
    color: var(--ems-accent);
    border-color: rgba(18, 184, 134, .35);
}
.action-btn-warning {
    color: var(--ems-orange);
    border-color: rgba(253, 126, 20, .2);
    background: var(--ems-soft-orange);
}
.action-btn-warning:hover,
.action-btn-warning:focus-visible {
    background: var(--ems-soft-orange);
    color: var(--ems-orange);
    border-color: rgba(253, 126, 20, .35);
}
.action-btn-danger {
    color: var(--ems-danger);
    border-color: rgba(220, 53, 69, .18);
    background: #FEF2F2;
}
.action-btn-danger:hover,
.action-btn-danger:focus-visible {
    background: #FEE2E2;
    color: var(--ems-danger);
    border-color: rgba(220, 53, 69, .28);
}
.action-btn i,
.action-btn svg {
    width: 14px;
    height: 14px;
    stroke-width: 2;
}

/* .segmented-control (Graphical/Table/Combined) — canonical definition lives
   in design-system.css. */

/* ---------- Tables ---------- */
.table-shell, .ems-card .table-responsive {
    border-radius: 0 0 var(--ems-radius) var(--ems-radius);
}
.table {
    --bs-table-bg: transparent;
    --bs-table-striped-bg: var(--ems-table-stripe);
    --bs-table-hover-bg: var(--ems-table-hover);
    --bs-table-color: var(--ems-text);
    margin-bottom: 0;
    color: var(--ems-text);
}
.table > :not(caption) > * > * {
    padding: .7rem .85rem;
    border-bottom-color: var(--ems-border-soft);
    vertical-align: middle;
    color: inherit;
}
.table thead th {
    position: sticky;
    top: 0;
    z-index: 1;
    font-size: .7rem;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: var(--ems-text-muted);
    background: var(--ems-table-head);
    font-weight: 700;
    border-bottom: 1px solid var(--ems-border);
}
.table-striped > tbody > tr:nth-of-type(odd) > * { --bs-table-bg-type: var(--ems-table-stripe); }
.table-hover > tbody > tr:hover > * { --bs-table-bg-state: var(--ems-table-hover); }

/* ---------- Badges / status ---------- */
.badge, .status-badge {
    border-radius: 999px !important;
    font-weight: 700 !important;
    letter-spacing: .01em;
    padding: .35em .7em !important;
    border: 0;
}
.bg-success, .badge.bg-success, .text-bg-success { background: var(--ems-success-soft) !important; color: #15803D !important; }
.bg-warning, .badge.bg-warning, .text-bg-warning { background: var(--ems-warning-soft) !important; color: #B45309 !important; }
.bg-danger, .badge.bg-danger, .text-bg-danger { background: var(--ems-danger-soft) !important; color: #B91C1C !important; }
.bg-info, .badge.bg-info, .text-bg-info { background: var(--ems-info-soft) !important; color: #1D4ED8 !important; }
.bg-primary, .badge.bg-primary, .text-bg-primary { background: var(--ems-primary-soft) !important; color: var(--ems-primary) !important; }
.bg-secondary, .badge.bg-secondary, .text-bg-secondary { background: var(--ems-bg-section) !important; color: var(--ems-text-secondary) !important; }
.bg-dark, .badge.bg-dark, .text-bg-dark { background: var(--ems-bg-section) !important; color: var(--ems-text) !important; }

.alert {
    border-radius: 14px;
    border: 1px solid transparent;
    font-weight: 550;
}
.alert-success { background: var(--ems-success-soft); color: #15803D; }
.alert-warning { background: var(--ems-warning-soft); color: #B45309; }
.alert-danger { background: var(--ems-danger-soft); color: #B91C1C; }
.alert-info { background: var(--ems-info-soft); color: #1D4ED8; }

.btn svg, .btn [data-lucide] { vertical-align: -2px; }
.sidebar-icon svg { stroke-width: 2; }

.avatar-sm {
    width: 34px;
    height: 34px;
    border-radius: 12px;
    background: linear-gradient(135deg, var(--ems-soft-violet), var(--ems-soft-blue));
    color: var(--ems-primary);
    display: inline-grid;
    place-items: center;
    font-size: .78rem;
    font-weight: 700;
    line-height: 1;
    flex-shrink: 0;
}

/* ---------- Report tabs ---------- */
.report-tabs {
    display: flex;
    flex-wrap: nowrap;
    gap: .2rem;
    background: var(--ems-card);
    border: 1px solid var(--ems-border);
    border-radius: var(--ems-radius-md);
    padding: .3rem;
    box-shadow: var(--ems-shadow-xs);
    overflow-x: auto;
    overflow-y: hidden;
    scrollbar-width: thin;
    white-space: nowrap;
}
.report-tabs::-webkit-scrollbar { height: 3px; }
.report-tabs::-webkit-scrollbar-thumb { background: var(--ems-border); border-radius: 999px; }
.report-tabs .nav-item { flex: 0 0 auto; }
.report-tabs .nav-link {
    color: var(--ems-text-muted);
    font-weight: 650;
    font-size: .78rem;
    border: 0;
    border-radius: 10px !important;
    padding: .38rem .75rem;
    white-space: nowrap;
}
.report-tabs .nav-link:hover { color: var(--ems-primary); background: var(--ems-soft-violet); }
/* .report-tabs .nav-link.active — canonical definition lives in design-system.css
   (accent text + sliding underline, no background pill; loads after this file). */

/* ---------- Widgets ---------- */
.widget-ring {
    width: 120px;
    height: 120px;
    border-radius: 50%;
    display: grid;
    place-items: center;
    background:
        radial-gradient(circle at center, var(--ems-surface) 58%, transparent 59%),
        conic-gradient(var(--tone, var(--ems-accent)) calc(var(--pct, 0) * 1%), var(--ems-border) 0);
    margin: 0 auto .5rem;
    box-shadow: var(--ems-shadow-sm);
}
.widget-ring strong { font-size: 1.25rem; color: var(--ems-text-heading); }
.progress-soft {
    height: 10px;
    border-radius: 999px;
    background: var(--ems-bg-section);
    overflow: hidden;
}
.progress-soft > span {
    display: block;
    height: 100%;
    border-radius: inherit;
    background: linear-gradient(90deg, var(--ems-primary), var(--ems-sky));
}

/* ---------- Drawer / modal ---------- */
.drawer-backdrop {
    position: fixed; inset: 0; background: rgba(29, 35, 51, .28); z-index: 1050;
    opacity: 0; pointer-events: none; transition: opacity .2s ease;
}
.drawer-backdrop.show { opacity: 1; pointer-events: auto; }
.detail-drawer {
    position: fixed; top: 12px; right: 12px; bottom: 12px; width: min(420px, calc(100% - 24px));
    background: var(--ems-surface-elevated); border: 1px solid var(--ems-border); border-radius: 20px;
    z-index: 1055; transform: translateX(110%);
    transition: transform .28s var(--ems-ease);
    display: flex; flex-direction: column;
    box-shadow: var(--ems-shadow-lg);
    color: var(--ems-text);
}
.detail-drawer.show { transform: none; }
.detail-drawer-header {
    padding: 1rem 1.1rem;
    border-bottom: 1px solid var(--ems-border-soft);
    display: flex; justify-content: space-between; align-items: center;
}
.detail-drawer-body { padding: 1.1rem; overflow: auto; flex: 1; }
.modal-content { border-radius: 20px; border: 1px solid var(--ems-border); box-shadow: var(--ems-shadow-lg); }

/* Keep Bootstrap modals above app chrome / drawer stacking contexts */
body > .modal { z-index: 1080; }
body > .modal-backdrop { z-index: 1070; }

/* ---------- Forms ---------- */
.form-control, .form-select {
    font-size: .875rem;
    border-color: var(--ems-border);
    border-radius: var(--ems-radius-sm);
    min-height: 40px;
    background: var(--ems-input-bg);
    color: var(--ems-text);
}
.form-control:focus, .form-select:focus {
    border-color: color-mix(in srgb, var(--ems-primary) 45%, transparent);
    box-shadow: 0 0 0 .2rem var(--ems-primary-soft);
    background: var(--ems-input-bg);
    color: var(--ems-text);
}
.form-label { color: var(--ems-text-secondary); font-weight: 650; font-size: .78rem; }

:focus-visible {
    outline: 2px solid rgba(108, 99, 255, .55);
    outline-offset: 2px;
}

body.drawer-open { overflow: hidden; }

.section-pastel {
    background: var(--ems-bg-section);
    border-radius: 18px;
    padding: 1rem;
    border: 1px solid var(--ems-border-soft);
}
.section-pastel.mint { background: var(--ems-soft-mint); }
.section-pastel.violet { background: var(--ems-soft-violet); }
.section-pastel.orange { background: var(--ems-soft-orange); }
.section-pastel.blue { background: var(--ems-soft-blue); }

.dropdown-menu {
    border-radius: 14px;
    border: 1px solid var(--ems-border);
    box-shadow: var(--ems-shadow-md);
    padding: .4rem;
    background: var(--ems-surface-elevated);
    color: var(--ems-text);
}
.dropdown-item { border-radius: 10px; font-weight: 550; color: var(--ems-text); }
.dropdown-item:hover { background: var(--ems-soft-violet); color: var(--ems-primary); }

/* Keep table action buttons/menus usable inside scroll wrappers */
.table-actions-visible {
    overflow-x: auto;
    overflow-y: visible;
}

.pagination { gap: 3px; }
.pagination .page-link {
    border-radius: 8px !important;
    margin: 0;
    border: 1px solid var(--ems-border);
    color: var(--ems-text-secondary);
    min-width: 32px;
    text-align: center;
    padding: 4px 8px;
    font-size: 13px;
    line-height: 1.5;
    transition: background .12s, border-color .12s, color .12s;
}
.pagination .page-link:hover {
    background: var(--ems-bg-section);
    border-color: var(--ems-primary);
    color: var(--ems-primary);
}
.pagination .page-item.active .page-link {
    background: var(--ems-primary);
    border-color: var(--ems-primary);
    color: #fff;
    font-weight: 600;
    pointer-events: none;
}
.pagination .page-item.disabled .page-link {
    opacity: .4;
    pointer-events: none;
    border-color: var(--ems-border);
}

/* ---------- Responsive ---------- */
@media (max-width: 991.98px) {
    .app-shell { padding: 0; gap: 0; }
    .app-sidebar {
        top: 0; left: 0; bottom: 0;
        border-radius: 0 20px 20px 0;
        transform: translateX(-105%);
        width: min(288px, 86vw) !important;
    }
    .app-shell.sidebar-open .app-sidebar { transform: translateX(0); }
    .app-main { margin-left: 0 !important; padding: 10px; }
    .app-topbar { margin-bottom: 10px; }
    .app-shell.sidebar-collapsed .sidebar-brand span:not(.sidebar-brand-mark),
    .app-shell.sidebar-collapsed .sidebar-link span:not(.sidebar-icon),
    .app-shell.sidebar-collapsed .nav-section-label,
    .app-shell.sidebar-collapsed .sidebar-footer-meta { display: inline; }
    .topbar-search { display: none; }
    .filter-bar { position: static; }
    .page-header h1 { font-size: 1.2rem; }
}

/* Print styles are in reports.css — see @media print block there. */

/* ---------- Appearance: accent themes (darker options) ---------- */
/* Deep teal */
html[data-ems-accent="teal"] {
    --ems-primary: #0F766E;
    --ems-primary-dark: #115E59;
    --ems-primary-soft: rgba(15, 118, 110, .16);
    --ems-primary-shadow: rgba(15, 118, 110, .28);
    --ems-accent: #0D9488;
    --ems-soft-violet: #ECFDF5;
    --ems-purple: #14B8A6;
    --ems-header-border: rgba(15, 118, 110, .12);
}
/* Navy */
html[data-ems-accent="navy"],
html[data-ems-accent="cyan"] {
    --ems-primary: #1E3A5F;
    --ems-primary-dark: #152A45;
    --ems-primary-soft: rgba(30, 58, 95, .16);
    --ems-primary-shadow: rgba(30, 58, 95, .3);
    --ems-accent: #2563EB;
    --ems-soft-violet: #EFF6FF;
    --ems-purple: #3B82F6;
    --ems-header-border: rgba(30, 58, 95, .14);
}
/* Forest */
html[data-ems-accent="forest"],
html[data-ems-accent="green"] {
    --ems-primary: #166534;
    --ems-primary-dark: #14532D;
    --ems-primary-soft: rgba(22, 101, 52, .16);
    --ems-primary-shadow: rgba(22, 101, 52, .28);
    --ems-accent: #15803D;
    --ems-soft-violet: #F0FDF4;
    --ems-purple: #22C55E;
    --ems-header-border: rgba(22, 101, 52, .14);
}
/* Charcoal indigo */
html[data-ems-accent="indigo"],
html[data-ems-accent="blue"] {
    --ems-primary: #3730A3;
    --ems-primary-dark: #312E81;
    --ems-primary-soft: rgba(55, 48, 163, .16);
    --ems-primary-shadow: rgba(55, 48, 163, .3);
    --ems-accent: #4F46E5;
    --ems-soft-violet: #EEF2FF;
    --ems-purple: #6366F1;
    --ems-header-border: rgba(55, 48, 163, .14);
}

html[data-ems-accent="teal"] .sidebar-brand-mark,
html[data-ems-accent="navy"] .sidebar-brand-mark,
html[data-ems-accent="forest"] .sidebar-brand-mark,
html[data-ems-accent="indigo"] .sidebar-brand-mark,
html[data-ems-accent="cyan"] .sidebar-brand-mark,
html[data-ems-accent="blue"] .sidebar-brand-mark,
html[data-ems-accent="green"] .sidebar-brand-mark {
    background: linear-gradient(135deg, var(--ems-primary), var(--ems-accent));
    box-shadow: 0 8px 18px var(--ems-primary-shadow);
}

/* ---------- Appearance: dark theme ---------- */
html[data-theme="dark"] {
    color-scheme: dark;
    --ems-bg: #0B1016;
    --ems-bg-secondary: #121820;
    --ems-bg-section: #161D27;
    --ems-card: #1A222D;
    --ems-surface: #1A222D;
    --ems-surface-elevated: #1E2733;
    --ems-topbar-bg: #1A222D;
    --ems-tabs-bg: #1A222D;
    --ems-header-bg: linear-gradient(135deg, rgba(30, 41, 59, .95), rgba(26, 34, 45, .98) 55%, rgba(22, 32, 42, .96));
    --ems-header-border: rgba(148, 163, 184, .12);
    --ems-card-header-bg: linear-gradient(180deg, var(--ems-bg-secondary), var(--ems-card));
    --ems-sidebar-hover: rgba(148, 163, 184, .08);
    --ems-sidebar-active: var(--ems-primary-soft);
    --ems-table-head: #161D27;
    --ems-table-stripe: rgba(148, 163, 184, .04);
    --ems-table-hover: rgba(148, 163, 184, .08);
    --ems-input-bg: #121820;
    --ems-muted: #8B97A8;
    --ems-soft-violet: rgba(148, 163, 184, .1);
    --ems-soft-blue: rgba(59, 164, 255, .12);
    --ems-soft-cyan: rgba(6, 182, 212, .12);
    --ems-soft-mint: rgba(20, 184, 166, .12);
    --ems-soft-orange: rgba(255, 181, 71, .12);
    --ems-soft-pink: rgba(243, 91, 166, .12);
    --ems-soft-yellow: rgba(250, 204, 21, .1);
    --ems-text-heading: #F1F5F9;
    --ems-text: #D0D7E2;
    --ems-text-secondary: #9AA6B8;
    --ems-text-muted: var(--ems-muted);
    --ems-text-light: #64748B;
    --ems-border: #2A3441;
    --ems-border-soft: #232C38;
    --ems-shadow-xs: 0 1px 2px rgba(0, 0, 0, .28);
    --ems-shadow-sm: 0 4px 16px rgba(0, 0, 0, .28);
    --ems-shadow-md: 0 10px 30px rgba(0, 0, 0, .34);
    --ems-shadow-lg: 0 18px 48px rgba(0, 0, 0, .4);
    --bs-body-color: var(--ems-text);
    --bs-body-bg: var(--ems-bg);
    --bs-border-color: var(--ems-border);
    --bs-secondary-bg: var(--ems-card);
    --bs-tertiary-bg: var(--ems-bg-section);
    --bs-heading-color: var(--ems-text-heading);
    --bs-card-bg: var(--ems-card);
    --bs-card-color: var(--ems-text);
    --bs-card-border-color: var(--ems-border);
    --bs-card-cap-bg: var(--ems-bg-secondary);
    --bs-modal-bg: var(--ems-surface-elevated);
    --bs-modal-color: var(--ems-text);
    --bs-modal-border-color: var(--ems-border);
    --bs-dropdown-bg: var(--ems-surface-elevated);
    --bs-dropdown-color: var(--ems-text);
    --bs-dropdown-border-color: var(--ems-border);
    --bs-dropdown-link-color: var(--ems-text);
    --bs-dropdown-link-hover-bg: var(--ems-primary-soft);
    --bs-dropdown-link-hover-color: var(--ems-primary);
}

/* Brighten deep light-mode accents so glyphs/icons stay readable on dark surfaces */
html[data-theme="dark"][data-ems-accent="teal"] {
    --ems-primary: #2DD4BF;
    --ems-primary-dark: #5EEAD4;
    --ems-primary-soft: rgba(45, 212, 191, .18);
    --ems-primary-shadow: rgba(45, 212, 191, .28);
    --ems-accent: #14B8A6;
    --ems-purple: #5EEAD4;
    --ems-soft-violet: rgba(45, 212, 191, .16);
    --ems-header-bg: linear-gradient(135deg, rgba(15, 118, 110, .18), rgba(26, 34, 45, .98) 50%, rgba(15, 23, 32, .96));
    --ems-header-border: rgba(20, 184, 166, .18);
}
html[data-theme="dark"][data-ems-accent="navy"],
html[data-theme="dark"][data-ems-accent="cyan"] {
    --ems-primary: #60A5FA;
    --ems-primary-dark: #93C5FD;
    --ems-primary-soft: rgba(96, 165, 250, .18);
    --ems-primary-shadow: rgba(96, 165, 250, .28);
    --ems-accent: #3B82F6;
    --ems-purple: #93C5FD;
    --ems-soft-violet: rgba(96, 165, 250, .16);
    --ems-header-bg: linear-gradient(135deg, rgba(30, 58, 95, .35), rgba(26, 34, 45, .98) 50%, rgba(15, 23, 32, .96));
    --ems-header-border: rgba(59, 130, 246, .2);
}
html[data-theme="dark"][data-ems-accent="forest"],
html[data-theme="dark"][data-ems-accent="green"] {
    --ems-primary: #4ADE80;
    --ems-primary-dark: #86EFAC;
    --ems-primary-soft: rgba(74, 222, 128, .18);
    --ems-primary-shadow: rgba(74, 222, 128, .28);
    --ems-accent: #22C55E;
    --ems-purple: #86EFAC;
    --ems-soft-violet: rgba(74, 222, 128, .16);
    --ems-header-bg: linear-gradient(135deg, rgba(22, 101, 52, .22), rgba(26, 34, 45, .98) 50%, rgba(15, 23, 32, .96));
    --ems-header-border: rgba(34, 197, 94, .18);
}
html[data-theme="dark"][data-ems-accent="indigo"],
html[data-theme="dark"][data-ems-accent="blue"] {
    --ems-primary: #A5B4FC;
    --ems-primary-dark: #C7D2FE;
    --ems-primary-soft: rgba(165, 180, 252, .2);
    --ems-primary-shadow: rgba(165, 180, 252, .3);
    --ems-accent: #818CF8;
    --ems-purple: #C7D2FE;
    --ems-soft-violet: rgba(165, 180, 252, .18);
    --ems-header-bg: linear-gradient(135deg, rgba(55, 48, 163, .28), rgba(26, 34, 45, .98) 50%, rgba(15, 23, 32, .96));
    --ems-header-border: rgba(99, 102, 241, .2);
}

html[data-theme="dark"] body,
html[data-theme="dark"] .app-body {
    color: var(--ems-text);
    background:
        radial-gradient(circle at 12% -10%, rgba(20, 184, 166, .07), transparent 34%),
        radial-gradient(circle at 88% 0%, rgba(59, 130, 246, .06), transparent 28%),
        radial-gradient(circle at 70% 100%, rgba(34, 197, 94, .04), transparent 30%),
        var(--ems-bg);
}

html[data-theme="dark"] .app-sidebar,
html[data-theme="dark"] .ems-card,
html[data-theme="dark"] .card,
html[data-theme="dark"] .card-compact,
html[data-theme="dark"] .metric-card,
html[data-theme="dark"] .stat-card,
html[data-theme="dark"] .action-card,
html[data-theme="dark"] .filter-bar,
html[data-theme="dark"] .report-tabs,
html[data-theme="dark"] .auth-card {
    background: var(--ems-card);
    color: var(--ems-text);
    border-color: var(--ems-border);
}
html[data-theme="dark"] .app-topbar {
    background: var(--ems-topbar-bg);
    color: var(--ems-text);
    border-color: var(--ems-border);
}
html[data-theme="dark"] .workspace-tabs,
html[data-theme="dark"] .report-tabs {
    background: var(--ems-bg-section) !important;
    background-color: var(--ems-bg-section) !important;
    color: var(--ems-text);
    border-color: var(--ems-border);
}
html[data-theme="dark"] .workspace-tab {
    color: var(--ems-text-secondary);
}
html[data-theme="dark"] .workspace-tab:hover {
    color: var(--ems-text-heading);
    background: var(--ems-bg-section);
}
html[data-theme="dark"] .workspace-tab.is-active {
    color: var(--ems-text-heading);
    background: var(--ems-card);
    box-shadow: 0 1px 4px rgba(0,0,0,.3), 0 0 0 0.5px rgba(255,255,255,.06) !important;
}
html[data-theme="dark"] .workspace-breadcrumb,
html[data-theme="dark"] .workspace-breadcrumb-list,
html[data-theme="dark"] .topbar-breadcrumb {
    color: var(--ems-text-muted);
}
html[data-theme="dark"] .page-header {
    background: var(--ems-header-bg);
    border-color: var(--ems-header-border);
    color: var(--ems-text);
}
html[data-theme="dark"] .app-content {
    color: var(--ems-text);
}
html[data-theme="dark"] .card-header,
html[data-theme="dark"] .ems-card-header,
html[data-theme="dark"] .chart-panel {
    background: var(--ems-card-header-bg);
    color: var(--ems-text-heading);
    border-color: var(--ems-border-soft);
}
html[data-theme="dark"] h1,
html[data-theme="dark"] h2,
html[data-theme="dark"] h3,
html[data-theme="dark"] h4,
html[data-theme="dark"] h5,
html[data-theme="dark"] .page-header h1,
html[data-theme="dark"] .topbar-title,
html[data-theme="dark"] .metric-value,
html[data-theme="dark"] .stat-value,
html[data-theme="dark"] .action-title,
html[data-theme="dark"] .sidebar-brand {
    color: var(--ems-text-heading);
}
html[data-theme="dark"] .topbar-breadcrumb,
html[data-theme="dark"] .page-header .subtitle,
html[data-theme="dark"] .metric-label,
html[data-theme="dark"] .stat-label,
html[data-theme="dark"] .action-sub,
html[data-theme="dark"] .form-label,
html[data-theme="dark"] .text-muted {
    color: var(--ems-text-secondary) !important;
}

html[data-theme="dark"] .sidebar-link:hover,
html[data-theme="dark"] .sidebar-sublink:hover {
    background: var(--ems-sidebar-hover);
    color: var(--ems-text-heading);
}
html[data-theme="dark"] .sidebar-link.active,
html[data-theme="dark"] .sidebar-sublink.active {
    background: var(--ems-sidebar-active);
    color: var(--ems-primary);
}
html[data-theme="dark"] .sidebar-footer {
    background: linear-gradient(180deg, transparent, var(--ems-bg-secondary));
    border-color: var(--ems-border-soft);
}
html[data-theme="dark"] .sidebar-footer-user {
    background: var(--ems-soft-violet);
}
html[data-theme="dark"] .sidebar-icon {
    background: var(--ems-bg-section);
    color: var(--ems-text-secondary);
}
html[data-theme="dark"] .sidebar-link.active .sidebar-icon {
    background: var(--ems-primary-soft);
    color: var(--ems-primary);
}

html[data-theme="dark"] .btn-soft {
    background: var(--ems-surface);
    color: var(--ems-text);
    border-color: var(--ems-border) !important;
}
html[data-theme="dark"] .btn-soft:hover {
    background: var(--ems-primary-soft);
    color: var(--ems-primary);
    border-color: color-mix(in srgb, var(--ems-primary) 28%, transparent) !important;
}
html[data-theme="dark"] .action-btn {
    background: var(--ems-surface);
    color: var(--ems-text-secondary);
    border-color: var(--ems-border);
}
html[data-theme="dark"] .action-btn:hover,
html[data-theme="dark"] .action-btn:focus-visible {
    background: var(--ems-primary-soft);
    color: var(--ems-primary);
}
html[data-theme="dark"] .action-btn-danger {
    background: var(--ems-danger-soft);
    color: #FCA5A5;
    border-color: rgba(239, 68, 68, .28);
}
html[data-theme="dark"] .action-btn-danger:hover,
html[data-theme="dark"] .action-btn-danger:focus-visible {
    background: rgba(239, 68, 68, .22);
    color: #FECACA;
}

html[data-theme="dark"] .dropdown-menu {
    background: #1E2733 !important;
    background-color: #1E2733 !important;
    border-color: #2A3441 !important;
    color: #E2E8F0 !important;
}
html[data-theme="dark"] .dropdown-item { color: #E2E8F0 !important; }
html[data-theme="dark"] .dropdown-item:hover,
html[data-theme="dark"] .dropdown-item:focus {
    background: #161D27 !important;
    color: #F1F5F9 !important;
}
html[data-theme="dark"] .dropdown-divider { border-color: var(--ems-border); }

html[data-theme="dark"] .form-control,
html[data-theme="dark"] .form-select,
html[data-theme="dark"] .topbar-search .form-control {
    background-color: var(--ems-input-bg);
    border-color: var(--ems-border);
    color: var(--ems-text);
}
html[data-theme="dark"] .form-control::placeholder {
    color: var(--ems-text-muted);
}
html[data-theme="dark"] .form-control:focus,
html[data-theme="dark"] .form-select:focus,
html[data-theme="dark"] .topbar-search .form-control:focus {
    background-color: var(--ems-input-bg);
    color: var(--ems-text);
    border-color: color-mix(in srgb, var(--ems-primary) 45%, transparent);
    box-shadow: 0 0 0 .2rem var(--ems-primary-soft);
}

html[data-theme="dark"] .table {
    --bs-table-bg: transparent;
    --bs-table-color: var(--ems-text);
    --bs-table-striped-bg: var(--ems-table-stripe);
    --bs-table-hover-bg: var(--ems-table-hover);
    --bs-table-border-color: var(--ems-border-soft);
    color: var(--ems-text);
}
html[data-theme="dark"] .table thead th {
    background: var(--ems-table-head);
    color: var(--ems-text-muted);
    border-color: var(--ems-border);
}
html[data-theme="dark"] .modal-content,
html[data-theme="dark"] .detail-drawer {
    background: var(--ems-surface-elevated);
    color: var(--ems-text);
    border-color: var(--ems-border);
}
html[data-theme="dark"] .modal-header,
html[data-theme="dark"] .modal-footer,
html[data-theme="dark"] .detail-drawer-header {
    border-color: var(--ems-border-soft);
    color: var(--ems-text-heading);
}
html[data-theme="dark"] .list-group-item {
    background: var(--ems-card);
    color: var(--ems-text);
    border-color: var(--ems-border);
}
html[data-theme="dark"] .pagination .page-link {
    background: var(--ems-card, var(--ems-surface));
    border-color: var(--ems-border);
    color: var(--ems-text-secondary);
}
html[data-theme="dark"] .pagination .page-item.active .page-link {
    background: var(--ems-primary);
    border-color: var(--ems-primary);
    color: #fff;
}
html[data-theme="dark"] .pagination .page-link:hover {
    background: var(--ems-bg-section);
    border-color: rgba(148,196,255,.4);
    color: #93c5fd;
}
html[data-theme="dark"] .pagination .page-item.disabled .page-link {
    background: transparent;
    color: var(--ems-text-muted);
}
html[data-theme="dark"] .alert-success { color: #86EFAC; }
html[data-theme="dark"] .alert-warning { color: #FCD34D; }
html[data-theme="dark"] .alert-danger { color: #FCA5A5; }
html[data-theme="dark"] .alert-info { color: #93C5FD; }
html[data-theme="dark"] .bg-success,
html[data-theme="dark"] .badge.bg-success,
html[data-theme="dark"] .text-bg-success { color: #86EFAC !important; }
html[data-theme="dark"] .bg-warning,
html[data-theme="dark"] .badge.bg-warning,
html[data-theme="dark"] .text-bg-warning { color: #FCD34D !important; }
html[data-theme="dark"] .bg-danger,
html[data-theme="dark"] .badge.bg-danger,
html[data-theme="dark"] .text-bg-danger { color: #FCA5A5 !important; }
html[data-theme="dark"] .bg-info,
html[data-theme="dark"] .badge.bg-info,
html[data-theme="dark"] .text-bg-info { color: #93C5FD !important; }
html[data-theme="dark"] .hm-empty { background: var(--ems-bg-section); }
html[data-theme="dark"] .skeleton {
    background: linear-gradient(90deg, #1A222D 25%, #243041 50%, #1A222D 75%);
    background-size: 200% 100%;
}
html[data-theme="dark"] .metric-card .metric-icon {
    color: var(--tone, var(--ems-primary));
    background: color-mix(in srgb, var(--tone, var(--ems-primary)) 22%, var(--ems-bg-section));
    box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--tone, var(--ems-primary)) 40%, transparent);
}
html[data-theme="dark"] .metric-card .metric-icon i,
html[data-theme="dark"] .metric-card .metric-icon svg,
html[data-theme="dark"] .metric-card .metric-icon [data-lucide] {
    color: inherit;
    stroke: currentColor;
    opacity: 1;
    filter: none;
}
html[data-theme="dark"] .metric-card:hover {
    border-color: color-mix(in srgb, var(--ems-primary) 28%, transparent);
}
html[data-theme="dark"] .action-card .action-icon {
    color: #fff;
}
html[data-theme="dark"] .action-card .action-icon i,
html[data-theme="dark"] .action-card .action-icon svg,
html[data-theme="dark"] .action-card .action-icon [data-lucide] {
    color: #fff;
    stroke: currentColor;
    opacity: 1;
    filter: none;
}
html[data-theme="dark"] .avatar-sm {
    background: linear-gradient(135deg, var(--ems-primary), var(--ems-accent));
    color: #0B1016;
    box-shadow: 0 0 0 1px rgba(255, 255, 255, .12), 0 6px 14px var(--ems-primary-shadow);
}
html[data-theme="dark"] .auth-logo {
    background: linear-gradient(135deg, var(--ems-primary), var(--ems-accent));
    color: #0B1016;
}
html[data-theme="dark"] .empty-state i,
html[data-theme="dark"] .error-state i,
html[data-theme="dark"] .empty-state svg,
html[data-theme="dark"] .error-state svg {
    color: var(--ems-primary);
    opacity: 1;
}
html[data-theme="dark"] .btn svg,
html[data-theme="dark"] .btn [data-lucide],
html[data-theme="dark"] .action-btn svg,
html[data-theme="dark"] .dropdown-item svg,
html[data-theme="dark"] .dropdown-item [data-lucide],
html[data-theme="dark"] .page-header svg,
html[data-theme="dark"] .page-header [data-lucide],
html[data-theme="dark"] .topbar-actions svg,
html[data-theme="dark"] .topbar-actions [data-lucide] {
    color: inherit;
    stroke: currentColor;
    opacity: 1;
    filter: none;
}
html[data-theme="dark"] .sidebar-icon i,
html[data-theme="dark"] .sidebar-icon svg,
html[data-theme="dark"] .sidebar-icon [data-lucide] {
    color: inherit;
    stroke: currentColor;
    opacity: 1;
    filter: none;
}
html[data-theme="dark"] .section-pastel {
    background: var(--ems-bg-section);
    border-color: var(--ems-border-soft);
}
html[data-theme="dark"] .empty-state,
html[data-theme="dark"] .error-state {
    color: var(--ems-text-secondary);
}
html[data-theme="dark"] .ems-mode-btn.is-active,
html[data-theme="dark"] .ems-mode-btn[aria-checked="true"] {
    background: var(--ems-surface-elevated);
    color: var(--ems-text-heading);
}
html[data-theme="dark"] .auth-page {
    background:
        radial-gradient(circle at 15% 20%, rgba(15, 118, 110, .14), transparent 36%),
        radial-gradient(circle at 85% 10%, rgba(55, 48, 163, .12), transparent 32%),
        var(--ems-bg);
}

/* Bootstrap utilities used by monitoring + misc panels */
html[data-theme="dark"] .bg-white {
    background-color: var(--ems-surface) !important;
    color: var(--ems-text);
}
html[data-theme="dark"] .text-dark {
    color: var(--ems-text-heading) !important;
}
html[data-theme="dark"] .bg-light {
    background-color: var(--ems-bg-section) !important;
    color: var(--ems-text);
}
html[data-theme="dark"] .border-light {
    border-color: var(--ems-border) !important;
}

/* Work Monitoring surfaces */
.ems-surface {
    background: var(--ems-surface);
    color: var(--ems-text);
}
.monitoring-shot-thumb {
    aspect-ratio: 4 / 3;
    object-fit: cover;
    background: var(--ems-bg-section);
}
html[data-theme="dark"] .monitoring-card,
html[data-theme="dark"] .monitoring-panel,
html[data-theme="dark"] .ems-surface {
    background: var(--ems-surface);
    color: var(--ems-text);
    border-color: var(--ems-border);
}
html[data-theme="dark"] .monitoring-card .text-muted,
html[data-theme="dark"] .monitoring-panel .text-muted {
    color: var(--ems-text-muted) !important;
}
html[data-theme="dark"] .monitoring-card h1,
html[data-theme="dark"] .monitoring-card h2,
html[data-theme="dark"] .monitoring-panel h1,
html[data-theme="dark"] .monitoring-panel h2,
html[data-theme="dark"] .monitoring-card .fs-3 {
    color: var(--ems-text-heading);
}
html[data-theme="dark"] .monitoring-shot-thumb {
    background: var(--ems-bg-secondary);
}

/* ========================================================
   Monitoring UI v2
   ======================================================== */

/* Live employee cards grid */
.mon-live-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
    gap: 12px;
    margin-top: 4px;
}
.mon-emp-card {
    background: var(--ems-surface);
    border: 1px solid var(--ems-border);
    border-radius: 12px;
    padding: 14px 16px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    transition: border-color .15s;
}
.mon-emp-card:hover { border-color: var(--ems-primary); }
.mon-emp-card-head { display: flex; align-items: center; gap: 10px; }
.mon-emp-avatar {
    width: 38px; height: 38px; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-size: 13px; font-weight: 600;
    flex-shrink: 0;
    position: relative;
}
.mon-emp-avatar-inner {
    width: 38px; height: 38px; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-size: 13px; font-weight: 600;
    background: var(--ems-bg-section); color: var(--ems-text-muted);
}
.mon-status-ring {
    position: absolute; bottom: -2px; right: -2px;
    width: 12px; height: 12px; border-radius: 50%;
    border: 2px solid var(--ems-surface);
}
.mon-status-ring.is-active  { background: #22c55e; }
.mon-status-ring.is-idle    { background: #f59e0b; }
.mon-status-ring.is-offline { background: #94a3b8; }
.mon-emp-name { font-size: 13px; font-weight: 600; color: var(--ems-text-heading); line-height: 1.2; }
.mon-emp-sub  { font-size: 11px; color: var(--ems-text-muted); }
.mon-emp-meta { display: flex; flex-wrap: wrap; gap: 6px; }
.mon-emp-tag {
    font-size: 11px; padding: 2px 8px; border-radius: 20px;
    background: var(--ems-bg-section); color: var(--ems-text-muted);
    border: 1px solid var(--ems-border-soft);
    white-space: nowrap;
}
.mon-emp-tag.is-idle-tag { background: #fff7ed; color: #b45309; border-color: #fed7aa; }
html[data-theme="dark"] .mon-emp-tag.is-idle-tag { background: rgba(245,158,11,.15); color: #fbbf24; border-color: rgba(245,158,11,.3); }
.mon-emp-card-foot { display: flex; align-items: center; justify-content: space-between; padding-top: 4px; border-top: 1px solid var(--ems-border-soft); }
.mon-status-badge {
    font-size: 11px; font-weight: 600; padding: 2px 8px; border-radius: 20px;
    text-transform: capitalize;
}
.mon-status-badge.is-active  { background: #dcfce7; color: #15803d; }
.mon-status-badge.is-idle    { background: #fff7ed; color: #b45309; }
.mon-status-badge.is-paused  { background: #fff7ed; color: #b45309; }
.mon-status-badge.is-offline { background: var(--ems-bg-section); color: var(--ems-text-muted); }
html[data-theme="dark"] .mon-status-badge.is-active  { background: rgba(34,197,94,.15); color: #4ade80; }
html[data-theme="dark"] .mon-status-badge.is-idle    { background: rgba(245,158,11,.15); color: #fbbf24; }
html[data-theme="dark"] .mon-status-badge.is-paused  { background: rgba(245,158,11,.15); color: #fbbf24; }
html[data-theme="dark"] .mon-status-badge.is-offline { background: rgba(148,163,184,.1); color: var(--ems-text-muted); }

/* App usage dual-tone bar */
.mon-usage-bar-wrap { display: flex; align-items: center; gap: 8px; }
.mon-usage-bar {
    flex: 1; height: 6px; border-radius: 3px;
    background: var(--ems-bg-section);
    overflow: hidden; position: relative;
}
.mon-usage-bar-active {
    position: absolute; left: 0; top: 0; height: 100%;
    background: var(--ems-primary, #3b82f6); border-radius: 3px;
}
.mon-usage-bar-idle {
    position: absolute; top: 0; height: 100%;
    background: #94a3b8; border-radius: 3px;
}
.mon-usage-time { font-size: 12px; color: var(--ems-text-muted); white-space: nowrap; min-width: 40px; text-align: right; font-variant-numeric: tabular-nums; }

/* Domain category row highlights */
.mon-domain-row-productive td:first-child { border-left: 3px solid #22c55e; }
.mon-domain-row-neutral    td:first-child { border-left: 3px solid #94a3b8; }
.mon-domain-row-distracting td:first-child { border-left: 3px solid #f59e0b; }
.mon-domain-row-blocked    td:first-child { border-left: 3px solid #ef4444; }
.mon-mini-bar {
    display: inline-block; height: 6px; border-radius: 3px;
    vertical-align: middle; margin-left: 4px;
}

/* Screenshot timeline */
.mon-timeline-section { margin-bottom: 20px; }
.mon-timeline-hour-label {
    font-size: 11px; font-weight: 700; letter-spacing: .05em;
    text-transform: uppercase; color: var(--ems-text-muted);
    margin-bottom: 8px; padding-bottom: 4px;
    border-bottom: 1px solid var(--ems-border-soft);
}
.mon-timeline-strip {
    display: flex; flex-wrap: wrap; gap: 8px;
}
.mon-shot-card {
    background: var(--ems-surface); border: 1px solid var(--ems-border);
    border-radius: 8px; overflow: hidden; width: 160px;
    transition: border-color .15s, transform .1s;
}
.mon-shot-card:hover { border-color: var(--ems-primary); transform: translateY(-1px); }
.mon-shot-thumb-wrap { position: relative; }
.mon-shot-thumb { width: 100%; aspect-ratio: 16/10; object-fit: cover; background: var(--ems-bg-section); display: block; }
.mon-shot-card-body { padding: 6px 8px; }
.mon-shot-name { font-size: 12px; font-weight: 600; color: var(--ems-text-heading); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mon-shot-time { font-size: 11px; color: var(--ems-text-muted); font-variant-numeric: tabular-nums; }
.mon-quick-dates { display: flex; gap: 6px; flex-wrap: wrap; }
.mon-quick-date-btn {
    font-size: 12px; padding: 4px 12px; border-radius: 20px;
    background: var(--ems-bg-section); border: 1px solid var(--ems-border);
    color: var(--ems-text-muted); cursor: pointer; transition: all .15s;
}
.mon-quick-date-btn:hover, .mon-quick-date-btn.is-active {
    background: var(--ems-primary); border-color: var(--ems-primary); color: #fff;
}

/* Alert severity */
.mon-alert-blocked  { background: #fef2f2; color: #991b1b; border-color: #fecaca; }
.mon-alert-warned   { background: #fff7ed; color: #92400e; border-color: #fed7aa; }
.mon-alert-policy   { background: #eff6ff; color: #1e40af; border-color: #bfdbfe; }
.mon-alert-info     { background: var(--ems-bg-section); color: var(--ems-text-muted); border-color: var(--ems-border); }
html[data-theme="dark"] .mon-alert-blocked  { background: rgba(239,68,68,.12); color: #fca5a5; border-color: rgba(239,68,68,.25); }
html[data-theme="dark"] .mon-alert-warned   { background: rgba(245,158,11,.12); color: #fcd34d; border-color: rgba(245,158,11,.25); }
html[data-theme="dark"] .mon-alert-policy   { background: rgba(59,130,246,.12); color: #93c5fd; border-color: rgba(59,130,246,.25); }
.mon-alert-type-badge {
    display: inline-block; font-size: 11px; font-weight: 600; padding: 2px 8px;
    border-radius: 20px; border: 1px solid transparent;
}

/* Donut chart */
.mon-donut-outer {
    display: flex; align-items: center; gap: 20px;
    padding: 12px 16px; background: var(--ems-surface);
    border: 1px solid var(--ems-border); border-radius: 12px;
}
.mon-donut-canvas {
    width: 80px; height: 80px; border-radius: 50%;
    flex-shrink: 0; position: relative; display: flex;
    align-items: center; justify-content: center;
}
.mon-donut-hole {
    position: absolute; width: 50px; height: 50px;
    background: var(--ems-surface); border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-size: 10px; font-weight: 700; color: var(--ems-text-muted); text-align: center;
    line-height: 1.2;
}
.mon-donut-legend { display: flex; flex-direction: column; gap: 5px; }
.mon-donut-legend-item { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--ems-text-muted); }
.mon-donut-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }

/* Auto-refresh indicator */
.mon-refresh-bar {
    display: flex; align-items: center; gap: 10px;
    font-size: 12px; color: var(--ems-text-muted);
}
.mon-refresh-dot { width: 7px; height: 7px; border-radius: 50%; background: #22c55e; animation: monPulse 2s infinite; }
@keyframes monPulse { 0%,100%{opacity:1} 50%{opacity:.3} }

/* ========================================================
   Live screen viewer
   ======================================================== */
.ls-frame-wrap {
    position: relative;
    background: #0f172a;
    border-radius: 10px;
    overflow: hidden;
    min-height: 200px;
    display: flex;
    align-items: center;
    justify-content: center;
}
.ls-frame-img {
    width: 100%;
    height: auto;
    display: block;
    border-radius: 0;
}
.ls-no-frame {
    padding: 48px 24px;
    text-align: center;
    color: #94a3b8;
}
.ls-overlay {
    position: absolute;
    inset: 0;
    background: rgba(15,23,42,.75);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: #94a3b8;
    font-size: 13px;
    gap: 4px;
    border-radius: 10px;
}

/* ========================================================
   Monitoring levels page
   ======================================================== */
.mll-badge {
    display: inline-block;
    font-size: 11px; font-weight: 600; padding: 3px 10px;
    border-radius: 20px; border: 1px solid transparent;
    white-space: nowrap;
}
.mll-level-card {
    background: var(--ems-surface); border-radius: 12px;
    border: 1px solid var(--ems-border); padding: 16px 18px;
    height: 100%;
}
.mll-feature-list {
    list-style: none; padding: 0; margin: 0;
    display: flex; flex-direction: column; gap: 4px;
}
.mll-feature-list li {
    font-size: 12px; padding: 2px 0;
    border-bottom: 1px solid var(--ems-border-soft);
}
.mll-feature-list li:last-child { border-bottom: none; }

/* Category dot (web-activity) */
.mon-cat-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; display: inline-block; }

/* Alert avatar */
.mon-alert-avatar {
    width: 30px; height: 30px; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-size: 11px; font-weight: 700; flex-shrink: 0;
}

/* Policy coverage bar */
.mon-coverage-bar-wrap { width: 80px; }
.mon-coverage-bar-track { height: 5px; background: var(--ems-bg-section); border-radius: 3px; overflow: hidden; }
.mon-coverage-bar-fill  { height: 100%; border-radius: 3px; background: var(--ems-primary); }
.mon-coverage-label { font-size: 11px; color: var(--ems-text-muted); margin-top: 2px; }

/* ---------- Appearance menu (profile dropdown) ---------- */
.ems-appearance {
    list-style: none;
}
.ems-appearance-toggle {
    display: flex !important;
    align-items: center;
    justify-content: space-between;
    gap: .5rem;
    width: 100%;
}
.ems-appearance-caret {
    transition: transform var(--ems-duration) var(--ems-ease);
    opacity: .7;
}
.ems-appearance.is-open .ems-appearance-caret {
    transform: rotate(180deg);
}
.ems-appearance-panel {
    padding: .55rem .65rem .7rem;
    animation: emsFadeIn .18s var(--ems-ease) both;
}
.ems-appearance-label {
    font-size: .65rem;
    font-weight: 700;
    letter-spacing: .08em;
    text-transform: uppercase;
    color: var(--ems-text-muted);
    margin: .35rem 0 .4rem;
}
.ems-mode-seg {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 3px;
    padding: 3px;
    border-radius: 10px;
    background: var(--ems-bg-section);
    border: 1px solid var(--ems-border-soft);
    margin-bottom: .55rem;
}
.ems-mode-btn {
    appearance: none;
    border: 0;
    background: transparent;
    color: var(--ems-text-secondary);
    font: inherit;
    font-size: .72rem;
    font-weight: 650;
    padding: .38rem .2rem;
    border-radius: 8px;
    cursor: pointer;
    transition: background .16s ease, color .16s ease, box-shadow .16s ease;
}
.ems-mode-btn:hover {
    color: var(--ems-text-heading);
}
.ems-mode-btn.is-active,
.ems-mode-btn[aria-checked="true"] {
    background: var(--ems-card);
    color: var(--ems-text-heading);
    box-shadow: var(--ems-shadow-xs);
}
.ems-mode-btn:focus-visible {
    outline: 2px solid var(--ems-primary);
    outline-offset: 1px;
}
.ems-accent-row {
    display: flex;
    align-items: center;
    gap: .55rem;
    padding: .15rem 0 .1rem;
}
.ems-accent-swatch {
    width: 26px;
    height: 26px;
    border-radius: 50%;
    border: 2px solid var(--ems-card);
    padding: 0;
    cursor: pointer;
    background: linear-gradient(135deg, var(--swatch-a) 50%, var(--swatch-b) 50%);
    box-shadow: 0 0 0 1px var(--ems-border);
    transition: transform .16s var(--ems-ease), box-shadow .16s ease;
}
.ems-accent-swatch:hover { transform: scale(1.08); }
.ems-accent-swatch.is-active,
.ems-accent-swatch[aria-checked="true"] {
    box-shadow: 0 0 0 2px var(--ems-card), 0 0 0 4px var(--ems-primary);
}
.ems-accent-swatch:focus-visible {
    outline: 2px solid var(--ems-primary);
    outline-offset: 2px;
}

.dropdown-menu.account-menu {
    min-width: 232px;
}

/* ---------- Notification bell ---------- */
@keyframes bell-ring {
    0%   { transform: rotate(0); }
    10%  { transform: rotate(18deg); }
    20%  { transform: rotate(-16deg); }
    30%  { transform: rotate(14deg); }
    40%  { transform: rotate(-12deg); }
    50%  { transform: rotate(8deg); }
    60%  { transform: rotate(-4deg); }
    70%  { transform: rotate(2deg); }
    80%  { transform: rotate(-1deg); }
    100% { transform: rotate(0); }
}
@keyframes badge-pop {
    0%   { transform: translate(-50%,-50%) scale(0.5); opacity: 0; }
    60%  { transform: translate(-50%,-50%) scale(1.25); }
    100% { transform: translate(-50%,-50%) scale(1); opacity: 1; }
}
@keyframes badge-pulse-ring {
    0%   { transform: translate(-50%,-50%) scale(1); opacity: .6; }
    100% { transform: translate(-50%,-50%) scale(2.2); opacity: 0; }
}

#notifBtn.bell-ringing i[data-lucide="bell"] {
    animation: bell-ring .7s cubic-bezier(.36,.07,.19,.97) both;
    display: inline-block;
    transform-origin: 50% 0%;
}
#notifCount {
    font-size: .6rem !important;
    min-width: 16px;
    height: 16px;
    line-height: 16px;
    padding: 0 4px !important;
    transition: none;
}
#notifCount.badge-new {
    animation: badge-pop .35s cubic-bezier(.175,.885,.32,1.275) both;
}
#notifCount.badge-new::before {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: 999px;
    background: #ef4444;
    animation: badge-pulse-ring .8s ease-out .1s both;
    pointer-events: none;
}

/* Unread notification rows */
#notifList .list-group-item.unread {
    background: var(--ems-primary-soft, #eff6ff);
    border-left: 3px solid var(--ems-primary, #2563eb);
    padding-left: calc(.75rem - 3px);
}
#notifList .list-group-item {
    border-radius: 0;
    border-left: 3px solid transparent;
}
#notifList .notif-time {
    font-size: .7rem;
    color: var(--ems-text-secondary, #6b7280);
    margin-top: 2px;
}

html[data-theme="dark"] #notifList .list-group-item.unread {
    background: rgba(37,99,235,.12);
}
