/* ============================================================
   Base reset
   ============================================================ */
html,
body {
    min-height: 100%;
    margin: 0;
}

body {
    font-family: 'Roboto', sans-serif;
    background: #f8fafc;
    color: #0f172a;
}

#app {
    min-height: 100vh;
}

/* ============================================================
   CSS Variables
   ============================================================ */
:root {
    --ink: #1f2240;
    --paper: #ffffff;
    --muted: #eef0ff;
    --line: #cfd3ff;
    --good: #2ecc71;
    --badge: #ffcc66;

    --app-bar-height: 64px;
    --drawer-width: 240px;
    --border-radius-card: 20px;
    --border-radius-chip: 50px;
    --transition-fast: 150ms ease;
    --transition-medium: 250ms ease;
}

/* ============================================================
   Scrollbar
   ============================================================ */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: rgba(100, 116, 139, 0.35);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(100, 116, 139, 0.6);
}

/* ============================================================
   App Bar
   ============================================================ */
.app-bar {
    backdrop-filter: blur(12px) saturate(180%);
    -webkit-backdrop-filter: blur(12px) saturate(180%);
    border-bottom: 1px solid rgba(203, 213, 225, 0.45) !important;
    transition: box-shadow var(--transition-medium);
}

.app-bar--admin {
    background: linear-gradient(135deg, #f5f4ff 0%, #eef2ff 100%) !important;
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
    border-bottom: 1px solid rgba(79, 70, 229, 0.15) !important;
    box-shadow: 0 1px 6px rgba(79, 70, 229, 0.08) !important;
}

.app-bar--admin .mud-typography,
.app-bar--admin .mud-button-root,
.app-bar--admin .mud-icon-root,
.app-bar--admin .mud-svg-icon {
    color: #1e293b !important;
}

/* Admin title badge */
.admin-title-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    background: rgba(79, 70, 229, 0.09);
    border: 1px solid rgba(79, 70, 229, 0.2);
    border-radius: 8px;
    padding: 0.25rem 0.65rem 0.25rem 0.45rem;
}

.admin-title-badge__icon {
    color: #4f46e5 !important;
    font-size: 1rem !important;
}

.admin-title-badge__text {
    font-size: 0.8rem;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: #4f46e5;
}

.app-bar__account-info {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-left: 0.75rem;
    padding-left: 0.75rem;
    border-left: 1px solid rgba(100, 116, 139, 0.25);
}

.app-bar__account-name {
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 220px;
}

.app-bar__user-button {
    text-transform: none !important;
    font-weight: 500;
    font-size: 0.875rem !important;
}

/* ============================================================
   Logo
   ============================================================ */
.home-logo-link {
    display: flex;
    align-items: center;
    text-decoration: none;
    margin-left: 0.25rem;
}

.home-logo-image {
    height: 36px;
    width: auto;
    object-fit: contain;
    transition: opacity var(--transition-fast);
}

.home-logo-image:hover {
    opacity: 0.85;
}

/* ============================================================
   Drawer / Nav
   ============================================================ */
.nav-drawer {
    border-right: 1px solid rgba(203, 213, 225, 0.4) !important;
}

.nav-drawer__header {
    padding: 0.5rem 1rem 0.25rem;
}

.nav-drawer__header-label {
    color: rgba(100, 116, 139, 0.75);
    font-size: 0.65rem;
    letter-spacing: 0.1em;
}

.nav-menu {
    display: flex;
    flex-direction: column;
}

.nav-menu__link {
    border-radius: 10px !important;
    margin: 1px 0;
    transition: background var(--transition-fast);
}

.nav-menu__group {
    margin: 2px 0;
}

.nav-menu__group-title {
    font-weight: 500;
}

.nav-menu__section-label {
    color: rgba(100, 116, 139, 0.75);
    font-size: 0.65rem;
    letter-spacing: 0.1em;
    display: block;
}

