:root {
    --app-primary: #6258d9;
    --app-primary-dark: #4e45bd;
    --app-ink: #1d2340;
    --app-muted: #72798f;
    --app-border: #e7e9f1;
    --app-surface: #fff;
    --app-radius: 20px;
    --app-shadow: 0 24px 70px rgba(37, 45, 91, .11), 0 4px 14px rgba(37, 45, 91, .04);
}

body {
    color: var(--app-ink);
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
}

.login-page {
    min-height: 100vh;
    background:
        radial-gradient(ellipse at 12% 18%, rgba(119, 108, 230, .13), transparent 34%),
        radial-gradient(ellipse at 88% 82%, rgba(105, 179, 218, .12), transparent 34%),
        #f6f7fb;
}

.login-shell {
    max-width: 1440px;
}

.brand-header {
    color: var(--app-ink);
}

.brand-mark {
    display: inline-grid;
    width: 52px;
    height: 52px;
    place-items: center;
    border-radius: 16px;
    color: #fff;
    background: linear-gradient(145deg, #8278ee, var(--app-primary));
    box-shadow: 0 9px 22px rgba(98, 88, 217, .25);
    font-size: 1.3rem;
}

.brand-name {
    margin-top: .8rem;
    font-size: 1rem;
    font-weight: 650;
    letter-spacing: -.02em;
}

.login-card,
.dashboard-card {
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, .85);
    border-radius: var(--app-radius);
    background: rgba(255, 255, 255, .94);
    box-shadow: var(--app-shadow);
}

.login-card-body {
    padding: 2.4rem;
}

.eyebrow {
    color: var(--app-primary);
    font-size: .68rem;
    font-weight: 750;
    letter-spacing: .13em;
}

.login-title {
    color: var(--app-ink);
    font-weight: 700;
    letter-spacing: -.035em;
}

.form-label {
    color: #333a54;
    font-size: .88rem;
    font-weight: 600;
}

.login-input .input-group-text,
.login-input .form-control,
.password-toggle {
    border-color: var(--app-border);
    background-color: #fff;
    font-size: .91rem;
}

.login-input .input-group-text {
    padding-inline: 1rem;
    color: #858ba0;
    border-right: 0;
    border-radius: 12px 0 0 12px;
}

.login-input .form-control {
    min-height: 54px;
    padding-inline: .5rem;
    border-left: 0;
    color: var(--app-ink);
}

.login-input .form-control::placeholder {
    color: #a4a9b8;
    font-size: .84rem;
}

.login-input .form-control:focus {
    border-color: var(--app-border);
    box-shadow: none;
}

.login-input:focus-within .input-group-text,
.login-input:focus-within .form-control,
.login-input:focus-within .password-toggle {
    border-color: var(--app-primary);
}

.login-input:focus-within {
    border-radius: 12px;
    box-shadow: 0 0 0 .22rem rgba(98, 88, 217, .13);
}

.password-toggle {
    min-width: 52px;
    color: #858ba0;
    border-left: 0;
    border-radius: 0 12px 12px 0;
}

.password-toggle:hover {
    color: var(--app-primary);
}

.form-check-input {
    border-color: #c9cddd;
}

.form-check-input:checked {
    border-color: var(--app-primary);
    background-color: var(--app-primary);
}

.form-check-input:focus {
    border-color: var(--app-primary);
    box-shadow: 0 0 0 .2rem rgba(98, 88, 217, .14);
}

.forgot-link {
    color: var(--app-primary);
    font-size: .82rem;
    font-weight: 600;
    text-decoration: none;
}

.forgot-link:hover {
    color: var(--app-primary-dark);
    text-decoration: underline;
}

