/* Magic Scales product styles (WP1): the marketing pages and docs (carried over from the POC's docs.css, without the
   syntax highlighting, D-WP1-11), the Contact Mastech form, and the application shell (.Client/Layout/MainLayout).
   Loaded after the UiKit theme's token sets, so it only uses their variables; the fallbacks are the dark set's. */

/* ---- Colour-scheme roles (WP1a R1a, DD8; UI polish and themes R15) -------------------------------------------------
   The mapping of the --scheme-* roles onto the --mastech-* and --rz-* variables is UiKit's css/themes/roles.css, a
   token sheet of every theme (ColourScheme.Theme, UiKitThemes.WaywareLight). */

html,
body {
    background-color: var(--scheme-background);
    color: var(--scheme-text);
}

h1,
h2,
h3,
h4 {
    color: var(--scheme-heading);
}

a,
.btn-link {
    color: var(--scheme-primary);
}

a:hover,
.btn-link:hover {
    color: var(--rz-link-hover-color);
}

:root {
    --ms-fg: var(--mastech-text, #e6edf3);
    --ms-muted: var(--mastech-text-muted, #9fb0c2);
    --ms-surface: var(--mastech-surface-raised, #1a2532);
    --ms-surface-elevated: color-mix(in srgb, var(--scheme-surface) 94%, var(--scheme-heading));
    --ms-border: var(--mastech-border, #2c3c4f);
    --ms-border-strong: color-mix(in srgb, var(--scheme-surface) 65%, var(--scheme-heading));
    --ms-accent: var(--mastech-accent, #6fb3e8);
    --ms-accent-strong: var(--mastech-brand, #084D84);
    --ms-accent-fg: var(--scheme-on-primary);
    /* Global-mode text on the page surface: a light purple (about 6.6:1 on #121a24). The UiKit global colour
       (--mastech-account-menu-global-background) is a fill for white text, too dark to be text itself. */
    --ms-global-fg: #b48cf2;
    --ms-code-bg: var(--mastech-surface-sunken, #0d141c);
    --ms-shadow: 0 1px 3px rgba(0, 0, 0, 0.35);
    /* "2026-11-20 Magic Scales burger menu" (R2, DD8): the scrim's colour, the page background mixed toward black, so the
       scrim dims the page in Dark and Light alike (the sunken surface is lighter than the page in Dark). */
    --ms-scrim: color-mix(in srgb, var(--scheme-background) 40%, black);
}

/* ---- Marketing layout --------------------------------------------------------------------------------------------- */

.ms-marketing {
    max-width: 78rem;
    margin: 0 auto;
    padding: 0 1.5rem;
}

.ms-marketing-header {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.75rem 2rem;
    padding: 1rem 0;
    border-bottom: 1px solid var(--ms-border);
}

.ms-brand {
    font-weight: 700;
    font-size: 1.2rem;
    color: var(--ms-fg);
    text-decoration: none;
}

.ms-marketing-nav {
    display: flex;
    flex-wrap: wrap;
    gap: 1.25rem;
    flex: 1 1 auto;
}

.ms-marketing-nav a {
    color: var(--ms-muted);
    text-decoration: none;
}

.ms-marketing-nav a:hover {
    color: var(--ms-fg);
}

.ms-marketing-actions {
    display: flex;
    gap: 0.6rem;
}

.ms-marketing-main {
    padding: 1rem 0 0;
}

/* ---- Shared building blocks ---------------------------------------------------------------------------------------- */

.muted {
    color: var(--ms-muted);
}

.card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(17rem, 1fr));
    gap: 1rem;
    margin: 1.25rem 0;
    padding: 0;
    list-style: none;
}

.card-grid-2 {
    grid-template-columns: repeat(auto-fill, minmax(22rem, 1fr));
}

.card {
    display: block;
    border: 1px solid var(--ms-border);
    background: linear-gradient(180deg, var(--ms-surface) 0%, var(--ms-surface-elevated) 100%);
    border-radius: 0.75rem;
    padding: 1.05rem 1.15rem;
    box-shadow: var(--ms-shadow);
    text-decoration: none;
    color: inherit;
}

a.card:hover {
    border-color: var(--ms-accent);
    color: inherit;
}

.card h3 {
    margin: 0 0 0.4rem;
    font-size: 1.05rem;
    color: var(--ms-fg);
}

.card p {
    margin: 0;
    color: var(--ms-muted);
    font-size: 0.92rem;
    line-height: 1.5;
}

.card .card-more {
    display: inline-block;
    margin-top: 0.7rem;
    color: var(--ms-accent);
    font-size: 0.88rem;
    font-weight: 600;
}

.card .card-btn {
    margin-top: 0.8rem;
    padding: 0.45rem 0.9rem;
    font-size: 0.88rem;
}

.card-list {
    margin: 0;
    padding-left: 1.1rem;
    font-size: 0.92rem;
    line-height: 1.6;
}

.btn {
    display: inline-block;
    border-radius: 0.6rem;
    padding: 0.55rem 1.1rem;
    font-weight: 600;
    text-decoration: none;
    border: 1px solid var(--ms-border-strong);
    background: var(--ms-surface-elevated);
    color: var(--ms-fg);
    cursor: pointer;
    font: inherit;
}

a.btn {
    color: var(--ms-fg);
}

.btn:hover {
    border-color: var(--ms-accent);
}

.btn-primary,
a.btn-primary {
    background: var(--ms-accent-strong);
    color: var(--ms-accent-fg);
    border-color: transparent;
}

.btn-primary:hover {
    filter: brightness(1.15);
}

.btn-secondary,
a.btn-secondary {
    background: var(--scheme-secondary);
    color: var(--scheme-on-secondary);
    border-color: transparent;
}

/* WP1a R7: the role showcase on the home page. */
.pill-accent-1 {
    color: var(--scheme-accent-1);
    border-color: var(--scheme-accent-1);
}

.card-accent-2 {
    border-top: 3px solid var(--scheme-accent-2);
}

.ms-banner-warning {
    background: var(--mastech-message-banner-warning-background);
    border-color: var(--scheme-warning);
    border-left-width: 4px;
}

.ms-banner-failure {
    background: var(--mastech-message-banner-danger-background);
    border-color: var(--scheme-failure);
    border-left-width: 4px;
}

.ms-banner .ms-banner-icon {
    display: inline-block;
    width: 1.3em;
    text-align: center;
    font-weight: 700;
}

.ms-banner-warning .ms-banner-icon {
    color: var(--scheme-warning);
}

.ms-banner-failure .ms-banner-icon {
    color: var(--scheme-failure);
}

.btn-row {
    display: flex;
    flex-wrap: wrap;
    gap: 0.7rem;
    margin: 1.4rem 0;
}

.pill {
    display: inline-block;
    border: 1px solid var(--ms-border);
    border-radius: 999px;
    padding: 0.15rem 0.7rem;
    font-size: 0.78rem;
    color: var(--ms-muted);
    background: var(--ms-surface);
}

.lede {
    font-size: 1.1rem;
    line-height: 1.6;
    color: var(--ms-muted);
    max-width: 44rem;
}

/* ---- Home ---------------------------------------------------------------------------------------------------------- */

.hero {
    padding: 2rem 0 1.6rem;
    border-bottom: 1px solid var(--ms-border);
    margin-bottom: 1.6rem;
}

.hero h1 {
    font-size: clamp(1.9rem, 4vw, 2.9rem);
    line-height: 1.15;
    margin: 0.6rem 0 0.8rem;
    letter-spacing: -0.02em;
}

.hero .lede {
    margin: 0;
}

.hero-split {
    display: grid;
    grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr);
    gap: 2rem;
    align-items: start;
}

@media (max-width: 900px) {
    .hero-split {
        grid-template-columns: 1fr;
    }
}

.hero-sample pre {
    margin: 0;
}

.hero-response {
    margin-top: 0.8rem !important;
}

.terminal {
    background: var(--ms-code-bg);
    border: 1px solid var(--ms-border);
    border-radius: 0.6rem;
    box-shadow: var(--ms-shadow);
    overflow: hidden;
}

.terminal-bar {
    display: flex;
    gap: 0.4rem;
    padding: 0.5rem 0.8rem;
    background: rgba(255, 255, 255, 0.05);
    border-bottom: 1px solid var(--ms-border);
}

.terminal-bar span {
    width: 0.7rem;
    height: 0.7rem;
    border-radius: 50%;
    background: #ff5f57;
}

.terminal-bar span:nth-child(2) { background: #febc2e; }
.terminal-bar span:nth-child(3) { background: #28c840; }

.terminal pre {
    background: transparent;
    border: 0;
    margin: 0;
}

.overview-figure {
    margin: 0 0 1.8rem;
    padding: 0.6rem;
    background: var(--scheme-surface);
    border: 1px solid var(--ms-border);
    border-radius: 0.8rem;
}

.overview-figure img,
.overview-figure svg {
    display: block;
    width: 100%;
    max-width: 62rem;
    height: auto;
    margin: 0 auto;
}

.site-footer {
    margin-top: 3rem;
    padding: 1.2rem 0 2rem;
    border-top: 1px solid var(--ms-border);
    color: var(--ms-muted);
    font-size: 0.86rem;
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem 1.2rem;
    align-items: center;
}

.site-footer a {
    color: var(--ms-muted);
}

/* ---- Docs ---------------------------------------------------------------------------------------------------------- */

.docs-shell {
    display: grid;
    grid-template-columns: 15rem minmax(0, 1fr) 14rem;
    gap: 2rem;
    align-items: start;
    padding-top: 1rem;
}

@media (max-width: 1100px) {
    .docs-shell {
        grid-template-columns: 14rem minmax(0, 1fr);
    }

    .docs-toc {
        display: none;
    }
}

@media (max-width: 780px) {
    .docs-shell {
        grid-template-columns: 1fr;
    }
}

.docs-nav,
.docs-toc {
    position: sticky;
    top: 1rem;
    font-size: 0.9rem;
}

.docs-nav ol,
.docs-toc ul {
    list-style: none;
    margin: 0.5rem 0 0;
    padding: 0;
}

.docs-nav a,
.docs-toc a {
    display: block;
    padding: 0.32rem 0.6rem;
    border-left: 2px solid transparent;
    text-decoration: none;
    color: var(--ms-muted);
    line-height: 1.35;
}

.docs-nav a:hover,
.docs-toc a:hover {
    color: var(--ms-fg);
    border-left-color: var(--ms-border-strong);
}

.docs-nav a.current {
    color: var(--ms-fg);
    border-left-color: var(--ms-accent);
    font-weight: 600;
}

.docs-nav-heading,
.docs-toc-heading {
    text-transform: uppercase;
    letter-spacing: 0.09em;
    font-size: 0.72rem;
    color: var(--ms-muted);
    font-weight: 700;
    margin: 1.2rem 0 0 0.6rem;
}

.docs-nav-heading:first-child {
    margin-top: 0;
}

.docs-breadcrumb {
    font-size: 0.85rem;
    color: var(--ms-muted);
    margin-bottom: 0.4rem;
}

.docs-breadcrumb a {
    color: var(--ms-muted);
}

.docs-pager {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    margin-top: 2.5rem;
    padding-top: 1.2rem;
    border-top: 1px solid var(--ms-border);
}

.docs-pager-next {
    text-align: right;
}

.docs-pager a {
    text-decoration: none;
    font-weight: 600;
}

.docs-pager span {
    display: block;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--ms-muted);
    font-weight: 400;
}

.docs-article {
    max-width: 48rem;
    line-height: 1.68;
}

.docs-article h1 {
    font-size: 2.1rem;
    letter-spacing: -0.02em;
    margin: 0 0 1.2rem;
}

.docs-article h2 {
    font-size: 1.4rem;
    margin: 2.4rem 0 0.8rem;
    padding-top: 0.6rem;
    border-top: 1px solid var(--ms-border);
}

.docs-article h3 {
    font-size: 1.1rem;
    margin: 1.8rem 0 0.6rem;
}

.docs-article p,
.docs-article ul,
.docs-article ol {
    margin: 0 0 1rem;
}

.docs-article ul,
.docs-article ol {
    padding-left: 1.4rem;
}

.docs-article blockquote {
    margin: 1.2rem 0;
    padding: 0.85rem 1.1rem;
    border-left: 3px solid var(--ms-accent);
    background: var(--ms-surface);
    border-radius: 0 0.5rem 0.5rem 0;
}

.docs-article table {
    width: 100%;
    border-collapse: collapse;
    margin: 1.2rem 0;
    font-size: 0.93rem;
    display: block;
    overflow-x: auto;
}

.docs-article th,
.docs-article td {
    border: 1px solid var(--ms-border);
    padding: 0.5rem 0.7rem;
    text-align: left;
    vertical-align: top;
}

.docs-article th {
    background: var(--ms-surface);
    font-weight: 600;
}

/* ---- Code (monospace, no highlighting: D-WP1-11) ------------------------------------------------------------------- */

code,
kbd,
pre {
    font-family: ui-monospace, "Cascadia Code", "SFMono-Regular", Consolas, "Liberation Mono", monospace;
}

pre {
    background: var(--ms-code-bg);
    border: 1px solid var(--ms-border);
    border-radius: 0.6rem;
    padding: 0.95rem 1.05rem;
    overflow-x: auto;
    font-size: 0.86rem;
    line-height: 1.55;
}

:not(pre) > code {
    background: var(--ms-surface);
    border: 1px solid var(--ms-border);
    border-radius: 0.35rem;
    padding: 0.08em 0.36em;
    font-size: 0.88em;
}

/* ---- Contact Mastech ----------------------------------------------------------------------------------------------- */

.ms-contact {
    max-width: 36rem;
    padding: 1rem 0;
}

.ms-contact-form {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.ms-field {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
}

.ms-field input,
.ms-field textarea {
    font: inherit;
    padding: 0.5rem 0.7rem;
    border-radius: 0.4rem;
    border: 1px solid var(--ms-border-strong);
    background: var(--ms-code-bg);
    color: var(--ms-fg);
}

.ms-field .validation-message {
    color: #ff9d9d;
    font-size: 0.88rem;
}

.ms-contact-form .btn {
    align-self: flex-start;
}

.ms-contact-thanks {
    font-size: 1.1rem;
}

/* ---- Application shell (.Client/Layout/MainLayout) ----------------------------------------------------------------- */

.ms-app {
    display: grid;
    grid-template-columns: 14rem minmax(0, 1fr);
    grid-template-rows: auto auto auto 1fr;
    grid-template-areas:
        "top top"
        "toolbar toolbar"
        "banners banners"
        "menu body";
    min-height: 100vh;
}

.ms-app-top {
    grid-area: top;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.75rem 1.5rem;
    padding: 0.6rem 1rem;
    background: var(--mastech-surface-sunken, #0d141c);
    border-bottom: 1px solid var(--ms-border);
}

.ms-app--global .ms-app-top {
    border-bottom: 3px solid var(--mastech-account-menu-global-background, #7a3fb0);
}

.ms-app-top .ms-brand {
    margin-right: auto;
}

/* "2026-11-20 Magic Scales burger menu" (R1, R3, R7, R10): the burger toggle before the brand, styled like the account
   toggle with its focus ring; hidden on wide windows, shown by the 780px block below. The scrim is shown only there too,
   so a wide window looks as before whatever the open state. */
.ms-menu-toggle {
    display: none;
    align-items: center;
    padding: 0.3rem;
    border: 1px solid var(--ms-border);
    border-radius: 0.4rem;
    background: transparent;
    color: var(--scheme-text);
    font: inherit;
    cursor: pointer;
}

.ms-menu-toggle:hover {
    background: var(--ms-surface);
}

.ms-menu-toggle:focus-visible {
    outline: 2px solid var(--scheme-primary);
    outline-offset: 2px;
}

.ms-menu-backdrop {
    display: none;
}

/* The host's Toolbar slot under the top bar (2026-11-18 Magic Scales scale displays, R1); only the app fills it. */
.ms-app-toolbar {
    grid-area: toolbar;
    min-width: 0;
}

/* "2026-11-18 Magic Scales account menu" (R1, R2, D10, D13, T2): the theme toggle and the account dropdown at the right
   of the top bar. The panel is a disclosure below the toggle; the transparent backdrop covers the page and the menu,
   below the panel, so a click outside only closes it. Long tenant lists scroll inside the panel (D6). Colours from the
   scheme and --mastech-* variables only. */
.ms-app-account {
    position: relative;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.ms-account-toggle {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.3rem 0.6rem;
    border: 1px solid var(--ms-border);
    border-radius: 0.4rem;
    background: transparent;
    color: var(--scheme-text);
    font: inherit;
    cursor: pointer;
}

.ms-account-toggle:hover {
    background: var(--ms-surface);
}

.ms-account-toggle:focus-visible {
    outline: 2px solid var(--scheme-primary);
    outline-offset: 2px;
}

.ms-account-toggle-label {
    max-width: 28rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.ms-account-backdrop {
    position: fixed;
    inset: 0;
    z-index: 900;
    background: transparent;
}

.ms-account-panel {
    position: absolute;
    top: calc(100% + 0.4rem);
    right: 0;
    z-index: 901;
    display: flex;
    flex-direction: column;
    min-width: 16rem;
    max-width: 24rem;
    max-height: calc(100vh - 5rem);
    padding: 0.5rem 0;
    border: 1px solid var(--ms-border);
    border-radius: 0.5rem;
    background: var(--scheme-surface);
    color: var(--scheme-text);
    box-shadow: 0 0.5rem 1.5rem color-mix(in srgb, var(--scheme-text) 25%, transparent);
}

.ms-account-user {
    margin: 0;
    padding: 0.4rem 1rem 0.6rem;
    color: var(--ms-muted);
    font-size: 0.9rem;
    overflow-wrap: anywhere;
}

.ms-account-divider {
    width: 100%;
    margin: 0.4rem 0;
    border: 0;
    border-top: 1px solid var(--ms-border);
}

.ms-account-panel .tenant-menu-entries {
    display: flex;
    flex-direction: column;
    min-height: 0;
    flex: 0 1 auto;
    max-height: min(18rem, calc(100vh - 16rem));
    overflow-y: auto;
}

.ms-account-item,
.ms-account-panel .tenant-menu-entry,
.ms-account-panel .identity-sign-out {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    box-sizing: border-box;
    width: 100%;
    padding: 0.45rem 1rem;
    border: 0;
    background: transparent;
    color: var(--scheme-text);
    font: inherit;
    text-align: left;
    text-decoration: none;
    cursor: pointer;
}

.ms-account-item:hover,
.ms-account-panel .tenant-menu-entry:hover:not(:disabled),
.ms-account-panel .identity-sign-out:hover {
    background: var(--ms-surface);
}

.ms-account-item:focus-visible,
.ms-account-panel .tenant-menu-entry:focus-visible,
.ms-account-panel .identity-sign-out:focus-visible {
    outline: 2px solid var(--scheme-primary);
    outline-offset: -2px;
}

.ms-account-item[aria-current="true"],
.ms-account-panel .tenant-menu-entry[aria-current="true"] {
    font-weight: 600;
}

.ms-account-item--global {
    color: var(--mastech-account-menu-global-background);
}

.ms-account-panel .tenant-menu-entry:disabled {
    cursor: default;
    opacity: 0.6;
}

.ms-account-panel .tenant-menu-entry-on-hold {
    margin-left: auto;
    font-size: 0.8rem;
    color: var(--ms-muted);
}

.ms-account-panel .tenant-menu-message {
    margin: 0.4rem 1rem;
    color: var(--mastech-tone-danger-solid, var(--scheme-text));
    font-size: 0.9rem;
}

.ms-app-banners {
    grid-area: banners;
}

.ms-app-menu {
    grid-area: menu;
    padding: 1rem 0.5rem;
    border-right: 1px solid var(--ms-border);
}

.ms-app-menu ul {
    list-style: none;
    margin: 0;
    padding: 0;
}

.ms-app-menu a {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.45rem 0.75rem;
    border-radius: 0.4rem;
    color: var(--ms-muted);
    text-decoration: none;
}

.ms-app-menu a:hover {
    color: var(--ms-fg);
    background: var(--ms-surface);
}

.ms-app-menu a.active {
    color: var(--ms-fg);
    background: var(--ms-surface);
    font-weight: 600;
}

.ms-app-menu .rzi {
    font-size: 1.2rem;
}

.ms-app-menu-heading {
    margin: 0 0 0.5rem 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.09em;
    font-size: 0.72rem;
    color: var(--ms-global-fg);
    font-weight: 700;
}

.ms-app-body {
    grid-area: body;
    padding: 1.25rem 1.5rem;
    min-width: 0;
}

.ms-placeholder {
    max-width: 40rem;
    padding: 1rem 1.2rem;
    border: 1px dashed var(--ms-border-strong);
    border-radius: 0.6rem;
    color: var(--ms-muted);
}

.ms-about dt {
    color: var(--ms-muted);
    font-size: 0.85rem;
}

.ms-about dd {
    margin: 0 0 0.75rem;
}

@media (max-width: 780px) {
    .ms-app {
        grid-template-columns: 1fr;
        grid-template-areas:
            "top"
            "toolbar"
            "banners"
            "menu"
            "body";
    }

    .ms-app-menu {
        display: none;
        border-right: 0;
        border-bottom: 1px solid var(--ms-border);
    }

    /* "2026-11-20 Magic Scales burger menu" (R1, R2, DD8): narrow, the burger shows and the menu is a panel it opens.
       The page takes the menu's row too, so it sits under the banners whether the panel is open or not (the rows stay
       S4's). Open, the root is the panel's containing block and one window high, so the panel and the scrim, placed
       over the rows under the top bar, start at the top bar's bottom edge and end within the window; the panel scrolls
       inside when taller, and the top bar stays above the scrim, so the toggle closes the panel again. */
    .ms-menu-toggle {
        display: inline-flex;
    }

    .ms-app-body {
        grid-row: menu-start / body-end;
    }

    /* Open, the shell's parent is one window high and lays out what it holds as a column: the web's deployment
       TopBanner above the shell keeps its own height and the shell takes what is left, so the panel ends within the
       window with or without that banner (the rows stay S4's). */
    *:has(> .ms-app--menu-open) {
        display: flex;
        flex-direction: column;
        height: 100dvh;
        overflow: clip;
    }

    .ms-app--menu-open {
        position: relative;
        flex: 1 1 auto;
        min-height: 0;
        overflow: clip;
    }

    .ms-app--menu-open .ms-app-menu {
        display: block;
        position: absolute;
        grid-row: 2 / -1;
        grid-column: 1 / -1;
        top: 0;
        right: 0;
        left: 0;
        z-index: 851;
        box-sizing: border-box;
        max-height: 100%;
        overflow-y: auto;
        background: var(--scheme-surface);
        box-shadow: var(--ms-shadow);
    }

    .ms-menu-backdrop {
        display: block;
        position: absolute;
        grid-row: 2 / -1;
        grid-column: 1 / -1;
        inset: 0;
        z-index: 850;
        background: color-mix(in srgb, var(--ms-scrim) 60%, transparent);
    }
}

/* ---- Plain buttons (Polish round 2 R22) ----------------------------------------------------------------------------
   The Mt* component rules (.mt-page, .mt-form-card, .mt-form-actions, the display components) are UiComponents'
   css/mt-components.css since part G (R18, AC-19); this sheet keeps the host's own rules and the placements of those
   components inside host markup. */

/* R22: plain buttons in the app layout ("Sign out", "Revoke", Rename, Select, ...) take the primary hue, slightly
   greyer (mixed with the text role, which keeps on-primary readable in Dark and Light). Part G Q-G3: the rule skips
   .mt-form-actions > button, so part H's action-row rules in mt-components.css win although that sheet loads first;
   :where() keeps the specificity at (0,1,1). Needs Chromium 88+ (WebView2, Android System WebView). */
:where(.ms-app) button:where(:not(.mt-form-actions > button)):not([class]) {
    padding: 0.375rem 1rem;
    border: 1px solid color-mix(in srgb, var(--scheme-primary) 75%, var(--scheme-text));
    border-radius: 4px;
    background: color-mix(in srgb, var(--scheme-primary) 75%, var(--scheme-text));
    color: var(--scheme-on-primary);
    font: inherit;
    cursor: pointer;
}

:where(.ms-app) button:not([class]):disabled {
    cursor: not-allowed;
    opacity: 0.55;
}

:where(.ms-app) button:not([class]):focus-visible {
    outline: 2px solid var(--scheme-primary);
    outline-offset: 2px;
}

/* R22: destructive plain buttons keep the same fill and show a failure-coloured border (specificity above the rule
   above, so the border always wins). */
.ms-app button[id^="revoke-"],
.ms-app button[id^="delete-"],
.ms-app #scale-detail-delete,
.ms-app button[id^="deactivate-"],
.ms-app #status-deleted,
.ms-app #status-onhold {
    border: 2px solid var(--scheme-failure);
}

/* ---- Dashboard widgets (2026-11-13 Magic Scales - WP9b R1-R4): the /home slots and the module widgets' tables and
   badges (plain table.mt-table and span.mt-badge from the module RCLs). Colours from the scheme variables only. */

.ms-dashboard {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(22rem, 100%), 1fr));
    gap: 1rem;
}

.ms-widget {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    padding: 1rem 1.25rem;
    border: 1px solid var(--mastech-border);
    border-radius: 0.75rem;
    background: var(--mastech-surface-raised);
    color: var(--mastech-text);
    min-width: 0;
    overflow-x: auto;
    position: relative;
}

.ms-widget > h2 {
    margin: 0;
}

/* Polish round 2 R25 (D18): small Refresh buttons, placed top right of their card by CSS only, so the DOM, reading and
   tab order stay as they are. The Weighing card's second toolbar stays in flow, right-aligned. */
.ms-app .mt-form-actions > button[id$="-refresh"],
.ms-app .mt-form-actions > #refresh-workstations {
    padding: 0.25rem 0.75rem;
    font-size: 0.8125rem;
}

.ms-widget .plan-summary-toolbar,
.ms-widget .workstations-summary-toolbar,
.ms-widget .scale-status-summary-toolbar {
    position: absolute;
    top: 1rem;
    right: 1.25rem;
}

.ms-widget .mt-card-header {
    padding-right: 6rem;
}

.ms-widget .recent-requests-summary-toolbar {
    justify-content: flex-end;
}

.scales-page-notice-card {
    position: relative;
}

.scales-page-notice-card .mt-form-actions {
    position: absolute;
    top: 1rem;
    right: 1.25rem;
}

.scales-page-notice-card #scales-page-notice {
    padding-right: 6rem;
}

@media (max-width: 30rem) {
    .ms-widget .plan-summary-toolbar,
    .ms-widget .workstations-summary-toolbar,
    .ms-widget .scale-status-summary-toolbar,
    .scales-page-notice-card .mt-form-actions {
        position: static;
    }

    .ms-widget .mt-card-header,
    .scales-page-notice-card #scales-page-notice {
        padding-right: 0;
    }

    /* "2026-11-20 Magic Scales burger menu" (R8, DD6, DD11): at phone width the account toggle shows only its icons; the
       label is visually hidden (clipped, not display: none), so it stays the button's accessible name. */
    .ms-account-toggle-label {
        position: absolute;
        width: 1px;
        height: 1px;
        overflow: hidden;
        clip-path: inset(50%);
        white-space: nowrap;
    }
}

/* Polish round 2 R24: Identity's CurrentUserSummary (dl.home-summary) as a small labelled panel. */
.home-summary {
    display: grid;
    grid-template-columns: max-content 1fr;
    gap: 0.25rem 1rem;
    margin: 0 0 1rem;
    padding: 0.75rem 1rem;
    border: 1px solid var(--mastech-border);
    border-radius: 0.75rem;
    background: var(--mastech-surface-raised);
}

.home-summary dt {
    color: var(--mastech-text-muted);
    font-size: 0.875rem;
}

.home-summary dd {
    margin: 0;
    font-weight: 600;
}

/* The widgets' table.mt-table and span.mt-badge are styled with the display components below. */

/* UI polish and themes R8a: the colour-scheme switcher (Development and Preview) in the top bar, role variables only. */
.ms-scheme-switcher .uikit-scheme-switcher {
    color: var(--ms-fg);
}

.ms-scheme-switcher .uikit-scheme-switcher-step,
.ms-scheme-switcher .uikit-scheme-switcher-review {
    color: var(--ms-accent);
}

.ms-scheme-switcher .uikit-scheme-switcher-select {
    color: var(--ms-fg);
    background: var(--ms-surface);
    border: 1px solid var(--ms-border);
    border-radius: 0.3rem;
}

/* The interactive pages draw their top bar (and the Preview deployment banner above it) on the client, so the switcher
   floats at the bottom centre there, clear of the banner, the brand and the account menu. */
.ms-scheme-switcher--over-top-bar {
    position: fixed;
    bottom: 0.75rem;
    left: 50%;
    transform: translateX(-50%);
    z-index: 10;
    padding: 0.25rem 0.5rem;
    border: 1px solid var(--ms-border);
    border-radius: 0.5rem;
    background: var(--ms-surface);
}

/* ---- Host extras for the display components ---------------------------------------------------------------------
   The display components' own rules are UiComponents' css/mt-components.css (part G). Polish round 2 R26: the Tokens
   copy button renders Radzen's <i class="rzi">; the copy icon keeps the button's text size. */
.token-copy-icon {
    font-size: inherit;
}

.plan-card-features {
    list-style: none;
    margin: 0;
    padding: 0;
}

.plan-card-features > li::before {
    content: "\2713\00a0";
    color: var(--mastech-tone-success-solid);
}

/* The Light/Dark toggle in the account menu (UI polish and themes R16, D12): one pill, like the other account-menu
   entries, holding two segments. The chosen segment (aria-pressed="true") is filled with the primary role, and the
   other segment stays on the surface. Only scheme roles are used, so the toggle reads correctly in Light and Dark. */
.ms-theme-toggle {
    display: inline-flex;
    padding: 0;
    overflow: hidden;
    border: 1px solid var(--scheme-primary);
}

.ms-theme-toggle-option {
    padding: 0.15rem 0.6rem;
    border: 0;
    background: transparent;
    color: var(--scheme-text);
    font: inherit;
    font-size: 0.85rem;
    cursor: pointer;
}

.ms-theme-toggle-option + .ms-theme-toggle-option {
    border-left: 1px solid var(--scheme-primary);
}

.ms-theme-toggle-option:hover {
    text-decoration: underline;
}

.ms-theme-toggle-option[aria-pressed="true"] {
    background: var(--scheme-primary);
    color: var(--scheme-on-primary);
    font-weight: 600;
}

.ms-theme-toggle-option:focus-visible {
    outline: 2px solid var(--scheme-primary);
    outline-offset: -4px;
}

.ms-theme-toggle-option[aria-pressed="true"]:focus-visible {
    outline-color: var(--scheme-on-primary);
}

/* ---- App host (2026-11-15 Magic Scales – App styling and shared shell, S4, S4-Q3 (a)) ------------------------------
   What the workstation app adds to the shared shell: the footer row of the shell grid, DeviceApp's status footer with
   the uplink button, and the two MAUI template rules (P1.3). The footer row is scoped to .ms-app--with-footer, which
   MagicScalesLayout sets only when its Footer slot is filled, so the web's grid (.ms-app above) is unchanged. Colours
   come only from var(--...). */

/* The shared shell's grid gains a footer row when the host fills MagicScalesLayout's Footer slot. */
.ms-app--with-footer {
    grid-template-rows: auto auto auto 1fr auto;
    grid-template-areas:
        "top top"
        "toolbar toolbar"
        "banners banners"
        "menu body"
        "footer footer";
}

.device-status-footer {
    grid-area: footer;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.75rem;
    padding: 0.4rem 1rem;
    border-top: 1px solid var(--ms-border);
    background: var(--mastech-surface-sunken);
    color: var(--ms-muted);
    font-size: 0.85rem;
}

.device-status-footer-app {
    margin-right: auto;
}

.uplink-status {
    border: 1px solid var(--ms-border);
    border-radius: 0.4rem;
    padding: 0.15rem 0.6rem;
    background: transparent;
    color: var(--ms-fg);
    font: inherit;
    cursor: pointer;
}

.uplink-status--offline {
    color: var(--rz-danger);
    border-color: var(--rz-danger);
}

/* Relay status and diagnostics D2: connected green, connecting/reconnecting amber, stopped grey, refused/unauthorized red. */
.uplink-status--connected {
    color: var(--rz-success);
    border-color: var(--rz-success);
}

.uplink-status--connecting,
.uplink-status--reconnecting {
    color: var(--rz-warning);
    border-color: var(--rz-warning);
}

.uplink-status--refused,
.uplink-status--unauthorized {
    color: var(--rz-danger);
    border-color: var(--rz-danger);
}

.uplink-status--stopped {
    color: var(--ms-muted);
    border-color: var(--ms-border);
}

/* Reconnect (superseded) and Sign in (unauthorized) next to the status. */
.uplink-status-action {
    border: 1px solid var(--ms-border);
    border-radius: 0.4rem;
    padding: 0.15rem 0.6rem;
    background: transparent;
    color: var(--ms-fg);
    font: inherit;
    cursor: pointer;
}

/* The open ping list with the "Connection details" link. */
.uplink-status-panel {
    flex-basis: 100%;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.uplink-status-details {
    color: var(--ms-fg);
}

/* Kept from the MAUI template app.css (P1.3). */
.status-bar-safe-area {
    display: flex;
    position: sticky;
    top: 0;
    height: env(safe-area-inset-top, 0px);
    background-color: var(--mastech-surface-sunken);
    width: 100%;
    z-index: 1;
}

#blazor-error-ui {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    z-index: 1000;
    box-sizing: border-box;
    padding: 0.6rem 1.25rem 0.7rem 1.25rem;
    background: var(--rz-warning);
    color: var(--rz-on-primary);
}

#blazor-error-ui .dismiss {
    cursor: pointer;
    position: absolute;
    right: 0.75rem;
    top: 0.5rem;
}

@media (max-width: 780px) {
    .ms-app--with-footer {
        grid-template-rows: auto auto auto auto 1fr auto;
        grid-template-areas:
            "top"
            "toolbar"
            "banners"
            "menu"
            "body"
            "footer";
    }
}