/* ============================================================
   Main content
   ============================================================ */
.main-content {
    transition: padding var(--transition-medium);
}

.main-content__alerts {
    margin-bottom: 1rem;
}

/* ============================================================
   Home page
   ============================================================ */
.home-hero {
    margin-bottom: 1.5rem;
    padding: 1.5rem 0.25rem 0.5rem;
    border-bottom: 1px solid rgba(203, 213, 225, 0.5);
}

.home-hero__title {
    font-weight: 700;
    letter-spacing: -0.01em;
}

.home-hero__subtitle {
    margin-top: 0.25rem;
}

.home-empty-state {
    border: 2px dashed rgba(203, 213, 225, 0.7);
    border-radius: var(--border-radius-card);
}

/* ============================================================
   Loading screen
   ============================================================ */
#loading-screen {
    position: fixed;
    inset: 0;
    margin: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(180deg, #ffffff 0%, #f8fafc 100%);
}

.loading-screen__content {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    padding: 1.5rem;
}

.loading-screen__illustration {
    width: min(100%, 400px);
    height: auto;
}

#loading-screen .shadow {
    filter: url(#shadow);
}

#loading-screen .paper {
    fill: var(--paper);
    stroke: var(--line);
    stroke-width: 10;
}

#loading-screen .clip {
    fill: var(--muted);
    stroke: var(--line);
    stroke-width: 10;
}

#loading-screen .tick {
    fill: none;
    stroke: var(--good);
    stroke-width: 18;
    stroke-linecap: round;
    stroke-linejoin: round;
}

#loading-screen .rule {
    fill: none;
    stroke: var(--line);
    stroke-width: 14;
    stroke-linecap: round;
}
#loading-screen .badge {
    fill: var(--badge);
    stroke: rgba(31, 34, 64, 0.12);
    stroke-width: 10;
}

#loading-screen .badgeText {
    font-family: system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
    font-weight: 800;
    fill: rgba(31, 34, 64, 0.75);
}

#powered-by-ai-badge .pill {
    fill: url(#poweredBadgeGrad);
}

#powered-by-ai-badge .text {
    font-family: system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
    font-weight: 800;
    fill: #ffffff;
    letter-spacing: 0.6px;
}

#powered-by-ai-badge .spark {
    fill: rgba(255, 255, 255, 0.75);
}

@media (max-width: 600px) {
    .loading-screen__content {
        padding: 1rem;
    }

    .home-logo-link {
        display: none;
    }
}

.home-logo-link {
    display: inline-flex;
    align-items: center;
    margin-left: 0.5rem;
}

.home-logo-image {
    height: 2.5rem;
    width: auto;
    cursor: pointer;
}

/* Help article header — global override so MudText colour rules are beaten */
.help-article-header,
.help-article-header * {
    color: #fff !important;
}

/* =================================================================
   HELP ARTICLE - TYPOGRAPHY & CALLOUTS
   (global — targets MarkupString-injected HTML, no scope attribute)
   ================================================================= */

.help-article-content h2,
.help-article-content h3 {
    scroll-margin-top: 5rem;
    line-height: 1.35;
}

.help-article-content article > h2:first-child {
    display: none;
}

.help-article-content h3 {
    display: flex;
    align-items: center;
    gap: 0.55rem;
    font-size: 0.78rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.09em;
    color: var(--mud-palette-primary);
    margin: 1.85rem 0 0.65rem;
    padding-bottom: 0.45rem;
    border-bottom: 2px solid var(--mud-palette-primary);
    opacity: 0.9;
}

.help-article-content h3::before {
    content: '';
    display: inline-block;
    width: 4px;
    height: 1rem;
    background: var(--mud-palette-primary);
    border-radius: 2px;
    flex-shrink: 0;
}

.help-article-content p {
    margin: 0 0 0.85rem;
    color: var(--mud-palette-text-secondary);
}