.sign-in-button {
    min-height: 54px;
    border-color: var(--app-primary);
    border-radius: 12px;
    background: linear-gradient(100deg, #6e64e5, var(--app-primary));
    box-shadow: 0 8px 18px rgba(98, 88, 217, .2);
    font-size: .95rem;
    font-weight: 650;
    transition: transform .18s ease, box-shadow .18s ease, background-color .18s ease;
}

.sign-in-button:hover {
    transform: translateY(-1px);
    border-color: var(--app-primary-dark);
    background: var(--app-primary-dark);
    box-shadow: 0 11px 22px rgba(98, 88, 217, .25);
}

.sign-in-button:focus-visible,
.password-toggle:focus-visible,
a:focus-visible {
    outline: 3px solid rgba(98, 88, 217, .35);
    outline-offset: 3px;
}

.login-footer {
    color: #8b91a3;
    font-size: .76rem;
}

.dashboard-page {
    min-height: 100vh;
    height: 100vh;
    height: 100dvh;
    overflow: hidden;
    background: #f6f7fb;
}

.admin-layout {
    display: flex;
    height: 100%;
    min-height: 0;
    overflow: hidden;
}

.admin-sidebar {
    display: flex;
    width: 260px;
    flex: 0 0 260px;
    flex-direction: column;
    height: 100vh;
    height: 100dvh;
    padding: 1.5rem 1rem 1rem;
    overflow: hidden;
    border-right: 1px solid var(--app-border);
    background: var(--app-surface);
}

.admin-sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.admin-sidebar-content {
    display: flex;
    min-height: 0;
    flex: 1 1 auto;
    flex-direction: column;
}

.admin-sidebar-content.collapse:not(.show) {
    display: flex;
}

.admin-sidebar-toggle {
    display: none;
}

.admin-brand {
    display: flex;
    align-items: center;
    gap: .7rem;
    padding: 0 .5rem;
    color: var(--app-ink);
    font-weight: 700;
    text-decoration: none;
}

.admin-brand-text {
    display: flex;
    flex: 1 1 auto;
    flex-direction: column;
    min-width: 0;
    line-height: 1.2;
    overflow-wrap: anywhere;
}

.admin-brand-client {
    display: block;
    min-width: 0;
    font-size: 1rem;
    font-weight: 700;
    color: var(--app-ink);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.admin-brand-app {
    font-size: .75rem;
    font-weight: 500;
    color: var(--app-muted);
}

.admin-sidebar-user {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: .85rem;
    margin: 1.5rem .5rem 1.25rem;
    min-width: 0;
    overflow-wrap: anywhere;
    text-align: left;
}

.admin-sidebar-mini {
    display: none;
    min-width: 0;
    flex: 1 1 auto;
    align-items: center;
    justify-content: flex-end;
    gap: .55rem;
}

.admin-sidebar-mini-text {
    display: grid;
    min-width: 0;
    gap: .05rem;
    text-align: right;
}

.admin-sidebar-mini-text strong,
.admin-sidebar-mini-text > span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: var(--app-ink);
}

.admin-sidebar-mini-text strong {
    font-size: .85rem;
    font-weight: 650;
}

.admin-sidebar-mini-text > span {
    color: var(--app-muted);
    font-size: .72rem;
}

.profile-mini-avatar {
    display: inline-flex;
    width: 36px;
    height: 36px;
    flex: 0 0 auto;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    border: 1px solid var(--app-border);
    border-radius: 50%;
    background: var(--app-surface);
    color: var(--app-ink);
    font-size: .8rem;
    font-weight: 700;
}

.profile-mini-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.admin-sidebar-nav {
    display: grid;
    gap: .35rem;
}

.admin-sidebar-link {
    position: relative;
    display: flex;
    align-items: center;
    gap: .75rem;
    padding: .75rem .85rem;
    border-radius: 10px;
    color: #555d74;
    font-size: .9rem;
    font-weight: 600;
    text-decoration: none;
}

.admin-sidebar-link:hover,
.admin-sidebar-link.active {
    color: var(--app-primary-dark);
    background: #f0efff;
}

.admin-sidebar-link i {
    font-size: 1.1rem;
}

.chat-launcher-badge {
    position: absolute;
    top: -.3rem;
    right: -.3rem;
    display: inline-flex;
    min-width: 1.25rem;
    height: 1.25rem;
    align-items: center;
    justify-content: center;
    padding: 0 .3rem;
    border-radius: 999px;
    color: #fff;
    background: #c4374a;
    border: 2px solid var(--app-surface, #fff);
    box-shadow: 0 2px 6px rgba(37, 45, 91, .2);
    font-size: .68rem;
    font-weight: 750;
    line-height: 1;
}

.chat-launcher {
    position: fixed;
    right: 1.25rem;
    bottom: 1.25rem;
    z-index: 1070;
    display: inline-flex;
    min-height: 48px;
    align-items: center;
    gap: .55rem;
    padding: .7rem 1rem;
    border: 1px solid rgba(255,255,255,.25);
    border-radius: 999px;
    color: #fff;
    background: var(--app-primary, #6258d9);
    box-shadow: 0 8px 26px rgba(37, 45, 91, .24);
    font-size: .88rem;
    font-weight: 700;
    text-decoration: none;
    transition: transform .16s ease, box-shadow .16s ease;
}

.chat-launcher:hover {
    color: #fff;
    transform: translateY(-2px);
    box-shadow: 0 12px 30px rgba(37, 45, 91, .3);
}

.chat-launcher:focus-visible {
    outline: 3px solid color-mix(in srgb, var(--app-primary, #6258d9) 50%, #fff);
    outline-offset: 3px;
}

.chat-launcher > i {
    font-size: 1.05rem;
}

.chat-launcher-badge[hidden] {
    display: none;
}

.admin-sidebar-logout {
    margin-top: auto;
    padding-top: 2rem;
}

/* Desktop: the user card and Sign out stay pinned; only the menu list scrolls when it is taller than the space left. */
@media (min-width: 992px) {
    .admin-sidebar-user,
    .admin-sidebar-logout {
        flex: 0 0 auto;
    }

    .admin-sidebar-nav {
        --sidebar-fade-top: 0px;
        --sidebar-fade-bottom: 0px;
        flex: 1 1 auto;
        min-height: 0;
        overflow-y: hidden;
        overscroll-behavior: contain;
        padding-inline-end: .25rem;
        scrollbar-width: thin;
        scrollbar-color: color-mix(in srgb, var(--sidebar-ink, #555d74) 28%, transparent) transparent;
        -webkit-mask-image: linear-gradient(to bottom, transparent 0, #000 var(--sidebar-fade-top), #000 calc(100% - var(--sidebar-fade-bottom)), transparent 100%);
        mask-image: linear-gradient(to bottom, transparent 0, #000 var(--sidebar-fade-top), #000 calc(100% - var(--sidebar-fade-bottom)), transparent 100%);
    }

    .admin-sidebar-nav.is-scrollable {
        overflow-y: auto;
    }

    .admin-sidebar-nav.has-fade-top {
        --sidebar-fade-top: 1.25rem;
    }

    .admin-sidebar-nav.has-fade-bottom {
        --sidebar-fade-bottom: 1.25rem;
    }

    .admin-sidebar-nav::-webkit-scrollbar {
        width: 6px;
    }

    .admin-sidebar-nav::-webkit-scrollbar-thumb {
        border-radius: 999px;
        background: color-mix(in srgb, var(--sidebar-ink, #555d74) 28%, transparent);
    }
}

.admin-main {
    width: 100%;
    height: 100vh;
    height: 100dvh;
    min-width: 0;
    overflow-y: auto;
    overscroll-behavior: contain;
    padding: 2.5rem clamp(1rem, 4vw, 3.5rem);
}

.brand-mark-small {
    width: 34px;
    height: 34px;
    border-radius: 10px;
    font-size: .95rem;
}

.dashboard-heading h1 {
    color: var(--app-ink);
    font-weight: 700;
    letter-spacing: -.03em;
}

.dashboard-card {
    border-color: var(--app-border);
    background: var(--app-surface);
    box-shadow: 0 8px 26px rgba(37, 45, 91, .045);
}

.daily-message-card {
    overflow: hidden;
    border: 1px solid var(--app-border);
    border-radius: var(--app-radius);
    background: var(--app-surface);
    background: linear-gradient(115deg, var(--app-surface), color-mix(in srgb, var(--app-primary) 6%, var(--app-surface)));
    box-shadow: 0 8px 26px rgba(37, 45, 91, .045);
}

.daily-message-card-body {
    display: flex;
    align-items: flex-start;
    gap: 1.15rem;
    padding: clamp(1.25rem, 3vw, 2rem);
    border-left: 4px solid var(--app-primary);
}

.daily-message-icon {
    display: grid;
    width: 2.8rem;
    height: 2.8rem;
    flex: 0 0 auto;
    place-items: center;
    border-radius: 14px;
    color: var(--app-primary);
    background: color-mix(in srgb, var(--app-primary) 12%, var(--app-surface));
    font-size: 1.2rem;
}

.daily-message-content {
    min-width: 0;
}

.daily-message-text {
    margin: 0;
    color: var(--app-ink);
    font-size: clamp(1.05rem, 1.8vw, 1.35rem);
    font-weight: 500;
    line-height: 1.55;
    overflow-wrap: anywhere;
}

.daily-message-attribution {
    margin-top: .8rem;
    color: var(--app-muted);
    font-size: .9rem;
    font-weight: 600;
}

.profile-avatar {
    display: grid;
    width: 46px;
    height: 46px;
    place-items: center;
    border-radius: 14px;
    color: var(--app-primary);
    background: #f0efff;
    font-size: 1.25rem;
}

.profile-details dt,
.profile-details dd {
    padding-block: .8rem;
    border-bottom: 1px solid #f0f1f5;
    font-size: .9rem;
}

.profile-details dt {
    color: var(--app-muted);
    font-weight: 500;
}

.profile-details dd {
    margin-bottom: 0;
    color: var(--app-ink);
    font-weight: 600;
    overflow-wrap: anywhere;
}

@media (max-width: 575.98px) {
    .login-card-body {
        padding: 1.6rem 1.25rem;
    }

    .login-card {
        border-radius: 16px;
    }
}

@media (max-width: 991.98px) {
    .dashboard-page {
        height: auto;
        overflow: auto;
    }

    .admin-layout {
        display: block;
        height: auto;
        min-height: 100vh;
        overflow: visible;
    }

    .admin-sidebar {
        width: 100%;
        height: auto;
        padding: .8rem 1rem;
        overflow: visible;
        border-right: 0;
        border-bottom: 1px solid var(--app-border);
    }

    .admin-sidebar-toggle {
        display: inline-flex;
        width: 40px;
        height: 40px;
        align-items: center;
        justify-content: center;
        border: 1px solid var(--app-border);
        border-radius: 10px;
        color: var(--app-ink);
        background: var(--app-surface);
        font-size: 1.35rem;
    }

    .admin-sidebar-toggle:hover,
    .admin-sidebar-toggle:focus-visible {
        color: var(--app-accent);
        background: var(--app-hover-bg);
    }

    .admin-sidebar-toggle:focus-visible {
        outline: 2px solid var(--app-accent);
        outline-offset: 2px;
    }

    /* Below the large breakpoint the menu is a slide-in drawer (Bootstrap offcanvas-lg). */
    .admin-sidebar-content.offcanvas-lg {
        --bs-offcanvas-width: min(86vw, 320px);
        padding: 1rem;
        overflow-y: auto;
    }

    .admin-sidebar-content.offcanvas-lg .offcanvas-header {
        display: flex;
        align-items: center;
        justify-content: space-between;
        margin-bottom: .5rem;
        padding: 0 0 .75rem;
        border-bottom: 1px solid var(--app-border);
    }

    .admin-sidebar-content.offcanvas-lg .admin-sidebar-nav {
        grid-template-columns: 1fr;
    }

    .admin-sidebar-mini {
        display: inline-flex;
    }

    /* When the menu is open, the full identity card shows, so hide the header copy to avoid duplicates. */
    .admin-sidebar:has(#admin-sidebar-content.show) .admin-sidebar-mini {
        display: none;
    }

    .admin-brand {
        padding: 0;
    }

    .admin-sidebar-user {
        margin: .65rem 0 .25rem;
    }

    .admin-sidebar-nav {
        display: grid;
        grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
        gap: .35rem;
        margin-top: .75rem;
    }

    .admin-sidebar-link {
        min-width: 0;
        min-height: 44px;
        padding: .55rem .7rem;
    }

    .admin-sidebar-link > span {
        min-width: 0;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .admin-sidebar-logout {
        position: static;
        margin-top: .75rem;
        padding: 0;
    }

    .admin-sidebar-logout .btn {
        padding: .35rem .55rem;
        font-size: .8rem;
    }

    .admin-main {
        height: auto;
        overflow: visible;
        padding: 1.5rem 1rem;
    }
}

@media (max-width: 420px) {
    .admin-sidebar-mini-text > span {
        display: none;
    }
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        scroll-behavior: auto !important;
        transition-duration: .01ms !important;
    }
}

/* Connection strength indicator under the role in the sidebar. */
.connection-indicator {
    display: inline-flex;
    align-items: center;
    gap: .4rem;
    margin-top: .3rem;
    font-size: .75rem;
    line-height: 1.2;
    color: var(--app-muted);
}

.connection-bars {
    display: inline-flex;
    align-items: flex-end;
    gap: 2px;
    height: 14px;
}

.connection-bars > span {
    width: 4px;
    border-radius: 1px;
    background: currentColor;
    opacity: .25;
}

.connection-bars > span:nth-child(1) { height: 4px; }
.connection-bars > span:nth-child(2) { height: 7px; }
.connection-bars > span:nth-child(3) { height: 10px; }
.connection-bars > span:nth-child(4) { height: 14px; }

.connection-bars > span.is-on {
    opacity: 1;
}

/* Scoped to the sidebar so the theme's sidebar text colour does not override the signal colour. */
.admin-sidebar .profile-user-identity .connection-indicator[data-level="4"],
.admin-sidebar .profile-user-identity .connection-indicator[data-level="3"] {
    color: #4ade80;
}

.admin-sidebar .profile-user-identity .connection-indicator[data-level="2"] {
    color: #fbbf24;
}

.admin-sidebar .profile-user-identity .connection-indicator[data-level="1"],
.admin-sidebar .profile-user-identity .connection-indicator[data-level="0"] {
    color: #f87171;
}

/* The label takes the signal colour from the indicator. */
.admin-sidebar .profile-user-identity .connection-indicator .connection-label {
    color: inherit;
}

/* Bars: unlit bars are neutral grey; lit bars use the level colour set explicitly per level. */
.admin-sidebar .profile-user-identity .connection-indicator .connection-bars > span {
    background-color: rgba(148, 163, 184, .35);
    opacity: 1;
}

.admin-sidebar .profile-user-identity .connection-indicator[data-level="4"] .connection-bars > span.is-on,
.admin-sidebar .profile-user-identity .connection-indicator[data-level="3"] .connection-bars > span.is-on {
    background-color: #4ade80;
}

.admin-sidebar .profile-user-identity .connection-indicator[data-level="2"] .connection-bars > span.is-on {
    background-color: #fbbf24;
}

.admin-sidebar .profile-user-identity .connection-indicator[data-level="1"] .connection-bars > span.is-on,
.admin-sidebar .profile-user-identity .connection-indicator[data-level="0"] .connection-bars > span.is-on {
    background-color: #f87171;
}

/* Role badge and signal bars sit side by side. */
.profile-role-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: .5rem;
}

.admin-sidebar .profile-user-identity .connection-indicator {
    position: relative;
    margin-top: 0;
    padding: .15rem .25rem;
    border-radius: .35rem;
    cursor: default;
}

.admin-sidebar .profile-user-identity .connection-indicator:focus-visible {
    outline: 2px solid currentColor;
    outline-offset: 2px;
}

/* The label appears as a popup on hover or keyboard focus. */
.admin-sidebar .profile-user-identity .connection-indicator .connection-label {
    position: absolute;
    top: calc(100% + 6px);
    right: 0;
    left: auto;
    z-index: 1100;
    padding: .3rem .55rem;
    border-radius: .4rem;
    background: #111827;
    font-size: .8rem;
    font-weight: 600;
    white-space: nowrap;
    box-shadow: 0 6px 18px rgba(0, 0, 0, .35);
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity .15s ease;
}

.admin-sidebar .profile-user-identity .connection-indicator:hover .connection-label,
.admin-sidebar .profile-user-identity .connection-indicator:focus-visible .connection-label {
    opacity: 1;
    visibility: visible;
}
