/* ============================================================
   Rumos Creator Portal: the app stylesheet.
   Tokens come from the Figma file (collections Rumos Color and Rumos Scale) and keep the
   Figma names, so var(--color-text-heading) in design context output works as is.
   Every class starts with r-.
   Reference: docs/redesign-components.md
   ============================================================ */

/* ---- Fonts (self-hosted, covered by font-src 'self') ---- */
@font-face {
    font-family: "Montserrat";
    src: url("../fonts/montserrat-latin.woff2") format("woff2");
    font-weight: 100 900;
    font-display: swap;
    unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
    font-family: "Montserrat";
    src: url("../fonts/montserrat-latin-ext.woff2") format("woff2");
    font-weight: 100 900;
    font-display: swap;
    unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
    font-family: "JetBrains Mono";
    src: url("../fonts/jetbrains-mono-latin.woff2") format("woff2");
    font-weight: 100 800;
    font-display: swap;
    unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
    font-family: "JetBrains Mono";
    src: url("../fonts/jetbrains-mono-latin-ext.woff2") format("woff2");
    font-weight: 100 800;
    font-display: swap;
    unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

/* ---- Tokens ---- */
:root {
    --font-sans: "Montserrat", -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
    --font-mono: "JetBrains Mono", ui-monospace, Consolas, Menlo, monospace;

    --spacing-xs: 4px;
    --spacing-sm: 8px;
    --spacing-md: 12px;
    --spacing-lg: 16px;
    --spacing-xl: 24px;
    --spacing-2xl: 32px;
    --spacing-3xl: 48px;

    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-card: 14px;
    --radius-lg: 16px;
    --radius-full: 999px;

    --sidebar-width: 240px;
    --tabbar-height: 59px;
}

:root, [data-theme="light"] {
    color-scheme: light;
    --color-bg-page: #f7f8fc;
    --color-bg-card: #ffffff;
    --color-bg-subtle: #eef0ff;
    --color-bg-raised: #eef0ff;
    --color-bg-nav: #0c0d31;
    --color-bg-nav-active: #192549;
    --color-bg-selected: #0c0d31;
    --color-action-primary: #f7901c;
    --color-action-secondary: #dee1ff;
    --color-text-primary: #0c0d31;
    --color-text-secondary: #4a4c6b;
    --color-text-muted: #62648a;
    --color-text-heading: #0c0d31;
    --color-text-link: #0c0d31;
    --color-text-on-primary: #0c0d31;
    --color-text-on-nav: #dee1ff;
    --color-text-on-selected: #ffffff;
    --color-border-default: #eceef6;
    --color-border-strong: #c5c8e0;
    --color-status-success-text: #0f6e46;
    --color-status-success-bg: #e0f5ea;
    --color-status-warning-text: #7a4f00;
    --color-status-warning-bg: #fff1d0;
    --color-status-danger-text: #a8221a;
    --color-status-danger-bg: #fce8e6;
    --color-status-info-text: #2747a8;
    --color-status-info-bg: #e5eafb;
    --color-brand-mark: #f7901c;
    --color-tint-orange-bg: #ffefdd;
    --color-tint-orange-fg: #b35f00;
    --color-tint-blue-bg: #e5eafb;
    --color-tint-blue-fg: #2747a8;
    --color-tint-violet-bg: #efe7fb;
    --color-tint-violet-fg: #6a3bb0;
    --color-tint-green-bg: #e0f5ea;
    --color-tint-green-fg: #0f6e46;
    --color-chart-grid: #e1e3f0;
    --color-chart-track: #eef0ff;
    --color-data-line: #0f6e46;
    --color-data-up: #0f6e46;
    --color-dot-good: #0f6e46;
    --color-dot-warn: #b35f00;
    --color-dot-bad: #a8221a;
    --color-dot-info: #2747a8;
    --color-dot-idle: #9a9ea7;
    --select-chevron: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20' fill='none' stroke='%2362648a' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M5 7.5L10 12.5L15 7.5'/%3E%3C/svg%3E");
}

[data-theme="dark"] {
    color-scheme: dark;
    --color-bg-page: #0c0d31;
    --color-bg-card: #131643;
    --color-bg-subtle: #192549;
    --color-bg-raised: #192549;
    --color-bg-nav: #090a23;
    --color-bg-nav-active: #192549;
    --color-bg-selected: #dee1ff;
    --color-action-primary: #f7901c;
    --color-action-secondary: #223368;
    --color-text-primary: #e2e3e5;
    --color-text-secondary: #c4c7ca;
    --color-text-muted: #9a9ea7;
    --color-text-heading: #dee1ff;
    --color-text-link: #dee1ff;
    --color-text-on-primary: #0c0d31;
    --color-text-on-nav: #dee1ff;
    --color-text-on-selected: #0c0d31;
    --color-border-default: #242f4c;
    --color-border-strong: #35446e;
    --color-status-success-text: #31d387;
    --color-status-success-bg: #123a3a;
    --color-status-warning-text: #ffc27a;
    --color-status-warning-bg: #332846;
    --color-status-danger-text: #ff6b93;
    --color-status-danger-bg: #3d1b38;
    --color-status-info-text: #7fd6fa;
    --color-status-info-bg: #123258;
    --color-brand-mark: #f7901c;
    --color-tint-orange-bg: #332846;
    --color-tint-orange-fg: #f7901c;
    --color-tint-blue-bg: #123258;
    --color-tint-blue-fg: #0fb4f5;
    --color-tint-violet-bg: #2a1f52;
    --color-tint-violet-fg: #b18cf0;
    --color-tint-green-bg: #123a3a;
    --color-tint-green-fg: #31d387;
    --color-chart-grid: #223368;
    --color-chart-track: #192549;
    --color-data-line: #31d387;
    --color-data-up: #31d387;
    --color-dot-good: #31d387;
    --color-dot-warn: #f7901c;
    --color-dot-bad: #ff6b93;
    --color-dot-info: #7fd6fa;
    --color-dot-idle: #797d86;
    --select-chevron: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20' fill='none' stroke='%239a9ea7' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M5 7.5L10 12.5L15 7.5'/%3E%3C/svg%3E");
}

/* ---- Base ---- */
*, *::before, *::after { box-sizing: border-box; }

body {
    margin: 0;
    background: var(--color-bg-page);
    color: var(--color-text-primary);
    font-family: var(--font-sans);
    font-size: 14px;
    line-height: 22px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

a { color: var(--color-text-link); text-decoration: none; }
a:hover, a:focus { color: var(--color-text-link); text-decoration: underline; }

:focus-visible { outline: 2px solid var(--color-action-primary); outline-offset: 2px; }

input[type="checkbox"], input[type="radio"] { accent-color: var(--color-action-primary); }

.r-icon { display: inline-block; flex: none; vertical-align: -3px; }

.r-sr-only {
    position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; border: 0;
    overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap;
}

.r-skip {
    position: fixed; top: 8px; left: 8px; z-index: 1300; padding: 8px 14px; border-radius: var(--radius-md);
    background: var(--color-action-primary); color: var(--color-text-on-primary); transform: translateY(-200%);
}
.r-skip:focus { color: var(--color-text-on-primary); transform: none; }

/* ---- Type ---- */
.r-display { margin: 0; font-size: 28px; line-height: 36px; font-weight: 700; color: var(--color-text-heading); }
.r-h-page { margin: 0; font-size: 24px; line-height: 32px; font-weight: 700; color: var(--color-text-heading); }
.r-h2 { margin: 0; font-size: 20px; line-height: 28px; font-weight: 700; color: var(--color-text-heading); }
.r-h3 { margin: 0; font-size: 16px; line-height: 24px; font-weight: 700; color: var(--color-text-heading); }
.r-h-section { margin: 0; font-size: 16px; line-height: 24px; font-weight: 600; color: var(--color-text-heading); }
.r-body { margin: 0; font-size: 14px; line-height: 22px; font-weight: 400; }
.r-body-md { margin: 0; font-size: 14px; line-height: 22px; font-weight: 500; }
.r-small { margin: 0; font-size: 12px; line-height: 18px; font-weight: 400; }
.r-small-md { margin: 0; font-size: 12px; line-height: 18px; font-weight: 500; }
.r-num-hero { margin: 0; font-family: var(--font-mono); font-size: 46px; line-height: 54px; font-weight: 700; letter-spacing: -0.02em; color: var(--color-text-heading); }
.r-num-lg { margin: 0; font-family: var(--font-mono); font-size: 26px; line-height: 32px; font-weight: 700; color: var(--color-text-heading); }
.r-num { font-family: var(--font-mono); font-size: 14px; line-height: 22px; font-weight: 700; }
.r-num-sm { font-family: var(--font-mono); font-size: 12px; line-height: 18px; font-weight: 700; }
.r-num-hero, .r-num-lg, .r-num, .r-num-sm { font-variant-numeric: tabular-nums; }

.r-text-primary { color: var(--color-text-primary); }
.r-text-secondary { color: var(--color-text-secondary); }
.r-text-muted { color: var(--color-text-muted); }
.r-text-up { color: var(--color-data-up); }

.r-link { font-size: 12px; line-height: 18px; font-weight: 500; color: var(--color-tint-orange-fg); }
.r-link:hover, .r-link:focus { color: var(--color-tint-orange-fg); }
.r-link--plain { color: var(--color-text-link); }
.r-link--plain:hover, .r-link--plain:focus { color: var(--color-text-link); }

/* ---- Layout helpers ---- */
.r-stack { display: flex; flex-direction: column; gap: var(--spacing-lg); }
.r-stack--sm { gap: var(--spacing-sm); }
.r-cluster { display: flex; flex-wrap: wrap; align-items: center; gap: var(--spacing-sm); }
.r-spacer { flex: 1 1 0; min-width: 0; }
.r-columns { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: var(--spacing-lg); align-items: start; }
.r-mobile-only { display: none !important; }

/* ---- Shell (desktop) ---- */
.r-shell { background: var(--color-bg-nav); }

.r-app { display: flex; height: 100vh; height: 100dvh; overflow: hidden; background: var(--color-bg-nav); }

.r-sidebar {
    flex: 0 0 var(--sidebar-width);
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-height: 0;
    padding: 24px 14px 16px;
    overflow-y: auto;
    color: var(--color-text-on-nav);
}
.r-sidebar__brand { display: block; width: 142px; padding: 0 0 24px 10px; }
.r-sidebar__brand img { display: block; width: 132px; height: 28px; }

.r-nav { display: flex; flex-direction: column; gap: 2px; margin: 0; padding: 0; list-style: none; }
.r-nav__item {
    display: flex;
    align-items: center;
    gap: var(--spacing-md);
    padding: 10px 12px;
    border-radius: var(--radius-md);
    color: var(--color-text-on-nav);
    font-size: 14px;
    line-height: 22px;
    font-weight: 500;
    transition: background-color .15s ease;
}
.r-nav__item:hover, .r-nav__item:focus { color: var(--color-text-on-nav); text-decoration: none; background: rgba(222, 225, 255, .06); }
.r-nav__label { opacity: .8; }
.r-nav__item.is-active { background: var(--color-bg-nav-active); }
.r-nav__item.is-active .r-nav__label { opacity: 1; }
.r-nav__item.is-active .r-icon { color: var(--color-action-primary); }

.r-count {
    display: inline-block;
    min-width: 22px;
    padding: 0 7px;
    border-radius: var(--radius-full);
    background: var(--color-action-primary);
    color: var(--color-text-on-primary);
    font-family: var(--font-mono);
    font-size: 12px;
    line-height: 18px;
    font-weight: 700;
    text-align: center;
}

.r-account {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: auto;
    padding: 9px 4px 9px 10px;
    border-radius: 12px;
    background: var(--color-bg-nav-active);
    color: var(--color-text-on-nav);
}
.r-account__who { display: flex; flex: 1 1 0; align-items: center; gap: 10px; min-width: 0; color: inherit; }
.r-account__who:hover, .r-account__who:focus { color: inherit; text-decoration: none; }
.r-account__text { display: flex; flex-direction: column; min-width: 0; font-size: 12px; line-height: 18px; }
.r-account__name, .r-account__tier { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.r-account__name { font-weight: 500; }
.r-account__tier { font-weight: 400; opacity: .7; }
.r-account form { margin: 0; }

.r-avatar {
    display: inline-flex;
    flex: none;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    overflow: hidden;
    border-radius: 50%;
    background: var(--color-action-primary);
    color: var(--color-text-on-primary);
    font-size: 12px;
    line-height: 18px;
    font-weight: 500;
}
.r-avatar img { display: block; width: 100%; height: 100%; object-fit: cover; }
.r-avatar--sm { width: 30px; height: 30px; }

/* Bare icon button. On the navy nav it inherits on-nav; in the panel, text-secondary. */
.r-iconbtn {
    display: inline-flex;
    flex: none;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    padding: 0;
    border: 0;
    border-radius: var(--radius-sm);
    background: transparent;
    color: inherit;
    cursor: pointer;
    transition: background-color .15s ease;
}
.r-iconbtn:hover { background: rgba(127, 134, 190, .18); }

.r-theme-icon { display: inline-flex; }
[data-theme="dark"] .r-theme-icon--sun, [data-theme="light"] .r-theme-icon--moon { display: none; }

.r-panel {
    display: flex;
    flex: 1 1 0;
    flex-direction: column;
    min-width: 0;
    margin: 10px 10px 10px 0;
    overflow-y: auto;
    scrollbar-color: var(--color-border-strong) transparent;
    scrollbar-width: thin;
    border-radius: 18px;
    background: var(--color-bg-page);
    color: var(--color-text-primary);
}
.r-panel:focus { outline: 0; }

.r-main { display: flex; flex: 1 0 auto; flex-direction: column; gap: 22px; min-width: 0; padding: 24px 32px 32px; }
.r-footer { padding: 0 32px 16px; font-size: 12px; line-height: 18px; color: var(--color-text-muted); }

.r-topbar, .r-tabbar { display: none; }

/* ---- Page header ---- */
.r-page-header { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; min-height: 42px; }
.r-page-title { margin: 0; font-size: 24px; line-height: 32px; font-weight: 700; color: var(--color-text-heading); }
.r-page-header__actions { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-left: auto; }
.r-breadcrumb { display: flex; flex-wrap: wrap; gap: 6px; font-size: 12px; line-height: 18px; font-weight: 500; color: var(--color-text-muted); }
.r-breadcrumb a { color: inherit; }

/* ---- Buttons ---- */
.r-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 9px 14px;
    border: 1px solid transparent;
    border-radius: var(--radius-md);
    font-family: inherit;
    font-size: 14px;
    line-height: 22px;
    font-weight: 500;
    white-space: nowrap;
    cursor: pointer;
    transition: filter .15s ease, background-color .15s ease;
}
.r-btn:hover, .r-btn:focus { text-decoration: none; }
.r-btn[disabled], .r-btn.is-disabled { opacity: .5; cursor: not-allowed; pointer-events: none; }

.r-btn--primary { background: var(--color-action-primary); color: var(--color-text-on-primary); }
.r-btn--primary:hover, .r-btn--primary:focus { color: var(--color-text-on-primary); filter: brightness(1.06); }

.r-btn--secondary { background: var(--color-bg-raised); color: var(--color-text-primary); }
.r-btn--secondary:hover, .r-btn--secondary:focus { background: var(--color-action-secondary); color: var(--color-text-primary); }

.r-btn--ghost { background: transparent; border-color: var(--color-border-strong); color: var(--color-text-primary); }
.r-btn--ghost:hover, .r-btn--ghost:focus { background: var(--color-bg-raised); color: var(--color-text-primary); }

.r-btn--danger { background: var(--color-status-danger-bg); color: var(--color-status-danger-text); }
.r-btn--danger:hover, .r-btn--danger:focus { color: var(--color-status-danger-text); filter: brightness(1.12); }
[data-theme="light"] .r-btn--danger:hover, [data-theme="light"] .r-btn--danger:focus { filter: brightness(.96); }

.r-btn--sm { padding: 5px 12px; font-size: 12px; line-height: 18px; }
.r-btn--lg { padding: 12px 14px; }
.r-btn--block { display: flex; width: 100%; }

/* ---- Forms ---- */
.r-form { display: flex; flex-direction: column; gap: 14px; margin: 0; }
.r-field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.r-label { display: block; margin: 0; font-size: 12px; line-height: 18px; font-weight: 500; color: var(--color-text-secondary); }
.r-hint { margin: 0; font-size: 12px; line-height: 18px; color: var(--color-text-muted); }
.r-field-error { margin: 0; font-size: 12px; line-height: 18px; font-weight: 500; color: var(--color-status-danger-text); }

.r-input, .r-textarea, .r-select {
    display: block;
    width: 100%;
    margin: 0;
    padding: 10px 12px;
    border: 1px solid var(--color-border-default);
    border-radius: var(--radius-md);
    background-color: var(--color-bg-raised);
    color: var(--color-text-primary);
    font-family: inherit;
    font-size: 14px;
    line-height: 22px;
    font-weight: 400;
    transition: border-color .15s ease, box-shadow .15s ease;
}
.r-input { height: 44px; }
.r-textarea { min-height: 96px; resize: vertical; }
.r-select {
    height: 44px;
    padding-right: 36px;
    appearance: none;
    -webkit-appearance: none;
    background-image: var(--select-chevron);
    background-repeat: no-repeat;
    background-position: right 10px center;
    background-size: 18px 18px;
}
.r-input::placeholder, .r-textarea::placeholder { color: var(--color-text-muted); opacity: 1; }
.r-input:focus, .r-textarea:focus, .r-select:focus {
    outline: 0;
    border-color: var(--color-action-primary);
    box-shadow: 0 0 0 1px var(--color-action-primary);
}
.r-input[disabled], .r-textarea[disabled], .r-select[disabled],
.r-input[readonly], .r-textarea[readonly] { color: var(--color-text-muted); cursor: not-allowed; }
.r-input.is-invalid, .r-textarea.is-invalid, .r-select.is-invalid { border-color: var(--color-status-danger-text); }
.r-input--lg { height: 48px; padding: 12px 13px; }

/* Browser autofill would paint its own light fill over the raised background. */
.r-input:-webkit-autofill {
    -webkit-text-fill-color: var(--color-text-primary);
    -webkit-box-shadow: 0 0 0 40px var(--color-bg-raised) inset;
    caret-color: var(--color-text-primary);
}

.r-input-wrap { position: relative; }
.r-input-wrap .r-input { padding-right: 44px; }
.r-input-wrap__btn {
    position: absolute;
    top: 50%;
    right: 8px;
    transform: translateY(-50%);
    color: var(--color-text-secondary);
}
.r-input-wrap__btn .r-icon--off { display: none; }
.r-input-wrap__btn[aria-pressed="true"] .r-icon--on { display: none; }
.r-input-wrap__btn[aria-pressed="true"] .r-icon--off { display: inline-block; }

.r-search { position: relative; display: block; min-width: 204px; margin: 0; }
.r-search .r-icon { position: absolute; top: 50%; left: 12px; color: var(--color-text-muted); transform: translateY(-50%); pointer-events: none; }
.r-search .r-input { height: 40px; padding: 10px 12px 10px 36px; font-size: 12px; line-height: 18px; }

/* ---- Card ---- */
.r-card {
    border: 1px solid var(--color-border-default);
    border-radius: var(--radius-card);
    background: var(--color-bg-card);
    color: var(--color-text-primary);
}
.r-card--pad { display: flex; flex-direction: column; gap: 14px; padding: 20px; }

/* ---- List and list row ---- */
.r-list { overflow: hidden; }
.r-list__head {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    padding: 11px 18px;
    font-size: 12px;
    line-height: 18px;
    font-weight: 500;
    color: var(--color-text-secondary);
}
.r-list__count { font-family: var(--font-mono); font-weight: 700; color: var(--color-text-muted); }

.r-row {
    display: flex;
    align-items: center;
    gap: 14px;
    min-height: 60px;
    padding: 12px 18px;
    border-top: 1px solid var(--color-border-default);
    color: var(--color-text-primary);
}
.r-row:first-child { border-top: 0; }
a.r-row:hover, a.r-row:focus { color: var(--color-text-primary); text-decoration: none; background: var(--color-bg-subtle); }
.r-row__icon {
    display: inline-flex;
    flex: none;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: 9px;
    background: var(--color-bg-raised);
    color: var(--color-text-secondary);
}
.r-row__text { display: flex; flex: 1 1 0; flex-direction: column; min-width: 0; }
.r-row__title, .r-row__meta { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.r-row__title { font-size: 14px; line-height: 22px; font-weight: 500; color: var(--color-text-primary); }
.r-row__meta { font-size: 12px; line-height: 18px; color: var(--color-text-muted); }
.r-row__value { flex: none; width: 70px; font-family: var(--font-mono); font-size: 14px; line-height: 22px; font-weight: 700; text-align: right; }
.r-row__when { flex: none; width: 84px; font-size: 12px; line-height: 18px; color: var(--color-text-muted); text-align: right; }
.r-row__more { color: var(--color-text-secondary); }

/* Rows that are only a link, as on the phone Profile. */
.r-menu { display: flex; flex-direction: column; overflow: hidden; }
.r-menu__item {
    display: flex;
    align-items: center;
    gap: var(--spacing-md);
    padding: 13px 14px;
    border-top: 1px solid var(--color-border-default);
    color: var(--color-text-primary);
    font-size: 14px;
    line-height: 22px;
    font-weight: 500;
}
.r-menu__item:first-child { border-top: 0; }
.r-menu__item:hover, .r-menu__item:focus { color: var(--color-text-primary); text-decoration: none; background: var(--color-bg-subtle); }
.r-menu__item .r-icon:first-child { color: var(--color-text-secondary); }

/* ---- Status pills ---- */
.r-pill {
    display: inline-flex;
    flex: none;
    padding: 3px 10px;
    border-radius: var(--radius-full);
    font-size: 12px;
    line-height: 18px;
    font-weight: 500;
    white-space: nowrap;
}
.r-pill--draft { background: var(--color-bg-subtle); color: var(--color-text-secondary); }
.r-pill--review, .r-pill--scheduled { background: var(--color-status-info-bg); color: var(--color-status-info-text); }
.r-pill--changes { background: var(--color-status-warning-bg); color: var(--color-status-warning-text); }
.r-pill--rejected { background: var(--color-status-danger-bg); color: var(--color-status-danger-text); }
.r-pill--approved, .r-pill--live { background: var(--color-status-success-bg); color: var(--color-status-success-text); }

/* ---- Tabs (pill filters) and segmented range ---- */
.r-tabs { display: flex; align-items: center; gap: 6px; max-width: 100%; overflow-x: auto; scrollbar-width: none; }
.r-tabs::-webkit-scrollbar { display: none; }
.r-tab {
    display: inline-flex;
    flex: none;
    align-items: center;
    gap: 6px;
    padding: 6px 13px;
    border: 0;
    border-radius: var(--radius-full);
    background: transparent;
    color: var(--color-text-secondary);
    font-family: inherit;
    font-size: 12px;
    line-height: 18px;
    font-weight: 500;
    cursor: pointer;
}
.r-tab:hover, .r-tab:focus { color: var(--color-text-primary); text-decoration: none; background: var(--color-bg-raised); }
.r-tab.is-active, .r-tab.is-active:hover, .r-tab.is-active:focus { background: var(--color-bg-selected); color: var(--color-text-on-selected); }
.r-tab__count { font-family: var(--font-mono); font-weight: 700; color: var(--color-text-muted); }
.r-tab.is-active .r-tab__count { color: inherit; }

.r-segmented { display: inline-flex; gap: 2px; padding: 3px; border-radius: 9px; background: var(--color-bg-raised); }
.r-segmented__item {
    padding: 3px 10px;
    border: 0;
    border-radius: 7px;
    background: transparent;
    color: var(--color-text-secondary);
    font-family: inherit;
    font-size: 12px;
    line-height: 18px;
    font-weight: 500;
    cursor: pointer;
}
.r-segmented__item.is-active { background: var(--color-bg-selected); color: var(--color-text-on-selected); }

/* Choice cards, e.g. Light and Dark under Appearance. */
.r-options { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.r-option {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--spacing-sm);
    min-height: 44px;
    padding: 12px;
    border: 1px solid var(--color-border-default);
    border-radius: var(--radius-md);
    background: var(--color-bg-raised);
    color: var(--color-text-primary);
    font-family: inherit;
    font-size: 12px;
    line-height: 18px;
    font-weight: 500;
    cursor: pointer;
}
.r-option.is-active { border-color: var(--color-action-primary); box-shadow: 0 0 0 1px var(--color-action-primary); }

/* ---- Pagination ---- */
.r-pagination { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 6px; font-size: 12px; line-height: 18px; font-weight: 500; }
.r-pagination__item {
    min-width: 30px;
    padding: 6px 10px;
    border-radius: var(--radius-sm);
    color: var(--color-text-secondary);
    text-align: center;
}
.r-pagination__item:hover, .r-pagination__item:focus { color: var(--color-text-primary); text-decoration: none; background: var(--color-bg-raised); }
.r-pagination__item.is-active { background: var(--color-bg-selected); color: var(--color-text-on-selected); }

/* ---- Banners ---- */
.r-banner {
    display: flex;
    align-items: center;
    gap: var(--spacing-md);
    padding: 12px 16px;
    border-radius: 12px;
    color: var(--color-text-primary);
    font-size: 14px;
    line-height: 22px;
}
.r-banner__body { flex: 1 1 0; min-width: 0; }
.r-banner__title { font-weight: 500; }
.r-banner__note { color: var(--color-text-secondary); }
.r-banner__actions { display: flex; flex: none; align-items: center; gap: var(--spacing-sm); }
.r-banner__close { margin: -4px -6px -4px 0; color: var(--color-text-secondary); }
.r-banner > .r-icon { color: var(--r-banner-fg, var(--color-text-secondary)); }

.r-banner--success { --r-banner-fg: var(--color-status-success-text); background: var(--color-status-success-bg); }
.r-banner--info { --r-banner-fg: var(--color-status-info-text); background: var(--color-status-info-bg); }
.r-banner--warning { --r-banner-fg: var(--color-status-warning-text); background: var(--color-status-warning-bg); }
.r-banner--danger { --r-banner-fg: var(--color-status-danger-text); background: var(--color-status-danger-bg); }
.r-banner--orange { --r-banner-fg: var(--color-action-primary); background: var(--color-tint-orange-bg); }

.r-banner--compact { gap: 10px; padding: 11px 13px; border-radius: var(--radius-md); font-size: 12px; line-height: 18px; font-weight: 500; }
.r-banner--compact > .r-icon { align-self: flex-start; margin-top: 1px; }

.r-flash { display: flex; flex-direction: column; gap: var(--spacing-sm); }

/* ---- Toast ---- */
.r-toast-region {
    position: fixed;
    left: 50%;
    bottom: 24px;
    z-index: 1200;
    display: flex;
    flex-direction: column;
    align-items: center;
    width: max-content;
    max-width: calc(100vw - 32px);
    transform: translateX(-50%);
    pointer-events: none;
}
.r-toast {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 11px 16px;
    border-radius: 12px;
    background: var(--color-bg-selected);
    color: var(--color-text-on-selected);
    font-size: 12px;
    line-height: 18px;
    font-weight: 500;
    box-shadow: 0 8px 24px rgba(0, 0, 20, .35);
    pointer-events: auto;
    animation: r-toast-in .18s ease-out;
}
.r-toast__action {
    padding: 0;
    border: 0;
    background: transparent;
    color: inherit;
    font: inherit;
    text-decoration: underline;
    cursor: pointer;
}
@keyframes r-toast-in { from { opacity: 0; transform: translateY(8px); } }

/* ---- Dialog (native <dialog>, opened with showModal) ---- */
.r-dialog {
    width: calc(100vw - 32px);
    max-width: 440px;
    max-height: calc(100vh - 32px);
    margin: auto;
    padding: 24px;
    overflow-y: auto;
    border: 1px solid var(--color-border-default);
    border-radius: var(--radius-lg);
    background: var(--color-bg-card);
    color: var(--color-text-primary);
}
.r-dialog[open] { display: flex; flex-direction: column; gap: var(--spacing-md); }
.r-dialog::backdrop { background: rgba(8, 8, 33, .62); }
.r-dialog__title { margin: 0; font-size: 16px; line-height: 24px; font-weight: 700; color: var(--color-text-heading); }
.r-dialog__body { margin: 0; font-size: 14px; line-height: 22px; color: var(--color-text-secondary); }
.r-dialog__actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: var(--spacing-sm); }

/* ---- Empty state ---- */
.r-empty {
    display: flex;
    flex: 1 0 auto;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: var(--spacing-3xl) var(--spacing-lg);
    text-align: center;
}
.r-empty__icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 60px;
    height: 60px;
    border-radius: var(--radius-lg);
    background: var(--color-bg-raised);
    color: var(--color-action-primary);
}
.r-empty__icon svg { width: 26px; height: 26px; }
.r-empty__title { margin: 0; font-size: 16px; line-height: 24px; font-weight: 700; color: var(--color-text-heading); }
.r-empty__text { max-width: 624px; margin: 0; font-size: 14px; line-height: 22px; color: var(--color-text-secondary); }
.r-empty__action { margin-top: 6px; }

/* Stand-alone 404 and 500. */
.r-error { display: flex; min-height: 100vh; min-height: 100dvh; align-items: center; justify-content: center; }

/* ---- Sign-in screens ---- */
.r-auth { display: flex; min-height: 100vh; min-height: 100dvh; background: var(--color-bg-page); }
.r-auth__side {
    display: flex;
    flex: 1 1 0;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-width: 0;
    padding: var(--spacing-2xl) var(--spacing-xl);
}
.r-auth__form { display: flex; flex-direction: column; gap: 16px; width: 100%; max-width: 400px; }
.r-auth__form .r-form { gap: 16px; }
.r-auth__title { display: flex; flex-direction: column; gap: 6px; }
.r-auth__title p { margin: 0; color: var(--color-text-secondary); }
.r-auth__row { display: flex; justify-content: flex-end; }
.r-auth__note { margin: 0; font-size: 12px; line-height: 18px; color: var(--color-text-muted); }
.r-auth__badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 52px;
    height: 52px;
    border-radius: 50%;
}
.r-auth__badge--good { background: var(--color-tint-green-bg); color: var(--color-tint-green-fg); }
.r-auth__badge--warn { background: var(--color-status-warning-bg); color: var(--color-status-warning-text); }

