/**
 * My Rtishchevo design system.
 * Final compatibility layer for theme and portal modules.
 */
:root {
    --mrt-container: 1180px;
    --mrt-reading-width: 760px;
    --mrt-color-primary: #075c46;
    --mrt-color-primary-hover: #044c3a;
    --mrt-color-accent: #ffb329;
    --mrt-color-accent-hover: #f4a719;
    --mrt-color-text: #172522;
    --mrt-color-muted: #61716d;
    --mrt-color-canvas: #f6f8f5;
    --mrt-color-surface: #fff;
    --mrt-color-border: #dbe6e1;
    --mrt-color-success: #08785d;
    --mrt-color-success-soft: #e8f5f0;
    --mrt-color-warning: #9a5b00;
    --mrt-color-warning-soft: #fff5df;
    --mrt-color-danger: #b53a32;
    --mrt-color-danger-soft: #fff0ee;
    --mrt-color-info: #285f9e;
    --mrt-color-info-soft: #edf5ff;
    --mrt-space-1: 4px;
    --mrt-space-2: 8px;
    --mrt-space-3: 12px;
    --mrt-space-4: 16px;
    --mrt-space-5: 20px;
    --mrt-space-6: 24px;
    --mrt-space-8: 32px;
    --mrt-space-10: 40px;
    --mrt-radius-sm: 10px;
    --mrt-radius-md: 14px;
    --mrt-radius-lg: 20px;
    --mrt-radius-xl: 28px;
    --mrt-shadow-sm: 0 6px 18px rgba(7, 74, 56, .06);
    --mrt-shadow-md: 0 14px 38px rgba(7, 74, 56, .10);
    --mrt-focus-ring: 0 0 0 3px rgba(255, 179, 41, .42);
    --mrt-control-height: 48px;

    /* Backward-compatible names used by existing modules. */
    --mrt-primary: var(--mrt-color-primary);
    --mrt-primary-dark: var(--mrt-color-primary-hover);
    --mrt-accent: var(--mrt-color-accent);
    --mrt-ink: var(--mrt-color-text);
    --mrt-muted: var(--mrt-color-muted);
    --mrt-bg: var(--mrt-color-canvas);
    --mrt-surface: var(--mrt-color-surface);
    --mrt-border: var(--mrt-color-border);
    --mrt-radius: var(--mrt-radius-lg);
    --mrt-shadow: var(--mrt-shadow-md);
}

/* Problem details use the whole card width and keep provenance readable. */
.mrt-detail-problem .mrt-detail-layout {
    grid-template-columns: minmax(0, 1fr);
}

.mrt-detail-problem :where(.mrt-detail-content, .entry-content, .mrt-problem-details) {
    width: 100%;
    max-width: none;
}

.mrt-detail-problem .mrt-problem-details {
    gap: 22px;
}