.help-article-content ul {
    list-style: none;
    padding: 0;
    margin: 0 0 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.help-article-content ul > li {
    display: flex;
    align-items: flex-start;
    gap: 0.6rem;
    padding: 0.55rem 0.75rem;
    background: var(--mud-palette-background-grey);
    border-radius: 6px;
    border-left: 3px solid var(--mud-palette-divider);
    line-height: 1.55;
    color: var(--mud-palette-text-primary);
    font-size: 0.92rem;
}

.help-article-content ul > li::before {
    content: "\203A";
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--mud-palette-primary);
    line-height: 1.4;
    flex-shrink: 0;
}

.help-article-content ol {
    list-style: none;
    padding: 0;
    margin: 0 0 1rem;
    counter-reset: help-step;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.help-article-content ol > li {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    counter-increment: help-step;
    padding: 0.65rem 0.9rem 0.65rem 0.75rem;
    background: var(--mud-palette-surface);
    border: 1px solid var(--mud-palette-divider);
    border-left: 3px solid var(--mud-palette-primary);
    border-radius: 6px;
    line-height: 1.55;
    color: var(--mud-palette-text-primary);
    font-size: 0.92rem;
}

.help-article-content ol > li::before {
    content: counter(help-step);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 1.6rem;
    height: 1.6rem;
    border-radius: 50%;
    background: var(--mud-palette-primary);
    color: var(--mud-palette-primary-text);
    font-size: 0.72rem;
    font-weight: 700;
    flex-shrink: 0;
    margin-top: 0.1rem;
}

.help-article-content strong {
    font-weight: 600;
    color: var(--mud-palette-text-primary);
}

/* Callout boxes */
.help-article-content .help-note,
.help-article-content .help-tip,
.help-article-content .help-warning {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
    border-radius: 8px;
    padding: 0.9rem 1.1rem;
    margin: 1.25rem 0;
    color: var(--mud-palette-text-primary);
}

.help-article-content .help-note {
    background: rgba(33, 150, 243, 0.07);
    border: 1px solid rgba(33, 150, 243, 0.25);
    border-left: 4px solid var(--mud-palette-info);
}

.help-article-content .help-tip {
    background: rgba(76, 175, 80, 0.07);
    border: 1px solid rgba(76, 175, 80, 0.25);
    border-left: 4px solid var(--mud-palette-success);
}

.help-article-content .help-warning {
    background: rgba(255, 152, 0, 0.07);
    border: 1px solid rgba(255, 152, 0, 0.25);
    border-left: 4px solid var(--mud-palette-warning);
}

.help-article-content .help-note p,
.help-article-content .help-tip p,
.help-article-content .help-warning p {
    margin-bottom: 0;
    color: inherit;
    font-size: 0.9rem;
}

.help-article-content .help-note strong,
.help-article-content .help-tip strong,
.help-article-content .help-warning strong {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    margin-bottom: 0.2rem;
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.09em;
}

.help-article-content .help-note strong    { color: var(--mud-palette-info); }
.help-article-content .help-tip strong     { color: var(--mud-palette-success); }
.help-article-content .help-warning strong { color: var(--mud-palette-warning); }

.help-article-content .help-note strong::before    { content: "i"; font-style: italic; font-size: 0.85rem; font-weight: 900; }
.help-article-content .help-tip strong::before     { content: "\2713"; font-style: normal; font-size: 0.85rem; }
.help-article-content .help-warning strong::before { content: "!"; font-style: normal; font-size: 0.85rem; font-weight: 900; }

.help-article-content .help-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
    margin: 0.75rem 0 1rem;
}

.help-article-content .help-table th {
    text-align: left;
    padding: 0.45rem 0.75rem;
    background: rgba(241, 245, 249, 0.9);
    font-weight: 700;
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    border-bottom: 2px solid rgba(148, 163, 184, 0.35);
}

.help-article-content .help-table td {
    padding: 0.55rem 0.75rem;
    border-bottom: 1px solid rgba(226, 232, 240, 0.75);
    vertical-align: top;
}

