/* Layout: the dark frame, the sidebar, the rounded canvas, the phone top bar,
   and the page header that opens every screen. */

body.em-app { background-color: var(--em-shell); }

/* Sidebar ---------------------------------------------------------------- */
.em-sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: var(--em-sidebar-w);
    display: none;
    flex-direction: column;
    padding: 20px 14px 14px;
    color: var(--em-nav-text);
    background:
        radial-gradient(420px 300px at 0% 0%, rgba(99, 91, 246, .38), transparent 70%),
        radial-gradient(360px 280px at 100% 100%, rgba(34, 211, 238, .14), transparent 70%),
        var(--em-shell);
    z-index: 200;
}

/* Labelled Light / Dark switch. It sits on the dark sidebar and on the dark sign-in backdrop.
   The active side follows data-theme on <html>, so no script is needed to draw it. */
.em-theme-switch {
    flex: none;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 4px;
    margin-top: 12px;
    padding: 4px;
    border-radius: 13px;
    background: rgba(255, 255, 255, .1);
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .4);
}
.em-theme-switch__opt {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    min-height: 34px;
    padding: 0 10px;
    border: 0;
    border-radius: 10px;
    background: transparent;
    color: var(--em-nav-text);
    font-size: .9rem;
    font-weight: 600;
    transition: background-color var(--em-fast), color var(--em-fast);
}
.em-theme-switch__opt:hover { color: #fff; }
.em-theme-switch__opt:focus-visible { outline-color: #fff; }
:root:not([data-theme="dark"]) .em-theme-switch__opt[data-em-theme-set="light"],
[data-theme="dark"] .em-theme-switch__opt[data-em-theme-set="dark"] {
    background: #fff;
    color: #000;
    box-shadow: 0 1px 3px rgba(0, 0, 0, .35);
}

.em-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 2px 8px 18px;
    color: #fff;
    font-weight: 700;
    font-size: 1.15rem;
    letter-spacing: -.01em;
    text-decoration: none;
}
.em-brand:hover { color: #fff; }
.em-brand__mark {
    width: 34px;
    height: 34px;
    flex: none;
    display: grid;
    place-items: center;
    border-radius: 11px;
    font-size: 1.15rem;
    color: #fff;
    background: linear-gradient(135deg, #5b5bf6, #8b5cf6 60%, #22d3ee);
    box-shadow: 0 8px 20px -6px rgba(124, 92, 246, .8);
}

.em-nav {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    margin-inline: -6px;
    padding-inline: 6px;
    scrollbar-color: rgba(255, 255, 255, .18) transparent;
}
.em-nav__group {
    padding: 12px 12px 4px;
    font-size: .8rem;
    font-weight: 700;
    letter-spacing: .12em;
    text-transform: uppercase;
    color: var(--em-nav-group);
}
.em-nav__group:first-child { padding-top: 4px; }
.em-nav__link {
    display: flex;
    align-items: center;
    gap: 12px;
    min-height: 34px;
    padding: 5px 12px;
    line-height: 1.3;
    border-radius: 11px;
    color: var(--em-nav-text);
    font-weight: 600;
    font-size: .95rem;
    text-decoration: none;
    transition: background-color var(--em-fast), color var(--em-fast);
}
.em-nav__link .bi { font-size: 1.1rem; width: 20px; text-align: center; }
.em-nav__link:hover { color: #fff; background: rgba(255, 255, 255, .14); }
.em-nav__link:focus-visible { outline-color: #fff; }
.em-nav__link.is-active {
    color: #fff;
    font-weight: 700;
    background: linear-gradient(90deg, #4f46e5, #6d28d9);
    box-shadow: 0 8px 22px -10px rgba(99, 91, 246, .9), inset 0 0 0 1px rgba(255, 255, 255, .45);
}

.em-user-menu { flex: none; margin-top: 12px; }
.em-user-menu .dropdown-menu { width: 100%; }
.em-user {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 10px;
    border: 0;
    border-radius: 14px;
    background: rgba(255, 255, 255, .1);
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .4);
    color: #fff;
    text-align: left;
    transition: background-color var(--em-fast);
}
.em-user:hover, .em-user[aria-expanded="true"] { background: rgba(255, 255, 255, .2); }
.em-user:focus-visible { outline-color: #fff; }
.em-user > .bi { color: var(--em-nav-text); font-size: 1rem; }
.em-user__avatar {
    width: 34px;
    height: 34px;
    flex: none;
    display: grid;
    place-items: center;
    border-radius: 50%;
    font-size: .82rem;
    font-weight: 700;
    color: #fff;
    background: linear-gradient(135deg, #0e7490, #4338ca);
}
.em-user__text { min-width: 0; flex: 1; display: flex; flex-direction: column; line-height: 1.25; }
.em-user__name { font-size: .9rem; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.em-user__role { font-size: .82rem; color: var(--em-nav-text); }

/* Phone top bar and slide-out menu --------------------------------------- */
.em-mobilebar {
    position: sticky;
    top: 0;
    z-index: 200;
    display: flex;
    align-items: center;
    gap: 8px;
    height: 56px;
    padding: 0 12px;
    background: var(--em-shell);
    color: #fff;
}
.em-mobilebar .em-brand { padding: 0; flex: 1; font-size: 1.1rem; }
.em-mobilebar .em-brand__mark { width: 30px; height: 30px; border-radius: 9px; font-size: 1.05rem; }
.em-mobilebar__btn {
    width: 44px;
    height: 44px;
    display: grid;
    place-items: center;
    border: 0;
    border-radius: 12px;
    background: transparent;
    color: #fff;
    font-size: 1.4rem;
}
.em-mobilebar__btn:hover { background: rgba(255, 255, 255, .1); }

.em-offcanvas.offcanvas {
    --bs-offcanvas-width: min(300px, 86vw);
    --bs-offcanvas-bg: var(--em-shell);
    --bs-offcanvas-border-width: 0;
    color: var(--em-nav-text);
    padding: 16px 14px 14px;
    background:
        radial-gradient(420px 300px at 0% 0%, rgba(99, 91, 246, .38), transparent 70%),
        var(--em-shell);
}
.em-offcanvas__head { display: flex; align-items: center; justify-content: space-between; }
.em-offcanvas__head .em-brand { padding-bottom: 12px; }
.em-offcanvas .em-nav__link { min-height: 44px; }

/* Canvas ------------------------------------------------------------------ */
.em-main { background: var(--em-canvas); min-height: calc(100vh - 56px); }
.em-content { padding: 20px 16px 16px; max-width: 1680px; margin-inline: auto; }

.em-footer {
    margin-top: 32px;
    padding-top: 16px;
    border-top: 1px solid var(--em-line);
    color: var(--em-muted);
    font-size: .85rem;
    display: flex;
    flex-wrap: wrap;
    gap: 4px 10px;
}
.em-footer a { color: inherit; font-weight: 600; text-decoration: none; }
.em-footer a:hover { color: var(--em-accent-ink); }

@media (min-width: 992px) {
    .em-sidebar { display: flex; }
    .em-mobilebar { display: none; }
    .em-main {
        position: fixed;
        inset: var(--em-frame) var(--em-frame) var(--em-frame) var(--em-sidebar-w);
        min-height: 0;
        overflow-y: auto;
        overscroll-behavior: contain;
        border-radius: var(--em-radius-xl);
        scrollbar-gutter: stable;
    }
    .em-content { padding: 26px 24px 20px; }
}

/* Page header ------------------------------------------------------------- */
.em-page-head {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 12px 20px;
    margin-bottom: 22px;
}
.em-page-head__text { min-width: 0; flex: 1 1 260px; }
.em-page-title { margin: 0; overflow-wrap: anywhere; }
.em-page-title .badge { vertical-align: middle; margin-left: 6px; font-size: .85rem; }
.em-page-sub { margin: 2px 0 0; color: var(--em-muted); }
.em-page-head__actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.em-back {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 4px;
    color: var(--em-muted);
    font-size: .9rem;
    font-weight: 600;
    text-decoration: none;
}
.em-back:hover { color: var(--em-accent-ink); }

/* Live / refresh indicator used in page headers */
.em-live {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    min-height: 38px;
    padding: 0 14px;
    border-radius: var(--em-radius-pill);
    background: var(--em-surface);
    border: 1px solid var(--em-line);
    box-shadow: var(--em-shadow);
    font-size: .9rem;
    font-weight: 600;
    color: var(--em-text);
}
.em-live::before {
    content: "";
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--em-ok);
    box-shadow: 0 0 0 4px var(--em-ok-soft);
}
.em-live.is-paused::before { background: var(--em-muted); box-shadow: 0 0 0 4px var(--em-neutral-soft); }
.em-live.is-offline::before { background: var(--em-bad); box-shadow: 0 0 0 4px var(--em-bad-soft); }
.em-live.is-refreshing::before { background: var(--em-a1); box-shadow: 0 0 0 4px var(--em-accent-soft); animation: em-pulse 1s ease-in-out infinite; }
.em-live .form-check { margin: 0; min-height: 0; padding-left: 2.6em; }

@keyframes em-pulse { 50% { opacity: .35; } }
@keyframes em-spin { to { transform: rotate(360deg); } }
.em-spin { display: inline-block; animation: em-spin 1.2s linear infinite; }

/* Sign-in pages ----------------------------------------------------------- */
body.em-auth {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 24px 16px;
    background:
        radial-gradient(700px 480px at 12% 0%, rgba(99, 91, 246, .45), transparent 70%),
        radial-gradient(600px 460px at 100% 100%, rgba(34, 211, 238, .2), transparent 70%),
        var(--em-shell);
}
.em-auth__theme { position: fixed; top: 16px; right: 16px; width: 200px; max-width: calc(100vw - 32px); }
.em-auth__theme .em-theme-switch { margin-top: 0; }
.em-auth__card {
    width: 100%;
    max-width: 420px;
    padding: 32px 28px 28px;
    border-radius: var(--em-radius-xl);
    background: var(--em-surface);
    border: 1px solid var(--em-line);
    box-shadow: var(--em-shadow-lg);
}
.em-auth__brand { display: flex; flex-direction: column; align-items: center; gap: 10px; margin-bottom: 22px; }
.em-auth__brand .em-brand__mark { width: 48px; height: 48px; border-radius: 15px; font-size: 1.5rem; }
.em-auth__brand span { font-weight: 800; font-size: 1.3rem; letter-spacing: -.02em; }
.em-auth__title { font-size: 1.25rem; text-align: center; margin: 0 0 4px; }
.em-auth__sub { text-align: center; color: var(--em-muted); margin: 0 0 20px; font-size: .95rem; }
.em-auth__foot { margin-top: 18px; text-align: center; color: #fff; font-size: .85rem; }
.em-auth__foot a { color: inherit; font-weight: 600; text-decoration: none; }