.mrt-detail-problem .mrt-problem-source-proof {
    display: grid;
    gap: 14px;
    margin: 4px 0 8px;
    padding: 20px;
    border: 1px solid #cfe2da;
    border-radius: 18px;
    background: linear-gradient(135deg, #edf7f3 0%, #fbf8eb 100%);
    color: var(--mrt-ink, #142822);
}

.mrt-problem-source-proof > header {
    display: grid;
    grid-template-columns: 44px minmax(0, 1fr) auto;
    align-items: center;
    gap: 13px;
}

.mrt-problem-source-proof__icon {
    display: grid;
    place-items: center;
    width: 44px;
    height: 44px;
    border-radius: 13px;
    background: #08765d;
    color: #fff;
    font-size: 20px;
    font-weight: 900;
}

.mrt-problem-source-proof header strong {
    display: block;
    font-size: 17px;
}

.mrt-problem-source-proof header p {
    max-width: 72ch;
    margin: 4px 0 0;
    color: #587269;
    font-size: 13px;
    line-height: 1.5;
}

.mrt-problem-source-proof header em {
    padding: 7px 10px;
    border-radius: 999px;
    background: #dcefe7;
    color: #09654f;
    font-size: 12px;
    font-style: normal;
    font-weight: 850;
    white-space: nowrap;
}

.mrt-problem-source-proof ul {
    display: grid;
    gap: 8px;
    margin: 0;
    padding: 0;
    list-style: none;
}

.mrt-problem-source-proof li {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 12px 14px;
    border: 1px solid rgba(145, 177, 165, .45);
    border-radius: 13px;
    background: rgba(255, 255, 255, .82);
}

.mrt-problem-source-proof li div {
    display: grid;
    gap: 2px;
}

.mrt-problem-source-proof li div span {
    color: #6a7d76;
    font-size: 11px;
    font-weight: 750;
    text-transform: uppercase;
    letter-spacing: .04em;
}

.mrt-problem-source-proof li a {
    flex: 0 0 auto;
    color: #08765d;
    font-size: 13px;
    font-weight: 850;
}

.mrt-problem-section-heading > span,
.mrt-comments-heading > span {
    color: #08765d;
    font-size: 12px;
    font-weight: 900;
    text-transform: uppercase;
    letter-spacing: .08em;
}

.mrt-problem-section-heading h2,
.mrt-comments-heading h2 {
    margin: 5px 0 0;
}

.mrt-detail-problem .mrt-problem-timeline {
    display: grid;
    gap: 10px;
    margin: 0;
    padding: 0;
    list-style: none;
}

.mrt-detail-problem .mrt-problem-timeline li {
    display: grid;
    grid-template-columns: 38px minmax(0, 1fr);
    gap: 12px;
    padding: 16px;
    border: 1px solid #dce8e3;
    border-radius: 15px;
    background: #f5f8f7;
}

.mrt-problem-timeline__marker {
    display: grid;
    place-items: center;
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: #08765d;
    color: #fff;
    font-weight: 900;
}

.mrt-problem-timeline li > div > header {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 14px;
}

.mrt-problem-timeline time {
    color: #687b74;
    font-size: 12px;
    white-space: nowrap;
}

.mrt-detail-problem .mrt-problem-comments {
    width: 100%;
    max-width: none;
    margin: 20px 0 50px;
    padding: clamp(22px, 3vw, 34px);
    border-radius: 22px;
}

.mrt-comments-heading {
    margin-bottom: 24px;
    padding-bottom: 20px;
    border-bottom: 1px solid #dce7e2;
}

.mrt-comments-heading p {
    margin: 8px 0 0;
    color: #5d716a;
}

.mrt-problem-comments .comment-respond {
    margin-top: 24px;
    padding: 22px;
    border-radius: 17px;
    background: #f5f8f7;
}

.mrt-problem-comments .comment-reply-title {
    margin: 0 0 8px;
    font-size: clamp(22px, 2.4vw, 29px);
}

.mrt-problem-comments :where(.logged-in-as, .comment-notes) {
    margin: 5px 0;
    color: #60736c;
    font-size: 13px;
}

.mrt-problem-comments .form-submit {
    margin: 2px 0 0;
}

/* Simple archives have one search field and one aligned action. */
.mrt-archive-tools.is-simple {
    width: 100%;
    grid-template-columns: minmax(0, 1fr) minmax(144px, 180px);
    align-items: end;
}

.mrt-archive-tools.is-simple .mrt-archive-search-field {
    width: 100%;
}

.mrt-archive-tools.is-simple > .mrt-button {
    width: 100% !important;
    max-width: none;
    min-height: 48px;
    justify-self: stretch;
}

@media (max-width: 620px) {
    .mrt-problem-source-proof > header {
        grid-template-columns: 40px minmax(0, 1fr);
    }

    .mrt-problem-source-proof header em {
        grid-column: 1 / -1;
        justify-self: start;
        white-space: normal;
    }

    .mrt-problem-source-proof li,
    .mrt-problem-timeline li > div > header {
        align-items: flex-start;
        flex-direction: column;
    }

    .mrt-detail-problem .mrt-problem-comments {
        margin-inline: 0;
        padding: 18px;
    }

    .mrt-problem-comments .comment-respond {
        padding: 16px;
    }

    .mrt-archive-tools.is-simple {
        grid-template-columns: minmax(0, 1fr);
    }
}

/* Stage 2: homepage and public catalog presentation layer. */
.home-section {
    padding-block: clamp(30px, 4vw, 52px);
}

.home-section .section-heading,
.mrt-archive-heading {
    align-items: end;
    margin-bottom: clamp(18px, 2.4vw, 28px);
}

.home-section .section-heading h2,
.mrt-archive-heading h1 {
    max-width: 820px;
    text-wrap: balance;
}

.home-section .section-heading p,
.mrt-archive-heading p {
    max-width: 720px;
    line-height: 1.6;
}

.all-link {
    display: inline-flex;
    min-height: 40px;
    align-items: center;
    gap: 8px;
    justify-content: center;
    padding: 8px 12px;
    border-radius: 12px;
}

.all-link:hover,
.all-link:focus-visible {
    background: var(--mrt-soft, #edf6f2);
    outline: 0;
}

/* Twelve services are deliberately presented as two balanced rows. */
.services-reference .reference-grid {
    align-items: stretch;
    grid-template-columns: repeat(6, minmax(0, 1fr));
}

.services-reference .service-card {
    display: grid;
    min-height: 210px;
    grid-template-rows: auto auto minmax(38px, auto) 1fr;
    align-content: start;
    justify-items: center;
    padding: 22px 14px 17px;
}

.services-reference .service-card h3 {
    min-height: 2.55em;
    display: grid;
    align-items: center;
    margin-block: 12px 5px;
    text-wrap: balance;
}

.services-reference .service-card p {
    display: -webkit-box;
    min-height: 2.9em;
    overflow: hidden;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
}

.services-reference .service-card em {
    align-self: end;
}

/* Popular places never leave an accidental-looking empty row. */
.places-grid {
    align-items: stretch;
}

.place-card {
    min-width: 0;
    overflow: hidden;
    border: 1px solid var(--mrt-border, #d8e3de);
    border-radius: 20px;
    background: #fff;
    box-shadow: 0 10px 28px rgba(14, 66, 53, .065);
}

.place-card > a {
    display: grid;
    height: 100%;
    grid-template-rows: auto minmax(0, 1fr);
    color: inherit;
}

.place-card .place-media {
    aspect-ratio: 16 / 10;
    background: linear-gradient(135deg, #e7f1ed, #fff3d8);
}

.place-card .place-media img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.place-card .place-copy {
    display: grid;
    align-content: start;
    padding: 16px;
}

.place-card .place-copy h3 {
    display: -webkit-box;
    overflow: hidden;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    text-wrap: balance;
}

.place-card .place-copy p {
    display: -webkit-box;
    overflow: hidden;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 3;
}

.places-grid.is-count-2,
.places-grid.is-count-3,
.places-grid.is-count-4 {
    grid-template-columns: repeat(var(--mrt-place-count, 2), minmax(0, 1fr));
}

.places-grid.is-count-2 { --mrt-place-count: 2; }
.places-grid.is-count-3 { --mrt-place-count: 3; }
.places-grid.is-count-4 { --mrt-place-count: 4; }

/* Public archive controls form one compact, understandable toolbar. */
.mrt-archive-heading {
    padding-top: clamp(26px, 4vw, 48px);
}

.mrt-archive-tool-row {
    align-items: end;
    padding: 18px;
    border: 1px solid var(--mrt-border, #d8e3de);
    border-radius: 20px;
    background: rgba(255, 255, 255, .86);
    box-shadow: 0 10px 30px rgba(14, 66, 53, .055);
}

.mrt-archive-tools {
    grid-template-columns: minmax(260px, 1fr) minmax(180px, .46fr) minmax(180px, .46fr) auto;
    align-items: end;
    gap: 12px;
}

.mrt-archive-tools label {
    display: grid;
    min-width: 0;
    gap: 7px;
    color: var(--mrt-ink, #142822);
    font-size: 13px;
    font-weight: 800;
}

.mrt-archive-tools input,
.mrt-archive-tools select {
    min-width: 0;
    min-height: 48px;
    margin: 0;
}

.mrt-archive-tools > .mrt-button {
    width: auto !important;
    min-width: 132px;
    max-width: none;
    min-height: 48px;
    justify-self: end;
    white-space: nowrap;
}

.mrt-filter-reset {
    grid-column: 1 / -1;
    justify-self: start;
}

.mrt-organization-results-summary {
    align-items: center;
    margin-block: 18px 24px;
}

.archive-grid {
    align-items: stretch;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 20px;
}

.archive-grid > :where(.content-card, .mrt-organization-card) {
    min-width: 0;
    height: 100%;
}

.content-card > a {
    grid-template-rows: auto minmax(0, 1fr);
}

.content-card .card-media {
    aspect-ratio: 16 / 10;
}

.content-card .card-body {
    min-height: 220px;
}

.content-card .card-body h3 {
    display: -webkit-box;
    overflow: hidden;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 3;
    text-wrap: balance;
}

.content-card .card-body > p {
    display: -webkit-box;
    overflow: hidden;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 4;
}

.content-card .mrt-card-freshness {
    margin-top: auto;
    padding-top: 14px;
}

.archive-grid > .mrt-empty,
.mrt-directory-empty {
    width: 100%;
    min-height: 260px;
    grid-column: 1 / -1;
    align-content: center;
    justify-items: center;
    padding: clamp(28px, 5vw, 56px);
    text-align: center;
}

.archive-grid > .mrt-empty p {
    max-width: 620px;
}

.mrt-home-event,
.mrt-home-movie {
    height: 100%;
    transition: transform .2s ease, box-shadow .2s ease, border-color .2s ease;
}

.mrt-home-event:hover,
.mrt-home-movie:hover {
    transform: translateY(-3px);
    border-color: #adcbbf;
    box-shadow: 0 18px 38px rgba(14, 66, 53, .11);
}

@media (max-width: 1050px) {
    .services-reference .reference-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }

    .mrt-archive-tools {
        grid-template-columns: minmax(240px, 1fr) minmax(170px, .5fr);
    }

    .mrt-archive-tools > .mrt-button {
        justify-self: stretch;
        width: 100% !important;
    }

    .archive-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 700px) {
    .home-section .section-heading,
    .mrt-archive-heading {
        display: grid;
        align-items: start;
        gap: 12px;
    }

    .home-section .section-heading .all-link {
        justify-self: start;
        padding-inline: 0;
    }

    .services-reference .reference-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 10px;
    }

    .services-reference .service-card {
        min-height: 178px;
        padding: 16px 10px 14px;
    }

    .services-reference .service-card h3 {
        min-height: auto;
        font-size: 14px;
    }

    .services-reference .service-card p {
        min-height: auto;
        font-size: 11px;
    }

    .places-grid,
    .places-grid.is-count-1,
    .places-grid.is-count-2,
    .places-grid.is-count-3,
    .places-grid.is-count-4 {
        display: grid;
        grid-template-columns: minmax(0, 1fr);
        overflow: visible;
    }

    .place-card,
    .places-grid.is-count-1 .place-card {
        width: 100%;
        flex: none;
    }

    .places-grid.is-count-1 .place-card > a {
        grid-template-columns: minmax(0, 1fr);
    }

    .places-grid.is-count-1 .place-media,
    .place-card .place-media {
        aspect-ratio: 16 / 9;
    }

    .mrt-archive-tool-row {
        padding: 14px;
    }

    .mrt-archive-tools {
        grid-template-columns: minmax(0, 1fr);
    }

    .mrt-archive-tools > .mrt-button {
        justify-self: stretch;
    }

    .archive-grid {
        grid-template-columns: minmax(0, 1fr);
        gap: 14px;
    }

    .content-card .card-body {
        min-height: 0;
    }

    .mrt-home-events,
    .mrt-home-movies {
        gap: 12px;
        padding-right: 4px;
        scroll-padding-left: 0;
        scrollbar-width: none;
    }

    .mrt-home-events::-webkit-scrollbar,
    .mrt-home-movies::-webkit-scrollbar {
        display: none;
    }
}

html {
    color-scheme: light;
    scroll-padding-top: 108px;
}

body {
    background: var(--mrt-color-canvas);
    color: var(--mrt-color-text);
    text-rendering: optimizeLegibility;
}

/* One predictable page width across the public portal and both cabinets. */
.mrt-container,
.entry-shell,
.portal-account-shell,
.mrt-detail-page,
.mrt-management-shell,
.mrt-portal-product-page .entry-shell,
.mrt-organization-landing-page .mrt-detail-page {
    width: min(calc(100% - 32px), var(--mrt-container));
    max-width: var(--mrt-container);
    margin-inline: auto;
}

.entry-content > p,
.entry-content > ul,
.entry-content > ol,
.entry-content > blockquote {
    max-width: var(--mrt-reading-width);
}

/* Controls: shared height, rhythm, focus and validation. */
.site-main :where(input:not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="file"]), select),
.portal-account-shell :where(input:not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="file"]), select) {
    min-height: var(--mrt-control-height);
    padding: 10px 14px;
    border: 1px solid var(--mrt-color-border);
    border-radius: var(--mrt-radius-md);
    background: var(--mrt-color-surface);
    color: var(--mrt-color-text);
}

.site-main textarea,
.portal-account-shell textarea {
    min-height: 112px;
    padding: 12px 14px;
    border: 1px solid var(--mrt-color-border);
    border-radius: var(--mrt-radius-md);
    background: var(--mrt-color-surface);
    color: var(--mrt-color-text);
    resize: vertical;
}

:where(a, button, input, select, textarea, summary, [tabindex]):focus-visible {
    outline: 2px solid var(--mrt-color-primary);
    outline-offset: 2px;
    box-shadow: var(--mrt-focus-ring);
}

:where(input, select, textarea)[aria-invalid="true"],
:where(input, select, textarea).is-invalid {
    border-color: var(--mrt-color-danger);
    background-color: var(--mrt-color-danger-soft);
}

/* Button hierarchy. */
:where(.mrt-button, .mrt-primary-button, .site-main button[type="submit"], .portal-account-shell button[type="submit"]) {
    display: inline-flex;
    min-height: 46px;
    align-items: center;
    justify-content: center;
    gap: var(--mrt-space-2);
    padding: 10px 20px;
    border: 1px solid transparent;
    border-radius: var(--mrt-radius-md);
    background: var(--mrt-color-accent);
    color: #302006;
    font-weight: 800;
    line-height: 1.2;
    text-align: center;
    cursor: pointer;
    transition: transform .18s ease, box-shadow .18s ease, background-color .18s ease;
}

:where(.mrt-button, .mrt-primary-button, .site-main button[type="submit"], .portal-account-shell button[type="submit"]):hover {
    background: var(--mrt-color-accent-hover);
    box-shadow: var(--mrt-shadow-sm);
    transform: translateY(-1px);
}

.mrt-secondary-button {
    display: inline-flex;
    min-height: 46px;
    align-items: center;
    justify-content: center;
    gap: var(--mrt-space-2);
    padding: 10px 18px;
    border: 1px solid #a9c8bd;
    border-radius: var(--mrt-radius-md);
    background: var(--mrt-color-surface);
    color: var(--mrt-color-primary);
    font-weight: 800;
}

.mrt-danger-button {
    display: inline-flex;
    min-height: 46px;
    align-items: center;
    justify-content: center;
    padding: 10px 18px;
    border: 1px solid #e5aaa5;
    border-radius: var(--mrt-radius-md);
    background: var(--mrt-color-danger-soft);
    color: var(--mrt-color-danger);
    font-weight: 800;
}

.mrt-text-button {
    display: inline-flex;
    min-height: 44px;
    align-items: center;
    gap: var(--mrt-space-2);
    padding: 6px 4px;
    border: 0;
    background: transparent;
    color: var(--mrt-color-primary);
    font-weight: 800;
}

:where(button, .mrt-button, .mrt-primary-button, .mrt-secondary-button, .mrt-danger-button)[disabled],
:where(button, .mrt-button, .mrt-primary-button, .mrt-secondary-button, .mrt-danger-button)[aria-disabled="true"] {
    cursor: not-allowed;
    filter: grayscale(.25);
    opacity: .56;
    transform: none;
}

/* Reusable cards and their interaction states. */
:where(.content-card, .service-card, .place-card, .mrt-management-card, .mrt-profile-card, .mrt-today-card) {
    border: 1px solid var(--mrt-color-border);
    border-radius: var(--mrt-radius-lg);
    background: var(--mrt-color-surface);
    box-shadow: var(--mrt-shadow-sm);
}

:where(a.content-card, a.service-card, a.place-card):hover {
    border-color: #b2cec4;
    box-shadow: var(--mrt-shadow-md);
    transform: translateY(-2px);
}

/* Notices, loading, empty and error states follow the same visual grammar. */
:where(.mrt-notice, .mrt-alert, .mrt-form-message) {
    padding: 14px 16px;
    border: 1px solid var(--mrt-color-border);
    border-radius: var(--mrt-radius-md);
    background: var(--mrt-color-surface);
}

:where(.mrt-notice, .mrt-alert).is-success { border-color: #b9ddcf; background: var(--mrt-color-success-soft); color: var(--mrt-color-success); }
:where(.mrt-notice, .mrt-alert).is-warning { border-color: #efd39d; background: var(--mrt-color-warning-soft); color: var(--mrt-color-warning); }
:where(.mrt-notice, .mrt-alert).is-error { border-color: #efc1bd; background: var(--mrt-color-danger-soft); color: var(--mrt-color-danger); }
:where(.mrt-notice, .mrt-alert).is-info { border-color: #bfd4eb; background: var(--mrt-color-info-soft); color: var(--mrt-color-info); }

:where(.mrt-empty, .mrt-management-empty, .mrt-empty-state) {
    display: grid;
    min-height: 180px;
    align-content: center;
    justify-items: center;
    gap: var(--mrt-space-3);
    padding: var(--mrt-space-8);
    border: 1px dashed #bfd2cb;
    border-radius: var(--mrt-radius-lg);
    background: #fbfdfc;
    color: var(--mrt-color-muted);
    text-align: center;
}

.mrt-skeleton {
    overflow: hidden;
    border-radius: var(--mrt-radius-sm);
    background: linear-gradient(90deg, #edf2ef 25%, #f8faf9 45%, #edf2ef 65%);
    background-size: 240% 100%;
    animation: mrt-skeleton-pulse 1.3s ease-in-out infinite;
}

@keyframes mrt-skeleton-pulse {
    to { background-position: -140% 0; }
}

@media (max-width: 720px) {
    :root {
        --mrt-space-8: 24px;
        --mrt-space-10: 32px;
        --mrt-radius-xl: 22px;
    }

    .mrt-container,
    .entry-shell,
    .portal-account-shell,
    .mrt-detail-page,
    .mrt-management-shell,
    .mrt-portal-product-page .entry-shell,
    .mrt-organization-landing-page .mrt-detail-page {
        width: min(calc(100% - 22px), var(--mrt-container));
    }

    body:has(.mobile-nav) {
        padding-bottom: 92px;
    }

    :where(.mrt-button, .mrt-primary-button, .mrt-secondary-button, .mrt-danger-button, .site-main button[type="submit"], .portal-account-shell button[type="submit"]) {
        min-height: 48px;
    }

    .entry-title,
    .mrt-detail-title {
        overflow-wrap: anywhere;
    }
}

@media (prefers-reduced-motion: reduce) {
    html { scroll-behavior: auto; }
    *, *::before, *::after {
        scroll-behavior: auto !important;
        animation-duration: .01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: .01ms !important;
    }
}

/* Defensive layout rules: no module card may force its grid outside the page. */
:where(.site-main, .portal-account-shell) :where(.mrt-form-grid, .mrt-field-grid, .mrt-route-grid, .mrt-account-stats, .mrt-account-actions, .mrt-management-grid) > * {
    min-width: 0;
    max-width: 100%;
}

:where(.site-main, .portal-account-shell) :where(h1, h2, h3, p, small) {
    overflow-wrap: break-word;
}

:where(.site-main, .portal-account-shell) :where(img, iframe, table) {
    max-width: 100%;
}

/*
 * Layout guardrails shared by old and new portal modules.
 * A number of feature modules use their own grids. These rules keep an
 * unexpectedly long title, phone number or control from widening the page.
 */
:where(.site-main, .portal-account-shell, .mrt-detail-page, .mrt-management-shell),
:where(.site-main, .portal-account-shell, .mrt-detail-page, .mrt-management-shell) *,
:where(.site-main, .portal-account-shell, .mrt-detail-page, .mrt-management-shell) *::before,
:where(.site-main, .portal-account-shell, .mrt-detail-page, .mrt-management-shell) *::after {
    box-sizing: border-box;
}

:where(.site-main, .portal-account-shell, .mrt-detail-page, .mrt-management-shell) :where(
    section, article, aside, header, footer, nav, form, fieldset, label, div,
    .mrt-card, .mrt-management-card, .mrt-settings-card
) {
    min-width: 0;
}

:where(.site-main, .portal-account-shell, .mrt-detail-page, .mrt-management-shell) :where(
    input:not([type="checkbox"]):not([type="radio"]), select, textarea
) {
    width: 100%;
    max-width: 100%;
}

:where(.site-main, .portal-account-shell, .mrt-detail-page, .mrt-management-shell) :where(
    h1, h2, h3, h4, p, li, dt, dd, strong, small, span, a
) {
    overflow-wrap: anywhere;
}

:where(.site-main, .portal-account-shell, .mrt-detail-page, .mrt-management-shell) :where(
    .mrt-form-grid, .mrt-field-grid, .mrt-settings-grid, .mrt-management-grid,
    .mrt-account-stats, .mrt-account-actions, .mrt-business-summary,
    .mrt-analytics-grid, .mrt-publication-card, .mrt-admin-organization-grid
) {
    max-width: 100%;
}

@media (max-width: 980px) {
    :where(.site-main, .portal-account-shell) :where(
        .mrt-form-grid, .mrt-field-grid, .mrt-settings-grid,
        .mrt-admin-organization-grid, .mrt-publication-card
    ) {
        grid-template-columns: minmax(0, 1fr) !important;
    }

    :where(.site-main, .portal-account-shell) :where(
        .mrt-account-stats, .mrt-account-actions, .mrt-business-summary,
        .mrt-analytics-grid
    ) {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 560px) {
    :where(.site-main, .portal-account-shell) :where(
        .mrt-account-stats, .mrt-account-actions, .mrt-business-summary,
        .mrt-analytics-grid
    ) {
        grid-template-columns: minmax(0, 1fr);
    }

    :where(.site-main, .portal-account-shell) :where(
        .mrt-button, .mrt-primary-button, .mrt-secondary-button,
        .mrt-danger-button, button[type="submit"]
    ) {
        max-width: 100%;
        white-space: normal;
    }
}

/* Portal layout contract: every module follows the same page width and cannot escape its grid. */
body :where(.site-main, .portal-account-shell, .mrt-detail-page, .mrt-management-shell) { min-width: 0; }
body :where(.site-main, .portal-account-shell) :where(.mrt-container, .mrt-detail-page, .mrt-management-shell, .mrt-portal-product-page, .mrt-cabinet, .mrt-business-dashboard, .mrt-social-hub) { max-width: var(--mrt-container); }
body :where(.site-main, .portal-account-shell) :where([class*="-grid"], [class*="__grid"], .archive-grid, .content-grid, .service-grid, .mrt-archive-tools, .mrt-route-grid) > * { min-width: 0; max-width: 100%; }

/* Keep the full services catalogue CTA compact and visually connected. */
.services-reference .reference-grid .service-card--all {
    grid-column: 1 / -1;
    display: grid;
    grid-template-columns: 68px minmax(0, 1fr) minmax(150px, 178px);
    grid-template-rows: auto auto;
    align-items: center;
    align-content: center;
    justify-items: stretch;
    gap: 3px 22px;
    min-height: 138px;
    padding: 23px 26px;
    text-align: left;
}

.services-reference .reference-grid .service-card--all .service-icon {
    grid-column: 1;
    grid-row: 1 / 3;
    width: 64px;
    height: 64px;
    margin: 0;
    border-radius: 18px;
}

.services-reference .reference-grid .service-card--all .service-icon svg {
    width: 38px;
    height: 38px;
}

.services-reference .reference-grid .service-card--all h3 {
    grid-column: 2;
    grid-row: 1;
    min-height: 0;
    margin: 0;
    font-size: clamp(21px, 2vw, 25px);
    line-height: 1.12;
}

.services-reference .reference-grid .service-card--all p {
    grid-column: 2;
    grid-row: 2;
    display: block;
    min-height: 0;
    margin: 4px 0 0;
    overflow: visible;
    color: #e4f2ed;
    font-size: 14px;
    line-height: 1.45;
    -webkit-line-clamp: unset;
}

.services-reference .reference-grid .service-card--all em {
    grid-column: 3;
    grid-row: 1 / 3;
    display: inline-flex;
    min-height: 52px;
    align-items: center;
    justify-content: center;
    align-self: center;
    margin: 0;
    padding: 14px 22px;
    border-radius: 16px;
    font-size: 14px;
    opacity: 1;
    transform: none;
}

.services-reference .reference-grid .service-card--all em span {
    font-size: 18px;
}

@media (max-width: 700px) {
    .services-reference .reference-grid .service-card--all {
        grid-template-columns: 54px minmax(0, 1fr);
        grid-template-rows: auto auto auto;
        gap: 3px 15px;
        min-height: 0;
        padding: 19px 17px;
    }

    .services-reference .reference-grid .service-card--all .service-icon {
        grid-column: 1;
        grid-row: 1 / 3;
        width: 52px;
        height: 52px;
        border-radius: 15px;
    }

    .services-reference .reference-grid .service-card--all .service-icon svg {
        width: 31px;
        height: 31px;
    }

    .services-reference .reference-grid .service-card--all h3 {
        grid-column: 2;
        grid-row: 1;
        font-size: 18px;
    }

    .services-reference .reference-grid .service-card--all p {
        grid-column: 2;
        grid-row: 2;
        font-size: 12px;
    }

    .services-reference .reference-grid .service-card--all em {
        grid-column: 1 / -1;
        grid-row: 3;
        width: 100%;
        min-height: 48px;
        margin-top: 12px;
        font-size: 13px;
    }
}
body :where(.site-main, .portal-account-shell) :where(input:not([type="checkbox"]):not([type="radio"]), select, textarea, iframe, canvas) { max-width: 100%; }

.mrt-event-discovery { display:grid;grid-template-columns:minmax(0,1fr) auto;align-items:end;gap:22px;margin:0 0 18px;padding:clamp(20px,3vw,30px);border:1px solid var(--mrt-color-border);border-radius:var(--mrt-radius-xl);background:linear-gradient(125deg,#eef7f3,#fff8e8);box-shadow:var(--mrt-shadow-sm) }
.mrt-event-discovery h2 { margin:5px 0 4px;font-size:clamp(26px,3.5vw,38px) }
.mrt-event-discovery p { max-width:680px;margin:0;color:var(--mrt-color-muted) }
.mrt-event-discovery nav { display:flex;gap:7px;flex-wrap:wrap;justify-content:flex-end }
.mrt-event-discovery nav a { flex:0 0 auto;padding:9px 13px;border:1px solid #cddfd7;border-radius:999px;background:#fff;color:var(--mrt-color-primary);font-size:13px;font-weight:850 }
.mrt-event-discovery nav a.is-active { border-color:var(--mrt-color-primary);background:var(--mrt-color-primary);color:#fff }
@media (max-width:760px) {.mrt-event-discovery{grid-template-columns:minmax(0,1fr);padding:20px 16px}.mrt-event-discovery nav{justify-content:flex-start;overflow-x:auto;flex-wrap:nowrap;padding-bottom:3px}}

/*
 * Stage 1 foundation (2026-08).
 * This final layer is the visual contract shared by archives, detail pages,
 * resident tools and the organization workspace.
 */
html {
    font-family: Roboto, Arial, sans-serif;
    font-size: 16px;
    -webkit-text-size-adjust: 100%;
}

body,
button,
input,
select,
textarea {
    font-family: Roboto, Arial, sans-serif;
}

body {
    min-width: 320px;
    overflow-x: clip;
    line-height: 1.55;
}

.site-main {
    width: 100%;
    min-width: 0;
}

/* The same content rail is used on the home page, archives and both cabinets. */
body :where(
    .mrt-container,
    .entry-shell,
    .portal-account-shell,
    .mrt-detail-page,
    .mrt-management-shell,
    .mrt-portal-product-page .entry-shell,
    .mrt-organization-landing-page .mrt-detail-page,
    .mrt-seo-generated-page .entry-shell
) {
    width: min(calc(100% - 32px), var(--mrt-container)) !important;
    max-width: var(--mrt-container) !important;
    margin-inline: auto !important;
}

/* Long-form text stays readable without making the whole page narrow. */
.entry-content > :where(p, ul, ol, blockquote):not([class]) {
    max-width: var(--mrt-reading-width);
}

:where(.site-main, .portal-account-shell, .mrt-management-shell) :where(h1, h2, h3, h4) {
    margin-top: 0;
    color: var(--mrt-color-text);
    font-weight: 800;
    line-height: 1.12;
    letter-spacing: -.025em;
    text-wrap: balance;
}

:where(.site-main, .portal-account-shell, .mrt-management-shell) h1 {
    font-size: clamp(34px, 4.4vw, 58px);
}

:where(.site-main, .portal-account-shell, .mrt-management-shell) h2 {
    font-size: clamp(26px, 3.1vw, 38px);
}

:where(.site-main, .portal-account-shell, .mrt-management-shell) h3 {
    font-size: clamp(20px, 2vw, 26px);
}

:where(.site-main, .portal-account-shell, .mrt-management-shell) :where(p, li, dd) {
    line-height: 1.6;
}

/* Common surface rhythm. Specific branded hero sections keep their own skin. */
:where(.site-main, .portal-account-shell) :where(
    .mrt-management-card,
    .mrt-settings-card,
    .mrt-profile-section,
    .mrt-notification-settings,
    .mrt-order-form,
    .mrt-empty-state
) {
    border-color: var(--mrt-color-border);
    border-radius: var(--mrt-radius-lg);
    background-color: var(--mrt-color-surface);
    box-shadow: var(--mrt-shadow-sm);
}

/* A grid child may shrink; text and controls must not push it outside the card. */
:where(.site-main, .portal-account-shell, .mrt-management-shell) :where(
    [class$="-grid"],
    [class*="-grid "],
    [class$="__grid"],
    [class*="__grid "],
    .mrt-cabinet,
    .mrt-detail-layout,
    .mrt-business-settings-forms,
    .mrt-business-onboarding-summary,
    .mrt-route-search
) > * {
    min-width: 0;
}

:where(.site-main, .portal-account-shell, .mrt-management-shell) :where(
    h1, h2, h3, h4, p, li, dt, dd, strong, small, a, label
) {
    max-width: 100%;
    overflow-wrap: break-word;
    word-break: normal;
}

:where(.site-main, .portal-account-shell, .mrt-management-shell) :where(
    img, video, svg, canvas, iframe
) {
    max-width: 100%;
}

/* Horizontal choices scroll inside their own rail instead of widening the page. */
:where(
    .mrt-category-jump,
    .mrt-business-dashboard-nav,
    .mrt-business-switcher,
    .mrt-social-nav,
    .mrt-event-discovery nav
) {
    max-width: 100%;
    overscroll-behavior-inline: contain;
    scrollbar-width: thin;
}

/* Search and filter actions should look like actions, not empty full-width bands. */
:where(.mrt-archive-tools, .mrt-directory-search, .mrt-search-results-form) > :where(button, .mrt-button) {
    width: auto !important;
    min-width: 144px;
    max-width: 220px;
    justify-self: start;
}

/* The cabinet is stable: fixed sidebar on desktop, one clean column on tablets. */
.portal-account-shell .mrt-cabinet {
    width: 100% !important;
    margin: 0 !important;
    grid-template-columns: minmax(230px, 270px) minmax(0, 1fr) !important;
    align-items: start;
}

.portal-account-shell :where(.mrt-cabinet-sidebar, .mrt-cabinet-content) {
    width: 100%;
    min-width: 0;
    max-width: 100%;
}

.portal-account-shell .mrt-cabinet-content {
    overflow: clip;
}

@media (max-width: 980px) {
    .portal-account-shell .mrt-cabinet {
        grid-template-columns: minmax(0, 1fr) !important;
    }

    .portal-account-shell .mrt-cabinet-sidebar {
        position: static !important;
        top: auto !important;
    }

    :where(.mrt-archive-tools, .mrt-directory-search, .mrt-search-results-form) > :where(button, .mrt-button) {
        max-width: none;
    }
}

@media (max-width: 620px) {
    :root {
        --mrt-space-8: 24px;
        --mrt-space-10: 30px;
        --mrt-radius-xl: 22px;
    }

    body :where(
        .mrt-container,
        .entry-shell,
        .portal-account-shell,
        .mrt-detail-page,
        .mrt-management-shell,
        .mrt-portal-product-page .entry-shell,
        .mrt-organization-landing-page .mrt-detail-page,
        .mrt-seo-generated-page .entry-shell
    ) {
        width: min(calc(100% - 20px), var(--mrt-container)) !important;
    }

    :where(.site-main, .portal-account-shell, .mrt-management-shell) h1 {
        font-size: clamp(31px, 10vw, 42px);
        line-height: 1.08;
    }

    :where(.site-main, .portal-account-shell, .mrt-management-shell) h2 {
        font-size: clamp(25px, 7.5vw, 34px);
    }

    .portal-account-shell .mrt-cabinet-content {
        padding: 16px 12px !important;
        border-radius: 18px;
    }

    :where(.mrt-archive-tools, .mrt-directory-search, .mrt-search-results-form) > :where(button, .mrt-button) {
        width: 100% !important;
        min-width: 0;
        max-width: none;
    }

    :where(.site-main, .portal-account-shell) :where(
        .mrt-form-grid,
        .mrt-field-grid,
        .mrt-settings-grid,
        .mrt-management-grid,
        .mrt-admin-organization-grid,
        .mrt-publication-card,
        .mrt-business-settings-forms,
        .mrt-business-onboarding-summary,
        .mrt-route-search
    ) {
        grid-template-columns: minmax(0, 1fr) !important;
    }

    :where(.site-main, .portal-account-shell) :where(
        input:not([type="checkbox"]):not([type="radio"]):not([type="range"]),
        select,
        textarea
    ) {
        min-width: 0;
        font-size: 16px;
    }
}