.help-article-content .help-table tbody tr:last-child td {
    border-bottom: none;
}

@media (max-width: 600px) {
    .help-article-content h3 { font-size: 0.72rem; }
}

/* Shared workflow diagrams for help articles and the unit progress dialog. */
.help-flow {
    margin: 1rem 0 1.5rem;
    padding: clamp(0.85rem, 3vw, 1.4rem);
    border: 1px solid var(--mud-palette-divider);
    border-radius: 16px;
    background: var(--mud-palette-background-grey);
    color: var(--mud-palette-text-primary);
}

.help-flow figcaption {
    margin-bottom: 1rem;
    font-size: 1rem;
    font-weight: 700;
}

.help-flow .help-flow-lane {
    padding: 1rem;
    border: 1px solid var(--mud-palette-divider);
    border-radius: 12px;
    background: var(--mud-palette-surface);
}

.help-flow .help-flow-lane + .help-flow-lane {
    margin-top: 1rem;
}

.help-flow .help-flow-lane--optional {
        margin-top: 1rem;
    border: 2px dashed var(--mud-palette-divider);
}

.help-flow .help-flow-label {
    margin: 0 0 0.8rem;
    color: var(--mud-palette-text-primary);
    font-size: 0.85rem;
    font-weight: 700;
}

.help-flow ol.help-flow-steps {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 1.5rem;
    margin: 0;
    padding: 0;
    list-style: none;
    counter-reset: flow-step;
}

.help-flow ol.help-flow-steps > li {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 0.4rem;
    min-width: 0;
    margin: 0;
    padding: 0.9rem;
    border: 1px solid var(--mud-palette-divider);
    border-top: 3px solid var(--mud-palette-primary);
    border-radius: 10px;
    background: var(--mud-palette-surface);
    color: var(--mud-palette-text-primary);
    line-height: 1.45;
    font-size: 0.9rem;
    overflow-wrap: anywhere;
    counter-increment: flow-step;
}

.help-flow ol.help-flow-steps > li::before {
    content: counter(flow-step, decimal-leading-zero);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 1.8rem;
    height: 1.8rem;
    margin: 0 0 0.2rem;
    border-radius: 6px;
    background: var(--mud-palette-primary);
    color: var(--mud-palette-primary-text);
    font-size: 0.75rem;
    font-weight: 700;
}

.help-flow ol.help-flow-steps > li:not(:last-child)::after {
    content: "";
    position: absolute;
    top: 50%;
    right: -1.05rem;
    width: 0.55rem;
    height: 0.55rem;
    border-top: 2px solid var(--mud-palette-text-secondary);
    border-right: 2px solid var(--mud-palette-text-secondary);
    transform: rotate(45deg);
}

.help-flow ol.help-flow-steps > li.help-flow-outcome {
    border-top-color: var(--mud-palette-success);
}

.help-flow .help-flow-steps strong {
    color: var(--mud-palette-text-primary);
    font-weight: 700;
}

.help-flow .help-flow-steps span {
    color: var(--mud-palette-text-secondary);
}

.help-flow .help-flow-return,
.help-flow .help-flow-note {
    margin: 1rem 0 0;
    padding: 0.75rem 0.9rem;
    border-radius: 8px;
    color: var(--mud-palette-text-primary);
    font-size: 0.85rem;
    line-height: 1.5;
}

.help-flow .help-flow-return {
    border-left: 3px solid var(--mud-palette-warning);
    background: var(--mud-palette-background-grey);
}

.help-flow .help-flow-note {
    border-left: 3px solid var(--mud-palette-success);
    background: var(--mud-palette-surface);
}

@media (max-width: 900px) {
    .help-flow ol.help-flow-steps {
        grid-template-columns: minmax(0, 1fr);
    }

    .help-flow ol.help-flow-steps > li:not(:last-child)::after {
        top: auto;
        bottom: -1.05rem;
        right: calc(50% - 0.275rem);
        transform: rotate(135deg);
    }
}