/* Brand panel: the same navy in both themes. */
.r-auth__brand {
    position: relative;
    flex: 0 0 auto;
    width: min(760px, 52.8vw);
    padding: 48px 56px;
    overflow: hidden;
    color: #dee1ff;
    background:
        radial-gradient(71.4% 71.4% at 42.9% 64.3%, rgba(15, 180, 245, .18), rgba(15, 180, 245, 0)),
        radial-gradient(55.6% 55.6% at 50% 24.4%, rgba(128, 80, 200, .42), rgba(128, 80, 200, 0)),
        #0c0d31;
}
.r-auth__logo { display: block; width: 132px; height: 28px; margin-bottom: 50px; }
.r-auth__slogan { margin: 0 0 12px; font-size: 28px; line-height: 36px; font-weight: 700; color: #dee1ff; }
.r-auth__sub { margin: 0; font-size: 14px; line-height: 22px; color: #dee1ff; opacity: .8; }

/* Phones scale with the panel (760px wide at the 1440 frame) and hang off its bottom edge,
   never rising into the headline. --phones-min is where that headline ends. */
.r-auth__phones { --phones-min: 210px; position: absolute; inset: 0; container-type: inline-size; }
.r-phone {
    position: absolute;
    display: block;
    border: solid #36456e;
    box-shadow: 0 24px 60px rgba(0, 0, 20, .55);
    object-fit: cover;
    background: #0c0d31;
}
.r-phone--profile {
    z-index: 2;
    left: 22.67cqw;
    top: max(var(--phones-min), calc(100% - 80.4cqw));
    width: 39.47cqw;
    height: 85.53cqw;
    border-width: .66cqw;
    border-radius: 4.34cqw;
    transform: rotate(-4deg);
}
.r-phone--workshops {
    z-index: 1;
    left: 50.44cqw;
    top: max(calc(var(--phones-min) + 7.4cqw), calc(100% - 73.1cqw));
    width: 35.53cqw;
    height: 76.97cqw;
    border-width: .66cqw;
    border-radius: 3.95cqw;
    transform: rotate(7deg);
}

/* Two-factor: one real input, shown as six boxes once rumos.js takes over. */
.r-otp { position: relative; }
.r-otp__boxes { display: none; gap: 10px; }
.r-otp__box {
    display: flex;
    flex: 1 1 0;
    align-items: center;
    justify-content: center;
    height: 64px;
    border: 1px solid var(--color-border-default);
    border-radius: var(--radius-md);
    background: var(--color-bg-raised);
    color: var(--color-text-heading);
    font-family: var(--font-mono);
    font-size: 26px;
    line-height: 32px;
    font-weight: 700;
}
.r-otp__box.is-current { border-color: var(--color-action-primary); box-shadow: 0 0 0 1px var(--color-action-primary); }
.r-otp.is-enhanced .r-otp__boxes { display: flex; }
.r-otp.is-enhanced .r-otp__input {
    position: absolute;
    inset: 0;
    z-index: 1;
    width: 100%;
    height: 100%;
    opacity: 0;
    cursor: text;
}

.r-rules { display: flex; flex-direction: column; gap: 6px; margin: 0; padding: 0; list-style: none; }
.r-rule { display: flex; align-items: center; gap: var(--spacing-sm); font-size: 12px; line-height: 18px; color: var(--color-text-muted); }
.r-rule__mark { display: inline-flex; flex: none; width: 14px; height: 14px; border: 1.5px solid var(--color-border-strong); border-radius: 50%; }
.r-rule__mark .r-icon { display: none; margin: -1.5px; }
.r-rule.is-met { color: var(--color-text-primary); }
.r-rule.is-met .r-rule__mark { border-color: transparent; color: var(--color-status-success-text); }
.r-rule.is-met .r-rule__mark .r-icon { display: block; }

/* Below this width the headline and sub line wrap to two lines each. */
@media (max-width: 1280px) {
    .r-auth__phones { --phones-min: 270px; }
}

/* ---- Phone (390 frames): top bar plus bottom tab bar ---- */
@media (max-width: 860px) {
    .r-mobile-only { display: revert !important; }
    .r-desktop-only { display: none !important; }

    html, body { overflow-x: clip; }

    .r-shell { background: var(--color-bg-page); }
    .r-app { display: block; height: auto; overflow: visible; background: var(--color-bg-page); }
    .r-sidebar { display: none; }

    .r-topbar {
        position: sticky;
        top: 0;
        z-index: 20;
        display: flex;
        align-items: center;
        gap: 10px;
        padding: 14px 16px 12px;
        background: var(--color-bg-nav);
    }
    .r-topbar__brand { display: block; margin-right: auto; }
    .r-topbar__brand img { display: block; width: 108px; height: 23px; }

    .r-panel { display: block; min-height: 0; margin: 0; overflow: visible; border-radius: 0; padding-bottom: calc(var(--tabbar-height) + env(safe-area-inset-bottom)); }
    .r-main { gap: 14px; padding: 18px 16px 20px; }
    .r-footer { padding: 0 16px 16px; }

    .r-page-title { font-size: 20px; line-height: 28px; }
    .r-page-header { min-height: 0; }

    .r-tabbar {
        position: fixed;
        right: 0;
        bottom: 0;
        left: 0;
        z-index: 30;
        display: flex;
        padding: 8px 6px calc(14px + env(safe-area-inset-bottom));
        background: var(--color-bg-nav);
    }
    .r-tabbar__item {
        position: relative;
        display: flex;
        flex: 1 1 0;
        flex-direction: column;
        align-items: center;
        gap: 3px;
        min-width: 0;
        color: var(--color-text-on-nav);
        font-size: 10px;
        line-height: 13px;
        font-weight: 500;
    }
    .r-tabbar__item:hover, .r-tabbar__item:focus { color: var(--color-text-on-nav); text-decoration: none; }
    .r-tabbar__label { opacity: .7; }
    .r-tabbar__item.is-active .r-tabbar__label { opacity: 1; }
    .r-tabbar__item.is-active .r-icon { color: var(--color-action-primary); }
    .r-tabbar__item .r-count { position: absolute; top: -5px; left: calc(50% + 4px); min-width: 16px; padding: 0 4px; font-size: 10px; line-height: 14px; }

    .r-toast-region { bottom: calc(var(--tabbar-height) + 12px + env(safe-area-inset-bottom)); }
    .r-auth .r-toast-region { bottom: 16px; }

    .r-columns { grid-template-columns: minmax(0, 1fr); }
    .r-search { min-width: 0; width: 100%; }

    .r-banner { flex-wrap: wrap; }

    /* Row on a phone: icon, title on top, pill and meta below. Value, time and menu drop out. */
    .r-row {
        display: grid;
        grid-template-columns: 18px auto minmax(0, 1fr);
        column-gap: 8px;
        row-gap: 3px;
        align-items: center;
        min-height: 0;
        padding: 12px 14px;
    }
    .r-row__icon { grid-row: 1 / span 2; width: 18px; height: 18px; margin-right: 4px; border-radius: 0; background: transparent; }
    .r-row__text { display: contents; }
    .r-row__title { grid-column: 2 / -1; }
    .r-row__meta { grid-column: 3; grid-row: 2; }
    .r-row .r-pill { grid-column: 2; grid-row: 2; }
    .r-row__value, .r-row__when, .r-row__more { display: none; }
    .r-row--no-pill .r-row__meta { grid-column: 2 / -1; }

    /* Sign-in on a phone: brand hero first, form below it. */
    .r-auth { flex-direction: column; gap: 14px; }
    .r-auth__brand { order: -1; flex: 0 0 336px; width: 100%; padding: 28px 24px 22px; background: radial-gradient(50% 50% at 40% 40%, rgba(128, 80, 200, .45), rgba(128, 80, 200, 0)), #0c0d31; }
    .r-auth__logo { margin-bottom: 16px; }
    .r-auth__slogan { margin: 0; font-size: 20px; line-height: 28px; }
    .r-auth__sub, .r-phone--workshops { display: none; }
    .r-phone--profile {
        left: 50%;
        top: 148px;
        width: 240px;
        height: 520px;
        margin-left: -120px;
        border-width: 4px;
        border-color: #35446e;
        border-radius: 26px;
        box-shadow: none;
        transform: none;
    }
    .r-auth__side { flex: 1 0 auto; align-items: stretch; justify-content: flex-start; padding: 14px 24px 32px; }
    .r-auth__form { gap: 14px; max-width: none; }
    .r-auth__form .r-form { gap: 14px; }
    .r-auth__title { gap: 14px; }
    .r-auth__row { justify-content: flex-start; }
}

/* iOS zooms into any field under 16px on focus. */
@media (pointer: coarse) {
    .r-input, .r-textarea, .r-select { font-size: 16px; }
}

@media (prefers-reduced-motion: reduce) {
    * { animation: none !important; transition: none !important; }
}