/* Getting-started journey: adapt to the article width, not the viewport. */
.help-service-journey {
    container-type: inline-size;
    background: linear-gradient(145deg, var(--mud-palette-surface), var(--mud-palette-background-grey));
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.06);
}

.help-service-journey figcaption {
    margin-bottom: 0.35rem;
    font-size: 1.15rem;
    line-height: 1.4;
}

.help-service-journey .help-service-journey-intro {
    margin-bottom: 1.25rem;
    font-size: 0.9rem;
}

.help-service-journey .help-flow-lane {
    --journey-accent: var(--mud-palette-primary);
    border-top: 4px solid var(--journey-accent);
    box-shadow: 0 3px 12px rgba(0, 0, 0, 0.04);
}

.help-service-journey .help-flow-lane--optional {
    --journey-accent: var(--mud-palette-secondary);
    margin-top: 0;
}

.help-service-journey-header {
    display: flex;
    align-items: center;
    gap: 0.85rem;
    margin-bottom: 1.1rem;
}

.help-service-journey-badge {
    display: grid;
    place-items: center;
    flex: 0 0 2.75rem;
    height: 2.75rem;
    border-radius: 14px;
    background: var(--journey-accent);
    color: var(--mud-palette-primary-text);
    font-size: 1.1rem;
    font-weight: 800;
}

.help-service-journey .help-flow-lane--optional .help-service-journey-badge {
    color: var(--mud-palette-secondary-text);
}

.help-service-journey .help-service-journey-eyebrow {
    margin: 0 0 0.15rem;
    color: var(--mud-palette-text-secondary);
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.help-service-journey .help-flow-label {
    margin: 0;
    font-size: 1rem;
    line-height: 1.4;
}

.help-service-journey ol.help-flow-steps {
    grid-template-columns: minmax(0, 1fr);
}

.help-service-journey ol.help-flow-steps > li {
    border-left: 1px solid var(--mud-palette-divider);
    border-top-color: var(--journey-accent);
    background: var(--mud-palette-background-grey);
}

.help-service-journey ol.help-flow-steps > li::before {
    border-radius: 50%;
    background: var(--journey-accent);
    color: var(--mud-palette-primary-text);
}

.help-service-journey .help-flow-lane--optional ol.help-flow-steps > li::before {
    color: var(--mud-palette-secondary-text);
}

.help-service-journey ol.help-flow-steps > li.help-flow-outcome {
    border-top-color: var(--mud-palette-success);
}

.help-service-journey ol.help-flow-steps > li:not(:last-child)::after {
    top: auto;
    bottom: -1.05rem;
    right: calc(50% - 0.275rem);
    transform: rotate(135deg);
}

.help-service-journey-bridge {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.85rem;
    padding: 1.1rem 0;
}

.help-service-journey-bridge > span {
    color: var(--mud-palette-secondary);
    font-size: 2rem;
    line-height: 1;
}

.help-service-journey .help-service-journey-bridge p {
    margin: 0;
    font-size: 0.85rem;
    line-height: 1.5;
}

.help-service-journey .help-service-journey-footer {
    margin: 1.25rem 0 0;
    color: var(--mud-palette-text-secondary);
    font-size: 0.8rem;
    text-align: center;
}

@container (min-width: 560px) {
    .help-service-journey ol.help-flow-steps {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }

    .help-service-journey ol.help-flow-steps > li:not(:last-child)::after {
        top: 50%;
        bottom: auto;
        right: -1.05rem;
        transform: rotate(45deg);
    }
}

/* Users page action menu */
.users-action-menu .mud-menu-item {
    font-size: 0.875rem;
    min-height: 36px;
}

.users-action-menu .mud-menu-item .mud-icon-root {
    font-size: 1.1rem;
}

