/* =====================================================================
   RacioFlow — Core design system
   Racio Media Group · Namibia

   The palette is taken from the Racio Media Group logo: signal red on
   black and charcoal, with generous white space.
   ================================================================== */

@font-face {
    font-family: "Inter";
    src: url("../fonts/inter-variable.ttf") format("truetype");
    font-style: normal;
    font-weight: 100 900;
    font-display: swap;
}
@font-face {
    font-family: "Inter";
    src: url("../fonts/inter-variable-italic.ttf") format("truetype");
    font-style: italic;
    font-weight: 100 900;
    font-display: swap;
}

:root {
    /* --- Brand ------------------------------------------------------ */
    --racio-red:        #E50305;
    --racio-red-dark:   #B90204;
    --racio-red-hover:  #C90204;
    --racio-red-soft:   #FFF1F1;

    --racio-black:      #000000;
    --racio-charcoal:   #5A5456;
    --racio-dark:       #181818;
    --racio-white:      #FFFFFF;

    --racio-gray-50:    #FAFAFA;
    --racio-gray-100:   #F5F5F5;
    --racio-gray-200:   #E9EAEC;
    --racio-gray-300:   #D4D4D4;
    --racio-gray-400:   #A3A3A3;
    --racio-gray-500:   #737373;
    --racio-gray-700:   #404040;
    --racio-gray-900:   #171717;

    /* --- Semantic surfaces ------------------------------------------ */
    --background:        #F4F4F5;
    --surface:           #FFFFFF;
    --surface-secondary: #FAFAFA;
    --surface-hover:     #F5F5F5;
    --surface-sunken:    #F0F0F1;

    --text-primary:   #171717;
    --text-secondary: #5A5456;
    --text-muted:     #6B6B6B;
    --text-inverse:   #FFFFFF;

    --border-color:   #E5E5E5;
    --border-strong:  #D4D4D4;

    --primary:        #E50305;
    --primary-hover:  #C90204;
    --primary-soft:   #FFF1F1;
    --primary-contrast:#FFFFFF;

    /* --- Sidebar ---------------------------------------------------- */
    --sidebar-background: #111111;
    --sidebar-background-deep: #080808;
    --sidebar-background-bright: #181818;
    --sidebar-accent:     #E50305;
    --sidebar-accent-glow:rgba(229,3,5,.18);
    --sidebar-decor:      rgba(229,3,5,.28);
    --sidebar-surface:    rgba(255,255,255,.055);
    --sidebar-text:       #FFFFFF;
    --sidebar-muted:      #9A9A9A;
    --sidebar-item:       #D7D7D7;
    --sidebar-active:     #E50305;
    --sidebar-active-soft:#B90204;
    --sidebar-active-text:#FFFFFF;
    --sidebar-border:     rgba(255,255,255,.10);
    --sidebar-hover:      rgba(255,255,255,.10);
    --sidebar-glow:       rgba(229,3,5,.12);
    --sidebar-edge:       rgba(255,255,255,.12);
    --sidebar-tile:       rgba(255,255,255,.055);
    --sidebar-tile-end:   rgba(255,255,255,.025);
    --sidebar-tile-border:rgba(255,255,255,.08);
    --sidebar-tile-shadow:0 8px 20px rgba(0,0,0,.16);
    --sidebar-hover-shadow:0 12px 26px rgba(0,0,0,.24), 0 5px 14px rgba(229,3,5,.08);
    --sidebar-active-shadow:0 13px 28px rgba(0,0,0,.30), 0 5px 16px rgba(229,3,5,.22);
    --sidebar-footer:     rgba(255,255,255,.025);
    --sidebar-user-hover: rgba(255,255,255,.08);
    --sidebar-float-shadow: 0 24px 60px rgba(0,0,0,.26), 0 8px 26px rgba(229,3,5,.08);

    /* --- Status ----------------------------------------------------- */
    --success:      #171717;
    --success-soft: #F1F1F1;
    --success-contrast:#FFFFFF;
    --warning:      #5A5456;
    --warning-soft: #F5F5F5;
    --warning-contrast:#FFFFFF;
    --danger:       #E50305;
    --danger-soft:  #FFF5F5;
    --info:         #404040;
    --info-soft:    #F1F1F1;

    /* --- Shape & motion --------------------------------------------- */
    --radius-sm: 6px;
    --radius:    10px;
    --radius-lg: 14px;
    --radius-xl: 18px;
    --radius-pill: 999px;

    /* --- Spacing scale --------------------------------------------- */
    --space-xs:   2px;
    --space-sm:   4px;
    --space-md:   8px;
    --space-lg:   12px;
    --space-xl:   16px;
    --space-2xl:  24px;
    --space-3xl:  32px;

    --shadow-xs: 0 1px 2px rgba(0,0,0,.05);
    --shadow-sm: 0 2px 10px rgba(0,0,0,.04);
    --shadow:    0 6px 24px rgba(0,0,0,.07);
    --shadow-lg: 0 18px 48px rgba(0,0,0,.14);

    --sidebar-width: 138px;
    --sidebar-gap: 12px;
    --topbar-height: 56px;

    --font-sans: "Inter", "Segoe UI Variable Text", "Segoe UI", system-ui,
                 -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
    --font-mono: "Inter", "Segoe UI", system-ui, sans-serif;

    --transition: 160ms cubic-bezier(.4,0,.2,1);
}

:root[data-theme="dark"] {
    color-scheme: dark;
    --background:        #0F0F0F;
    --surface:           #171717;
    --surface-secondary: #1E1E1E;
    --surface-hover:     #232323;
    --surface-sunken:    #121212;

    --text-primary:   #FFFFFF;
    --text-secondary: #B5B5B5;
    --text-muted:     #8C8C8C;

    --border-color:   #2C2C2C;
    --border-strong:  #3A3A3A;

    --primary-soft:   rgba(229,3,5,.14);

    --sidebar-background: #111111;
    --sidebar-background-deep: #080808;
    --sidebar-background-bright: #181818;
    --sidebar-accent:     #E50305;
    --sidebar-accent-glow:rgba(229,3,5,.20);
    --sidebar-decor:      rgba(229,3,5,.28);
    --sidebar-surface:    rgba(255,255,255,.055);
    --sidebar-text:       #FFFFFF;
    --sidebar-muted:      #9A9A9A;
    --sidebar-item:       #D7D7D7;
    --sidebar-active:     #E50305;
    --sidebar-active-soft:#B90204;
    --sidebar-active-text:#FFFFFF;
    --sidebar-border:     rgba(255,255,255,.10);
    --sidebar-hover:      rgba(255,255,255,.10);
    --sidebar-glow:       rgba(229,3,5,.12);
    --sidebar-edge:       rgba(255,255,255,.12);
    --sidebar-tile:       rgba(255,255,255,.055);
    --sidebar-tile-end:   rgba(255,255,255,.025);
    --sidebar-tile-border:rgba(255,255,255,.08);
    --sidebar-tile-shadow:0 9px 22px rgba(0,0,0,.22);
    --sidebar-hover-shadow:0 13px 28px rgba(0,0,0,.28), 0 5px 14px rgba(229,3,5,.10);
    --sidebar-active-shadow:0 14px 30px rgba(0,0,0,.30), 0 6px 16px rgba(229,3,5,.20);
    --sidebar-footer:     rgba(255,255,255,.025);
    --sidebar-user-hover: rgba(255,255,255,.08);
    --sidebar-float-shadow: 0 26px 64px rgba(0,0,0,.40), 0 8px 28px rgba(229,3,5,.10);

    --success:      #F5F5F5;
    --success-soft: rgba(255,255,255,.08);
    --success-contrast:#171717;
    --warning:      #A3A3A3;
    --warning-soft: rgba(255,255,255,.10);
    --warning-contrast:#171717;
    --danger:       #FF5A5C;
    --danger-soft:  rgba(229,3,5,.18);
    --info:         #B5B5B5;
    --info-soft:    rgba(255,255,255,.07);

    --shadow-xs: 0 1px 2px rgba(0,0,0,.5);
    --shadow-sm: 0 2px 10px rgba(0,0,0,.4);
    --shadow:    0 6px 24px rgba(0,0,0,.5);
    --shadow-lg: 0 18px 48px rgba(0,0,0,.6);
}

:root[data-theme="light"] { color-scheme: light; }

/* =====================================================================
   Reset & base
   ================================================================== */

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

html { -webkit-text-size-adjust: 100%; }

body {
    margin: 0;
    font-family: var(--font-sans);
    font-optical-sizing: auto;
    font-size: 15px;
    line-height: 1.55;
    color: var(--text-primary);
    background: var(--background);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    font-synthesis: style;
}

button, input, optgroup, select, textarea { font-family: inherit; }

h1, h2, h3, h4, h5, h6 { margin: 0 0 .5rem; font-weight: 650; line-height: 1.25; letter-spacing: -.01em; }
h1 { font-size: 1.75rem; }
h2 { font-size: 1.3rem; }
h3 { font-size: 1.05rem; }
h4 { font-size: .95rem; }
p  { margin: 0 0 .75rem; }
a  { color: var(--primary); text-decoration: none; transition: color var(--transition); }
a:hover { color: var(--primary-hover); }
img, svg, video { max-width: 100%; }
img { height: auto; }
hr { border: 0; border-top: 1px solid var(--border-color); margin: 1.25rem 0; }
code, kbd, pre { font-family: var(--font-mono); font-size: .875em; }
small { font-size: .8125rem; }
::selection { background: rgba(229,3,5,.18); }

:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
    border-radius: 4px;
}

.rf-icon { flex: none; display: inline-block; vertical-align: middle; }

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

/* =====================================================================
   App shell
   ================================================================== */

.rf-app { display: flex; min-height: 100vh; }

.rf-sidebar {
    position: fixed;
    inset: var(--sidebar-gap) auto var(--sidebar-gap) var(--sidebar-gap);
    width: var(--sidebar-width);
    background:
        radial-gradient(circle at 8% 5%, var(--sidebar-accent-glow), transparent 28%),
        radial-gradient(circle at 92% 68%, var(--sidebar-glow), transparent 34%),
        linear-gradient(158deg, var(--sidebar-background-bright) 0%, var(--sidebar-background) 42%, var(--sidebar-background-deep) 100%);
    color: var(--sidebar-text);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    z-index: 60;
    border: 1px solid var(--sidebar-edge);
    border-radius: 22px;
    box-shadow: var(--sidebar-float-shadow), inset 0 1px 0 rgba(255,255,255,.08);
    -webkit-backdrop-filter: blur(20px) saturate(145%);
    backdrop-filter: blur(20px) saturate(145%);
    transition: transform var(--transition), box-shadow var(--transition);
}
@supports not (backdrop-filter: blur(2px)) {
    .rf-sidebar { background: var(--sidebar-background-bright); }
}
.rf-sidebar::after {
    position: absolute;
    z-index: 2;
    inset: 22px auto 22px 0;
    width: 3px;
    border-radius: 0 var(--radius-pill) var(--radius-pill) 0;
    background: linear-gradient(180deg, transparent, var(--sidebar-accent) 18%, var(--sidebar-accent) 82%, transparent);
    box-shadow: 0 0 18px var(--sidebar-accent-glow);
    content: "";
    pointer-events: none;
}

.rf-sidebar-decor {
    position: absolute;
    z-index: 0;
    inset: 0;
    overflow: hidden;
    pointer-events: none;
}
.rf-sidebar-decor::before,
.rf-sidebar-decor::after {
    position: absolute;
    border-radius: 50%;
    background: var(--sidebar-surface);
    box-shadow: inset 0 1px 0 rgba(255,255,255,.08), 0 16px 34px rgba(0,0,0,.22);
    content: "";
}
.rf-sidebar-decor::before {
    top: 7%;
    left: -34px;
    width: 74px;
    height: 74px;
}
.rf-sidebar-decor::after {
    right: -28px;
    bottom: 4%;
    width: 66px;
    height: 66px;
}
.rf-sidebar-shape { position: absolute; display: block; }
.rf-sidebar-shape.is-ring {
    top: 17%;
    right: -52px;
    width: 112px;
    height: 112px;
    border: 2px solid var(--sidebar-decor);
    border-radius: 50%;
    box-shadow: 0 0 34px var(--sidebar-glow), inset 0 0 22px var(--sidebar-glow);
    opacity: .78;
}
.rf-sidebar-shape.is-diamond {
    top: 48%;
    left: -43px;
    width: 88px;
    height: 88px;
    border: 1px solid var(--sidebar-decor);
    border-radius: var(--radius-lg);
    background: linear-gradient(145deg, var(--sidebar-accent-glow), var(--sidebar-surface));
    box-shadow: 0 14px 34px rgba(0,0,0,.24), inset 0 1px 0 rgba(255,255,255,.08);
    opacity: .72;
    transform: rotate(38deg);
}
.rf-sidebar-shape.is-dots {
    right: -12px;
    bottom: 13%;
    width: 102px;
    height: 126px;
    background-image: radial-gradient(circle, var(--sidebar-decor) 1.3px, transparent 1.5px);
    background-size: 14px 14px;
    opacity: .50;
    -webkit-mask-image: linear-gradient(135deg, transparent 2%, #000 45%, transparent 94%);
    mask-image: linear-gradient(135deg, transparent 2%, #000 45%, transparent 94%);
}
.rf-sidebar-brand,
.rf-sidebar-nav,
.rf-sidebar-foot {
    position: relative;
    z-index: 1;
}

.rf-sidebar-brand {
    display: flex;
    align-items: center;
    gap: .7rem;
    padding: 1.1rem 1.15rem 1rem;
    border-bottom: 1px solid var(--sidebar-border);
    min-height: var(--topbar-height);
}
.rf-sidebar-brand img { height: 42px; width: 58px; object-fit: contain; display: block; padding: 2px; background: var(--primary-contrast); border: 1px solid rgba(255,255,255,.42); border-radius: 9px; box-shadow: 0 7px 18px rgba(0,0,0,.32), 0 0 16px rgba(229,3,5,.12); }
.rf-sidebar-brand .rf-brand-text { display: flex; flex-direction: column; line-height: 1.15; min-width: 0; }
.rf-sidebar-brand .rf-brand-name {
    font-size: 1.02rem; font-weight: 700; letter-spacing: -.02em; color: var(--sidebar-text);
}
.rf-sidebar-brand .rf-brand-sub {
    font-size: .625rem; text-transform: uppercase; letter-spacing: .12em;
    color: var(--sidebar-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

.rf-sidebar-nav {
    flex: 1;
    overflow-y: auto;
    padding: .85rem .7rem 1rem;
    scrollbar-width: thin;
    scrollbar-color: var(--sidebar-border) transparent;
}
.rf-sidebar-nav::-webkit-scrollbar { width: 6px; }
.rf-sidebar-nav::-webkit-scrollbar-button { display: none; width: 0; height: 0; }
.rf-sidebar-nav::-webkit-scrollbar-track { background: transparent; }
.rf-sidebar-nav::-webkit-scrollbar-thumb { background: var(--sidebar-border); border-radius: 3px; }

.rf-nav-section {
    padding: 1.1rem .65rem .4rem;
    font-size: .625rem;
    font-weight: 700;
    letter-spacing: .14em;
    text-transform: uppercase;
    color: var(--sidebar-muted);
}

.rf-nav-item {
    display: flex;
    align-items: center;
    gap: .7rem;
    padding: .58rem .7rem;
    margin-bottom: 2px;
    border-radius: var(--radius);
    background: linear-gradient(145deg, var(--sidebar-tile), var(--sidebar-tile-end));
    color: var(--sidebar-item);
    font-size: .875rem;
    font-weight: 500;
    border: 1px solid var(--sidebar-tile-border);
    border-left: 3px solid transparent;
    box-shadow: var(--sidebar-tile-shadow), inset 0 1px 0 rgba(255,255,255,.06);
    transition: background var(--transition), border-color var(--transition),
                box-shadow var(--transition), color var(--transition), transform var(--transition);
    position: relative;
}
.rf-nav-item::before {
    position: absolute;
    top: 1px;
    right: 10px;
    left: 10px;
    height: 1px;
    border-radius: var(--radius-pill);
    background: linear-gradient(90deg, transparent, rgba(255,255,255,.18), transparent);
    content: "";
    pointer-events: none;
}
.rf-nav-item:hover {
    border-color: rgba(229,3,5,.32);
    background: linear-gradient(145deg, var(--sidebar-hover), var(--sidebar-surface));
    box-shadow: var(--sidebar-hover-shadow), inset 0 1px 0 rgba(255,255,255,.10);
    color: var(--sidebar-text);
    transform: translateY(-2px);
}
.rf-nav-item.is-active {
    background: linear-gradient(145deg, var(--sidebar-active), var(--sidebar-active-soft));
    color: var(--sidebar-active-text);
    border-color: rgba(255,255,255,.24);
    box-shadow: var(--sidebar-active-shadow), inset 0 1px 0 rgba(255,255,255,.18);
    font-weight: 600;
}
.rf-nav-item .rf-icon {
    border-radius: var(--radius-sm);
    opacity: .9;
    transition: color var(--transition), transform var(--transition),
                background var(--transition), box-shadow var(--transition), filter var(--transition);
}
.rf-nav-item.is-active .rf-icon {
    background: rgba(255,255,255,.16);
    box-shadow: 0 0 0 5px rgba(255,255,255,.10);
    color: var(--sidebar-active-text);
    filter: none;
    opacity: 1;
}
.rf-nav-item:active .rf-icon { transform: scale(.92); }
.rf-nav-label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.rf-nav-badge {
    min-width: 20px;
    height: 20px;
    padding: 0 6px;
    border-radius: var(--radius-pill);
    background: var(--racio-red);
    color: #fff;
    font-size: .6875rem;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.rf-sidebar-foot {
    border-top: 1px solid var(--sidebar-border);
    padding: .75rem;
}
.rf-sidebar-user {
    display: flex; align-items: center; gap: .65rem;
    padding: .5rem .6rem; border-radius: var(--radius-sm);
    color: var(--sidebar-text); transition: background var(--transition), box-shadow var(--transition);
}
.rf-sidebar-user:hover { background: var(--sidebar-user-hover); color: var(--sidebar-text); box-shadow: var(--sidebar-tile-shadow); }
.rf-sidebar-user .rf-su-meta { min-width: 0; flex: 1; display: flex; flex-direction: column; }
.rf-sidebar-user .rf-su-name { font-size: .8125rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rf-sidebar-user .rf-su-role { font-size: .6875rem; color: var(--sidebar-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.rf-sidebar-backdrop {
    display: none;
    position: fixed; inset: 0;
    background: rgba(0,0,0,.5);
    z-index: 55;
    backdrop-filter: blur(2px);
}

/* --- Main column ---------------------------------------------------- */

.rf-main {
    flex: 1;
    min-width: 0;
    margin-left: calc(var(--sidebar-width) + 24px);
    display: flex;
    flex-direction: column;
    transition: margin-left var(--transition);
}

@media (min-width: 901px) {
    .rf-sidebar-brand {
        min-height: 94px;
        flex-direction: column;
        justify-content: center;
        gap: .45rem;
        padding: .7rem .55rem .65rem;
        overflow: hidden;
    }
    .rf-sidebar-brand img {
        width: 62px;
        height: 44px;
    }
    .rf-sidebar-brand .rf-brand-text {
        display: flex;
        align-items: center;
        max-width: 100%;
    }
    .rf-sidebar-brand .rf-brand-name {
        font-size: .8rem;
        letter-spacing: .01em;
    }
    .rf-sidebar-brand .rf-brand-sub {
        display: none;
    }
    .rf-sidebar-nav {
        padding: .5rem .45rem .85rem;
    }
    .rf-nav-section {
        display: flex;
        align-items: center;
        gap: .35rem;
        margin: .72rem .15rem .3rem;
        padding: 0;
        color: var(--sidebar-muted);
        font-size: .625rem;
        line-height: 1.2;
        text-align: center;
    }
    .rf-nav-section::before,
    .rf-nav-section::after {
        flex: 1;
        height: 1px;
        background: linear-gradient(90deg, transparent, var(--sidebar-edge));
        content: "";
    }
    .rf-nav-section::after {
        background: linear-gradient(90deg, var(--sidebar-edge), transparent);
    }
    .rf-nav-item {
        min-height: 64px;
        flex-direction: column;
        justify-content: center;
        gap: .32rem;
        padding: .5rem .35rem;
        border: 1px solid var(--sidebar-tile-border);
        border-radius: var(--radius);
        margin-bottom: .36rem;
        background: linear-gradient(145deg, var(--sidebar-tile), var(--sidebar-tile-end));
        box-shadow: var(--sidebar-tile-shadow), inset 0 1px 0 rgba(255,255,255,.06);
        text-align: center;
        transition: background var(--transition), border-color var(--transition),
                    box-shadow var(--transition), color var(--transition), transform var(--transition);
    }
    .rf-nav-item .rf-icon {
        width: 22px;
        height: 22px;
        transition: color var(--transition), transform var(--transition),
                    background var(--transition), box-shadow var(--transition), filter var(--transition);
    }
    .rf-nav-item:hover {
        border-color: rgba(229,3,5,.34);
        box-shadow: var(--sidebar-hover-shadow), inset 0 1px 0 rgba(255,255,255,.10);
        transform: translateY(-2px);
    }
    .rf-nav-item:hover .rf-icon { transform: scale(1.08); }
    .rf-nav-label {
        display: -webkit-box;
        flex: none;
        width: 100%;
        overflow: hidden;
        color: inherit;
        font-size: .75rem;
        font-weight: 600;
        line-height: 1.2;
        text-align: center;
        overflow-wrap: anywhere;
        text-overflow: clip;
        -webkit-box-orient: vertical;
        -webkit-line-clamp: 2;
        white-space: normal;
    }
    .rf-nav-item.is-active {
        min-height: 68px;
        gap: .34rem;
        border-color: rgba(255,255,255,.24);
        background: linear-gradient(145deg, var(--sidebar-active), var(--sidebar-active-soft));
        box-shadow: var(--sidebar-active-shadow), inset 0 1px 0 rgba(255,255,255,.18);
        animation: rf-nav-active-in 220ms ease-out;
    }
    .rf-nav-item.is-active .rf-nav-label {
        color: var(--sidebar-active-text);
        font-weight: 700;
    }
    .rf-nav-item.is-active .rf-icon {
        background: rgba(255,255,255,.16);
        box-shadow: 0 0 0 5px rgba(255,255,255,.10);
        color: var(--sidebar-active-text);
        filter: none;
    }
    .rf-nav-item.is-active::after {
        position: absolute;
        top: 8px;
        right: 8px;
        width: 6px;
        height: 6px;
        border-radius: 50%;
        background: #22C55E;
        box-shadow: 0 0 0 4px rgba(34,197,94,.18);
        content: "";
    }
    .rf-nav-item.is-active.has-nav-badge::after {
        display: none;
    }
    .rf-nav-badge {
        position: absolute;
        z-index: 2;
        top: 5px;
        right: 5px;
        min-width: 20px;
        height: 20px;
        padding: 0 5px;
        border: 2px solid var(--primary-contrast);
        box-shadow: 0 2px 7px rgba(0,0,0,.24);
        font-size: .625rem;
        line-height: 1;
    }
    .rf-sidebar-foot {
        padding: .6rem .45rem;
        background: var(--sidebar-footer);
    }
    .rf-sidebar-user {
        min-height: 68px;
        flex-direction: column;
        justify-content: center;
        gap: .35rem;
        padding: .5rem .3rem;
        text-align: center;
    }
    .rf-sidebar-user .rf-su-meta {
        display: flex;
        width: 100%;
        flex-direction: column;
        align-items: center;
    }
    .rf-sidebar-user .rf-su-name {
        width: 100%;
        font-size: .75rem;
    }
    .rf-sidebar-user .rf-su-role {
        width: 100%;
        font-size: .625rem;
    }
    .rf-nav-item:focus-visible,
    .rf-sidebar-user:focus-visible,
    .rf-sidebar-brand:focus-visible {
        outline: none;
        box-shadow: 0 0 0 2px var(--sidebar-background-bright), 0 0 0 4px var(--primary);
    }
}

@keyframes rf-nav-active-in {
    from { opacity: .65; transform: translateX(-4px); }
    to { opacity: 1; transform: none; }
}
.rf-sidebar-tooltip {
    position: fixed;
    z-index: 100;
    max-width: 220px;
    padding: .42rem .65rem;
    border: 1px solid rgba(229,3,5,.32);
    border-left: 3px solid var(--primary);
    border-radius: var(--radius-sm);
    background: #171717;
    color: #fff;
    font-size: .72rem;
    font-weight: 650;
    line-height: 1.25;
    white-space: nowrap;
    box-shadow: 0 10px 30px rgba(0,0,0,.24);
    opacity: 0;
    pointer-events: none;
    transform: translateX(-5px) translateY(-50%);
    transition: opacity 120ms ease, transform 120ms ease;
}
.rf-sidebar-tooltip.is-visible {
    opacity: 1;
    transform: translateX(0) translateY(-50%);
}

.rf-topbar {
    position: sticky;
    top: 0;
    z-index: 45;
    height: var(--topbar-height);
    display: flex;
    align-items: center;
    gap: .75rem;
    padding: 0 1.15rem;
    background: color-mix(in srgb, var(--surface) 94%, transparent);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--border-color);
}
@supports not (backdrop-filter: blur(2px)) {
    .rf-topbar { background: var(--surface); }
}

.rf-topbar-title { display: none; }

.rf-topbar-logo {
    display: block;
    flex: none;
    width: 32px; height: 32px;
    border-radius: var(--radius-sm);
    overflow: hidden;
    flex-shrink: 0;
}
.rf-topbar-logo img { width: 100%; height: 100%; object-fit: contain; display: block; }

.rf-icon-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px; height: 40px;
    border-radius: var(--radius-sm);
    border: 1px solid transparent;
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
    position: relative;
    transition: background var(--transition), color var(--transition);
}
.rf-icon-btn:hover { background: var(--surface-hover); color: var(--text-primary); }

.rf-menu-toggle { display: none; }

.rf-search {
    position: relative;
    flex: 1;
    max-width: 460px;
}
.rf-search input {
    width: 100%;
    height: 36px;
    padding: 0 .9rem 0 2.4rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-pill);
    background: var(--surface-secondary);
    color: var(--text-primary);
    font-size: .875rem;
    font-family: inherit;
    transition: border-color var(--transition), box-shadow var(--transition), background var(--transition);
}
.rf-search input::placeholder { color: var(--text-muted); }
.rf-search input:focus {
    outline: none;
    background: var(--surface);
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(229,3,5,.10);
}
.rf-search .rf-search-icon {
    position: absolute; left: .8rem; top: 50%; transform: translateY(-50%);
    color: var(--text-muted); pointer-events: none;
}
.rf-search-results {
    position: absolute; top: calc(100% + 8px); left: 0; right: 0;
    background: var(--surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    max-height: 60vh; overflow-y: auto;
    padding: .35rem;
    display: none;
    z-index: 70;
}
.rf-search-results.is-open { display: block; }
.rf-search-group-title {
    padding: .5rem .65rem .3rem; font-size: .625rem; font-weight: 700;
    text-transform: uppercase; letter-spacing: .1em; color: var(--text-muted);
}
.rf-search-item {
    display: flex; gap: .65rem; align-items: center;
    padding: .5rem .65rem; border-radius: var(--radius-sm);
    color: var(--text-primary);
}
.rf-search-item:hover, .rf-search-item.is-active { background: var(--surface-hover); color: var(--text-primary); }
.rf-search-item .rf-si-main { min-width: 0; flex: 1; }
.rf-search-item .rf-si-title { font-size: .875rem; font-weight: 550; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rf-search-item .rf-si-sub { font-size: .75rem; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.rf-topbar-spacer { flex: 1; }
.rf-topbar-actions { display: flex; align-items: center; gap: .3rem; }

.rf-dot {
    position: absolute; top: 7px; right: 7px;
    min-width: 17px; height: 17px; padding: 0 4px;
    border-radius: var(--radius-pill);
    background: var(--racio-red); color: #fff;
    font-size: .625rem; font-weight: 700; line-height: 17px;
    text-align: center;
    border: 2px solid var(--surface);
}

/* --- Dropdowns ------------------------------------------------------ */

.rf-dropdown { position: relative; }
.rf-dropdown-panel {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    min-width: 260px;
    background: var(--surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    padding: .35rem;
    display: none;
    z-index: 80;
    animation: rf-pop 140ms ease-out;
}
.rf-dropdown-panel.is-open { display: block; }
@keyframes rf-pop { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: none; } }

.rf-dropdown-head {
    display: flex; align-items: center; justify-content: space-between;
    gap: .5rem; padding: .55rem .7rem .5rem;
    border-bottom: 1px solid var(--border-color); margin-bottom: .3rem;
}
.rf-dropdown-head h4 { margin: 0; font-size: .8125rem; font-weight: 650; }
.rf-dropdown-item {
    display: flex; align-items: center; gap: .6rem;
    padding: .55rem .7rem; border-radius: var(--radius-sm);
    color: var(--text-primary); font-size: .875rem;
    width: 100%; background: none; border: 0; text-align: left;
    font-family: inherit; cursor: pointer;
}
.rf-dropdown-item:hover { background: var(--surface-hover); color: var(--text-primary); }
.rf-dropdown-item.is-danger { color: var(--danger); }
.rf-dropdown-item.is-danger:hover { background: var(--danger-soft); }
.rf-dropdown-sep { height: 1px; background: var(--border-color); margin: .3rem 0; }
.rf-dropdown-foot { padding: .3rem; border-top: 1px solid var(--border-color); margin-top: .3rem; }
.rf-device-alerts {
    display: flex; align-items: center; gap: .55rem; margin: .15rem .15rem .35rem; padding: .65rem .7rem;
    border: 1px solid color-mix(in srgb, var(--racio-red) 18%, var(--border-color));
    border-radius: var(--radius-md); background: linear-gradient(135deg, var(--primary-soft), var(--surface));
}
.rf-device-alerts-icon {
    display: grid; place-items: center; width: 30px; height: 30px; flex: none;
    border-radius: 9px; background: var(--racio-red); color: #fff;
}
.rf-device-alerts-copy { display: flex; flex: 1; min-width: 0; flex-direction: column; line-height: 1.25; }
.rf-device-alerts-copy strong { font-size: .75rem; color: var(--text-primary); }
.rf-device-alerts-copy span { font-size: .6875rem; color: var(--text-muted); }
.rf-device-alerts .rf-btn-link { flex: none; font-size: .72rem; }

.rf-notif-list { max-height: 62vh; overflow-y: auto; }
.rf-notif {
    display: flex; gap: .65rem; padding: .6rem .7rem;
    border-radius: var(--radius-sm); color: var(--text-primary);
}
.rf-notif:hover { background: var(--surface-hover); color: var(--text-primary); }
.rf-notif.is-unread { background: var(--primary-soft); }
.rf-notif.is-unread:hover { background: color-mix(in srgb, var(--primary-soft) 70%, var(--surface-hover)); }
.rf-notif-icon {
    width: 34px; height: 34px; flex: none; border-radius: var(--radius-sm);
    display: grid; place-items: center;
    background: var(--surface-sunken); color: var(--text-secondary);
}
.rf-notif.is-unread .rf-notif-icon { background: rgba(229,3,5,.14); color: var(--racio-red); }
.rf-notif-body { min-width: 0; flex: 1; }
.rf-notif-title { font-size: .8125rem; font-weight: 600; }
.rf-notif-text  { font-size: .75rem; color: var(--text-secondary); }
.rf-notif-time  { font-size: .6875rem; color: var(--text-muted); margin-top: 2px; }

/* --- Content -------------------------------------------------------- */

.rf-content {
    width: 100%; min-width: 0; padding: 1.5rem 1.5rem 3rem; flex: 1;
    background-image:
        linear-gradient(rgba(229,3,5,.025) 1px, transparent 1px),
        linear-gradient(90deg, rgba(229,3,5,.025) 1px, transparent 1px);
    background-size: 48px 48px;
}
:root[data-theme="dark"] .rf-content {
    background-image:
        linear-gradient(rgba(255,255,255,.018) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255,255,255,.018) 1px, transparent 1px);
}
.rf-content-wide { max-width: none; }

.rf-page-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
    margin-bottom: 1.25rem;
}
.rf-page-head > div:first-child::before {
    display: block;
    width: 34px;
    height: 3px;
    margin-bottom: .55rem;
    border-radius: var(--radius-pill);
    background: var(--racio-red);
    box-shadow: 0 0 14px rgba(229,3,5,.24);
    content: "";
}
.rf-page-title { font-size: 1.65rem; font-weight: 700; letter-spacing: -.022em; margin: 0; }
.rf-page-subtitle { color: var(--text-secondary); font-size: .875rem; margin: .2rem 0 0; }
.rf-page-actions { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; }

.rf-breadcrumb { display: flex; align-items: center; gap: .35rem; font-size: .75rem; color: var(--text-muted); margin-bottom: .35rem; flex-wrap: wrap; }
.rf-breadcrumb a { color: var(--text-muted); }
.rf-breadcrumb a:hover { color: var(--primary); }

/* =====================================================================
   Cards & panels
   ================================================================== */

.rf-card {
    background: var(--surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm), inset 0 1px 0 rgba(255,255,255,.34);
}
:root[data-theme="dark"] .rf-card { box-shadow: var(--shadow-sm), inset 0 1px 0 rgba(255,255,255,.055); }
.rf-card-head {
    display: flex; align-items: center; justify-content: space-between;
    gap: .75rem; flex-wrap: wrap;
    padding: 1rem 1.15rem;
    border-bottom: 1px solid var(--border-color);
}
.rf-card-head h2, .rf-card-head h3 { margin: 0; font-size: .95rem; font-weight: 650; }
.rf-card-head .rf-card-sub { font-size: .75rem; color: var(--text-muted); margin: 2px 0 0; }
.rf-card-body { padding: 1.15rem; }
.rf-card-body.is-flush { padding: 0; }
.rf-card-foot {
    padding: .85rem 1.15rem;
    border-top: 1px solid var(--border-color);
    background: var(--surface-secondary);
    border-radius: 0 0 var(--radius-lg) var(--radius-lg);
    display: flex; gap: .5rem; align-items: center; flex-wrap: wrap;
}

.rf-grid { display: grid; gap: 1rem; }
.rf-grid > * { min-width: 0; }
.rf-grid-2 { grid-template-columns: repeat(2, minmax(0,1fr)); }
.rf-grid-3 { grid-template-columns: repeat(3, minmax(0,1fr)); }
.rf-grid-4 { grid-template-columns: repeat(4, minmax(0,1fr)); }
.rf-grid-sidebar { grid-template-columns: minmax(0,1fr) 340px; align-items: start; }
.rf-grid-sidebar-left { grid-template-columns: 300px minmax(0,1fr); align-items: start; }

/* Shared people and relationship lists. These appear outside dashboards too. */
.rf-list {
    display: flex;
    flex-direction: column;
}
.rf-list-item {
    display: flex;
    align-items: center;
    gap: .75rem;
    min-width: 0;
    padding: .75rem 1.15rem;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-primary);
}
.rf-list-item:last-child { border-bottom: 0; }
a.rf-list-item:hover {
    background: var(--surface-hover);
    color: var(--text-primary);
}
.rf-list-main,
.rf-list-item .rf-si-main {
    display: flex;
    flex: 1;
    min-width: 0;
    flex-direction: column;
    gap: .1rem;
}
.rf-list-title,
.rf-list-item .rf-si-main strong {
    overflow: hidden;
    color: var(--text-primary);
    font-size: .875rem;
    font-weight: 650;
    line-height: 1.35;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.rf-list-sub,
.rf-list-item .rf-si-main small {
    overflow: hidden;
    color: var(--text-muted);
    font-size: .75rem;
    line-height: 1.35;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.rf-list-item > .rf-icon {
    flex: none;
    color: var(--text-muted);
}

/* New-message staff picker. */
.rf-contact-search {
    display: block;
    width: min(100%, 520px);
    max-width: 520px;
}
.rf-contact-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: .75rem;
}
.rf-contact-card {
    display: flex;
    align-items: center;
    gap: .75rem;
    min-width: 0;
    padding: .8rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    background: var(--surface);
    color: var(--text-primary);
    transition: border-color var(--transition), background var(--transition), transform var(--transition);
}
.rf-contact-card:hover {
    border-color: var(--primary);
    background: var(--primary-soft);
    color: var(--text-primary);
    transform: translateY(-1px);
}
.rf-contact-copy {
    display: flex;
    flex: 1;
    min-width: 0;
    flex-direction: column;
    gap: .15rem;
}
.rf-contact-copy strong,
.rf-contact-copy small {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.rf-contact-copy strong {
    color: var(--text-primary);
    font-size: .875rem;
    font-weight: 650;
}
.rf-contact-copy small {
    color: var(--text-muted);
    font-size: .75rem;
}
.rf-contact-action {
    display: grid;
    width: 34px;
    height: 34px;
    flex: none;
    place-items: center;
    border-radius: 50%;
    background: var(--surface-secondary);
    color: var(--text-secondary);
}
.rf-contact-card:hover .rf-contact-action {
    background: var(--primary);
    color: #fff;
}

/* --- Stat cards ----------------------------------------------------- */

.rf-stat {
    background: var(--surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 1.05rem 1.15rem;
    box-shadow: var(--shadow-sm);
    position: relative;
    overflow: hidden;
    display: flex;
    gap: .9rem;
    align-items: flex-start;
}
.rf-stat::before {
    content: ""; position: absolute; inset: 0 0 auto 0; height: 3px;
    background: var(--border-color);
}
.rf-stat.is-brand::before   { background: var(--racio-red); }
.rf-stat.is-success::before { background: var(--success); }
.rf-stat.is-warning::before { background: var(--warning); }
.rf-stat.is-danger::before  { background: var(--danger); }
.rf-stat.is-dark::before    { background: var(--racio-dark); }

.rf-stat-icon {
    width: 42px; height: 42px; flex: none; border-radius: var(--radius);
    display: grid; place-items: center;
    background: var(--surface-sunken); color: var(--text-secondary);
}
.rf-stat.is-brand   .rf-stat-icon { background: var(--primary-soft);  color: var(--racio-red); }
.rf-stat.is-success .rf-stat-icon { background: var(--success-soft);  color: var(--success); }
.rf-stat.is-warning .rf-stat-icon { background: var(--warning-soft);  color: var(--warning); }
.rf-stat.is-danger  .rf-stat-icon { background: var(--danger-soft);   color: var(--danger); }

.rf-stat-main { min-width: 0; flex: 1; }
.rf-stat-label {
    font-size: .6875rem; font-weight: 650; text-transform: uppercase;
    letter-spacing: .09em; color: var(--text-muted);
}
.rf-stat-value { font-size: 1.7rem; font-weight: 700; letter-spacing: -.03em; line-height: 1.15; margin-top: .15rem; }
.rf-stat-meta  { font-size: .75rem; color: var(--text-secondary); margin-top: .15rem; }
.rf-stat-meta.is-up   { color: var(--success); }
.rf-stat-meta.is-down { color: var(--danger); }

/* =====================================================================
   Buttons
   ================================================================== */

.rf-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: .45rem;
    height: 40px;
    padding: 0 1rem;
    border-radius: var(--radius-sm);
    border: 1px solid transparent;
    background: var(--surface-secondary);
    color: var(--text-primary);
    font-family: inherit;
    font-size: .875rem;
    font-weight: 600;
    line-height: 1;
    cursor: pointer;
    white-space: nowrap;
    text-decoration: none;
    transition: background var(--transition), color var(--transition), border-color var(--transition), box-shadow var(--transition), transform var(--transition);
}
.rf-btn:active { transform: translateY(1px); }
.rf-btn:disabled, .rf-btn.is-disabled { opacity: .55; cursor: not-allowed; transform: none; }

.rf-btn-primary { background: var(--racio-red); color: #fff; }
.rf-btn-primary:hover:not(:disabled) { background: var(--racio-red-hover); color: #fff; box-shadow: 0 4px 14px rgba(229,3,5,.28); }

.rf-btn-dark { background: var(--racio-dark); color: #fff; }
.rf-btn-dark:hover:not(:disabled) { background: #2c2c2c; color: #fff; }

.rf-btn-ghost { background: var(--surface); color: var(--text-primary); border-color: var(--border-color); }
.rf-btn-ghost:hover:not(:disabled) { background: var(--surface-hover); color: var(--text-primary); border-color: var(--border-strong); }

.rf-btn-soft { background: var(--primary-soft); color: var(--racio-red); }
.rf-btn-soft:hover:not(:disabled) { background: rgba(229,3,5,.16); color: var(--racio-red-dark); }

.rf-btn-outline { background: transparent; color: var(--racio-red); border-color: var(--racio-red); }
.rf-btn-outline:hover:not(:disabled) { background: var(--racio-red); color: #fff; }

.rf-btn-danger { background: var(--danger); color: #fff; }
.rf-btn-danger:hover:not(:disabled) { background: var(--racio-red-dark); color: #fff; }

.rf-btn-success { background: var(--success); color: var(--success-contrast); }
.rf-btn-success:hover:not(:disabled) { background: var(--text-secondary); color: var(--success-contrast); }

.rf-btn-link { background: none; border: 0; color: var(--primary); height: auto; padding: 0; font-weight: 600; }
.rf-btn-link:hover { color: var(--primary-hover); text-decoration: underline; }

.rf-btn-sm  { height: 32px; padding: 0 .7rem; font-size: .8125rem; border-radius: var(--radius-sm); }
.rf-btn-lg  { height: 50px; padding: 0 1.5rem; font-size: 1rem; border-radius: var(--radius); }
.rf-btn-xl  { height: 58px; padding: 0 1.8rem; font-size: 1.05rem; border-radius: var(--radius); }
.rf-btn-block { width: 100%; }
.rf-btn-icon { width: 38px; padding: 0; }

.rf-btn.is-loading { position: relative; color: transparent !important; pointer-events: none; }
.rf-btn.is-loading::after {
    content: ""; position: absolute; width: 16px; height: 16px;
    border: 2px solid currentColor; border-top-color: transparent; border-radius: 50%;
    animation: rf-spin .6s linear infinite;
    color: #fff;
}
.rf-btn-ghost.is-loading::after, .rf-btn-soft.is-loading::after { color: var(--text-primary); }
@keyframes rf-spin { to { transform: rotate(360deg); } }

.rf-btn-group { display: inline-flex; gap: .35rem; flex-wrap: wrap; }
.rf-theme-options { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); width: 100%; }
.rf-theme-option { min-width: 0; padding-inline: .45rem; }
.rf-theme-option.is-active {
    position: relative;
    z-index: 1;
    border-color: color-mix(in srgb, var(--primary) 38%, var(--border-color));
    background: var(--primary-soft);
    color: var(--primary);
}
.rf-theme-option.is-active:hover { background: var(--primary-soft); color: var(--primary); }

/* =====================================================================
   Forms
   ================================================================== */

.rf-form-grid { display: grid; gap: 1rem 1.15rem; grid-template-columns: repeat(2, minmax(0,1fr)); }
.rf-form-grid-3 { grid-template-columns: repeat(3, minmax(0,1fr)); }
.rf-col-span-2 { grid-column: span 2; }
.rf-col-span-3 { grid-column: span 3; }

.rf-field { display: flex; flex-direction: column; gap: .35rem; min-width: 0; }
.rf-label {
    font-size: .8125rem;
    font-weight: 600;
    color: var(--text-primary);
    display: flex; align-items: center; gap: .3rem;
}
.rf-label .rf-required { color: var(--racio-red); }
.rf-hint { font-size: .75rem; color: var(--text-muted); }
.rf-error { font-size: .75rem; color: var(--danger); display: flex; align-items: center; gap: .3rem; }

.rf-input, .rf-select, .rf-textarea {
    width: 100%;
    min-height: 42px;
    padding: .55rem .75rem;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    background: var(--surface);
    color: var(--text-primary);
    font-family: inherit;
    font-size: .9rem;
    transition: border-color var(--transition), box-shadow var(--transition);
    appearance: none;
}
.rf-textarea { min-height: 110px; resize: vertical; line-height: 1.6; }
.rf-input::placeholder, .rf-textarea::placeholder { color: var(--text-muted); }

.rf-input:focus, .rf-select:focus, .rf-textarea:focus {
    outline: none;
    border-color: var(--racio-red);
    box-shadow: 0 0 0 3px rgba(229,3,5,.10);
}
.rf-input:disabled, .rf-select:disabled, .rf-textarea:disabled {
    background: var(--surface-sunken); color: var(--text-muted); cursor: not-allowed;
}
.rf-input.is-invalid, .rf-select.is-invalid, .rf-textarea.is-invalid {
    border-color: var(--danger);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--danger) 10%, transparent);
}

.rf-select {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23737373' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right .7rem center;
    padding-right: 2.2rem;
}
.rf-select[multiple] { background-image: none; padding-right: .75rem; min-height: 120px; }

.rf-input-group { position: relative; display: flex; }
.rf-input-group .rf-input { padding-left: 2.4rem; }
.rf-input-group .rf-ig-icon {
    position: absolute; left: .75rem; top: 50%; transform: translateY(-50%);
    color: var(--text-muted); pointer-events: none;
}
.rf-input-group .rf-ig-action {
    position: absolute; right: .35rem; top: 50%; transform: translateY(-50%);
    width: 32px; height: 32px; display: grid; place-items: center;
    background: none; border: 0; border-radius: var(--radius-sm);
    color: var(--text-muted); cursor: pointer;
}
.rf-input-group .rf-ig-action:hover { background: var(--surface-hover); color: var(--text-primary); }
.rf-input-group.has-action .rf-input { padding-right: 2.6rem; }

.rf-check { display: flex; align-items: flex-start; gap: .55rem; font-size: .875rem; cursor: pointer; }
.rf-check input[type="checkbox"], .rf-check input[type="radio"] {
    width: 17px; height: 17px; margin: 2px 0 0; accent-color: var(--racio-red); cursor: pointer; flex: none;
}
.rf-check-group { display: flex; flex-wrap: wrap; gap: .5rem .95rem; }

.rf-switch { display: inline-flex; align-items: center; gap: .6rem; cursor: pointer; font-size: .875rem; }
.rf-switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.rf-switch-track {
    width: 42px; height: 24px; border-radius: var(--radius-pill);
    background: var(--border-strong); position: relative; transition: background var(--transition); flex: none;
}
.rf-switch-track::after {
    content: ""; position: absolute; top: 3px; left: 3px;
    width: 18px; height: 18px; border-radius: 50%; background: #fff;
    transition: transform var(--transition); box-shadow: var(--shadow-xs);
}
.rf-switch input:checked + .rf-switch-track { background: var(--racio-red); }
.rf-switch input:checked + .rf-switch-track::after { transform: translateX(18px); }
.rf-switch input:focus-visible + .rf-switch-track { outline: 2px solid var(--primary); outline-offset: 2px; }

/* File drop */
.rf-filedrop {
    border: 2px dashed var(--border-strong);
    border-radius: var(--radius);
    padding: 1.5rem 1rem;
    text-align: center;
    background: var(--surface-secondary);
    cursor: pointer;
    transition: border-color var(--transition), background var(--transition);
}
.rf-filedrop:hover, .rf-filedrop.is-dragging { border-color: var(--racio-red); background: var(--primary-soft); }
.rf-filedrop input[type="file"] { display: none; }
.rf-filedrop-icon { color: var(--text-muted); margin-bottom: .35rem; }
.rf-filedrop-title { font-weight: 600; font-size: .875rem; }
.rf-filedrop-hint { font-size: .75rem; color: var(--text-muted); }

.rf-filelist { display: flex; flex-direction: column; gap: .4rem; margin-top: .6rem; }
.rf-fileitem {
    display: flex; align-items: center; gap: .6rem;
    padding: .5rem .65rem; border: 1px solid var(--border-color);
    border-radius: var(--radius-sm); background: var(--surface); font-size: .8125rem;
}
.rf-fileitem-icon { color: var(--text-muted); flex: none; }
.rf-fileitem-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rf-fileitem-size { color: var(--text-muted); font-size: .75rem; flex: none; }

.rf-form-actions {
    display: flex; gap: .5rem; align-items: center; flex-wrap: wrap;
    padding-top: 1.15rem; margin-top: 1.15rem; border-top: 1px solid var(--border-color);
}

fieldset.rf-fieldset { border: 0; padding: 0; margin: 0 0 1.5rem; }
fieldset.rf-fieldset > legend {
    padding: 0; margin-bottom: .85rem; font-size: .6875rem; font-weight: 700;
    text-transform: uppercase; letter-spacing: .11em; color: var(--text-muted);
    width: 100%; border-bottom: 1px solid var(--border-color); padding-bottom: .5rem;
}

/* =====================================================================
   Tables
   ================================================================== */

.rf-table-wrap { width: 100%; overflow-x: auto; }
.rf-table { width: 100%; border-collapse: collapse; font-size: .875rem; }
.rf-table thead th {
    background: var(--surface-secondary);
    color: var(--text-secondary);
    font-size: .6875rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .07em;
    text-align: left;
    padding: .7rem .9rem;
    white-space: nowrap;
    border-bottom: 1px solid var(--border-color);
    position: sticky; top: 0; z-index: 1;
}
.rf-table thead th a { color: inherit; display: inline-flex; align-items: center; gap: .25rem; }
.rf-table thead th a:hover { color: var(--primary); }
.rf-table tbody td { padding: .75rem .9rem; border-bottom: 1px solid var(--border-color); vertical-align: middle; }
.rf-table tbody tr:last-child td { border-bottom: 0; }
.rf-table tbody tr { transition: background var(--transition); }
.rf-table tbody tr:hover { background: var(--surface-hover); }
.rf-table .rf-td-actions { text-align: right; white-space: nowrap; }
.rf-table .rf-td-num { text-align: right; font-variant-numeric: tabular-nums; }
.rf-table td.is-tight, .rf-table th.is-tight { width: 1%; white-space: nowrap; }

.rf-cell-user { display: flex; align-items: center; gap: .6rem; min-width: 0; }
.rf-cell-user .rf-cu-main { min-width: 0; }
.rf-cell-user .rf-cu-name { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rf-cell-user .rf-cu-sub  { font-size: .75rem; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* Filter bar above tables */
.rf-filters {
    display: flex; flex-wrap: wrap; gap: .55rem; align-items: flex-end;
    padding: .9rem 1.15rem; border-bottom: 1px solid var(--border-color);
    background: var(--surface-secondary);
}
.rf-filters .rf-field { flex: 1 1 160px; gap: .25rem; }
.rf-filters .rf-label { font-size: .6875rem; text-transform: uppercase; letter-spacing: .06em; color: var(--text-muted); }
.rf-filters .rf-input, .rf-filters .rf-select { min-height: 38px; padding: .4rem .65rem; font-size: .8125rem; }
.rf-filters .rf-input-group .rf-input { padding-left: 2.5rem; }
.rf-filters .rf-input-group.has-action .rf-input { padding-right: 2.6rem; }
.rf-filters-actions { display: flex; gap: .4rem; }

/* =====================================================================
   Badges, chips & progress
   ================================================================== */

.rf-badge {
    display: inline-flex; align-items: center; gap: .3rem;
    padding: .2rem .55rem;
    border-radius: var(--radius-pill);
    font-size: .6875rem;
    font-weight: 650;
    line-height: 1.5;
    white-space: nowrap;
    border: 1px solid transparent;
}
.rf-badge.is-success { background: var(--success-soft); color: var(--success); border-color: color-mix(in srgb, var(--success) 22%, var(--border-color)); }
.rf-badge.is-warning { background: var(--warning-soft); color: var(--warning); border-color: color-mix(in srgb, var(--warning) 25%, var(--border-color)); }
.rf-badge.is-danger  { background: var(--danger-soft);  color: var(--danger); border-color: color-mix(in srgb, var(--danger) 22%, var(--border-color)); }
.rf-badge.is-brand   { background: var(--primary-soft); color: var(--racio-red-dark); border-color: rgba(229,3,5,.2); }
.rf-badge.is-neutral { background: var(--info-soft);    color: var(--text-secondary); border-color: var(--border-color); }
.rf-badge.is-muted   { background: transparent;         color: var(--text-muted); border-color: var(--border-color); }
.rf-badge.is-dark    { background: var(--racio-dark);   color: #fff; }

:root[data-theme="dark"] .rf-badge.is-success { color: var(--success); }
:root[data-theme="dark"] .rf-badge.is-warning { color: var(--warning); }
:root[data-theme="dark"] .rf-badge.is-danger  { color: var(--danger); }
:root[data-theme="dark"] .rf-badge.is-brand   { color: #FF6B6D; }

.rf-chip {
    display: inline-flex; align-items: center; gap: .35rem;
    padding: .25rem .6rem; border-radius: var(--radius-pill);
    background: var(--surface-sunken); border: 1px solid var(--border-color);
    font-size: .75rem; color: var(--text-secondary);
}

.rf-progress {
    height: 8px; border-radius: var(--radius-pill);
    background: var(--surface-sunken); overflow: hidden;
}
.rf-progress-bar {
    height: 100%; border-radius: var(--radius-pill);
    background: var(--racio-red);
    transition: width 500ms cubic-bezier(.4,0,.2,1);
}
.rf-progress-bar.is-success { background: var(--success); }
.rf-progress-bar.is-warning { background: var(--warning); }
.rf-progress.is-lg { height: 12px; }

.rf-meter-labels { display: flex; justify-content: space-between; font-size: .75rem; color: var(--text-muted); margin-top: .35rem; }

/* Definition list used on detail pages */
.rf-dl { display: grid; grid-template-columns: minmax(120px, 38%) 1fr; gap: .55rem .9rem; font-size: .875rem; }
.rf-dl dt { color: var(--text-muted); font-size: .8125rem; }
.rf-dl dd { margin: 0; font-weight: 550; word-break: break-word; }

/* Timeline for status history */
.rf-timeline { list-style: none; margin: 0; padding: 0; position: relative; }
.rf-timeline::before {
    content: ""; position: absolute; left: 11px; top: 6px; bottom: 6px;
    width: 2px; background: var(--border-color);
}
.rf-timeline li,
.rf-timeline-item {
    position: relative;
    min-width: 0;
    min-height: 24px;
    padding: 0 0 1.05rem 2.1rem;
}
.rf-timeline li:last-child,
.rf-timeline-item:last-child { padding-bottom: 0; }
.rf-timeline-item > div { min-width: 0; }
.rf-timeline-dot {
    position: absolute; left: 4px; top: 4px;
    width: 16px; height: 16px; border-radius: 50%;
    background: var(--surface); border: 3px solid var(--border-strong);
}
.rf-timeline li.is-current .rf-timeline-dot,
.rf-timeline-item.is-current .rf-timeline-dot { border-color: var(--racio-red); }
.rf-timeline-title { font-size: .875rem; font-weight: 600; }
.rf-timeline-meta { font-size: .75rem; color: var(--text-muted); }
.rf-timeline-note { font-size: .8125rem; color: var(--text-secondary); margin-top: .2rem; }

/* =====================================================================
   Alerts, toasts, modals
   ================================================================== */

.rf-alert {
    display: flex; gap: .65rem; align-items: flex-start;
    padding: .8rem .95rem;
    border-radius: var(--radius);
    border: 1px solid var(--border-color);
    background: var(--surface-secondary);
    font-size: .875rem;
    margin-bottom: 1rem;
}
.rf-alert-icon { flex: none; margin-top: 1px; }
.rf-alert.is-success { background: var(--success-soft); border-color: color-mix(in srgb, var(--success) 25%, var(--border-color)); color: var(--success); }
.rf-alert.is-warning { background: var(--warning-soft); border-color: color-mix(in srgb, var(--warning) 28%, var(--border-color)); color: var(--warning); }
.rf-alert.is-danger  { background: var(--danger-soft);  border-color: color-mix(in srgb, var(--danger) 25%, var(--border-color)); color: var(--danger); }
.rf-alert.is-info    { background: var(--primary-soft); border-color: rgba(229,3,5,.18);    color: var(--racio-red-dark); }
:root[data-theme="dark"] .rf-alert.is-success { color: var(--success); }
:root[data-theme="dark"] .rf-alert.is-warning { color: var(--warning); }
:root[data-theme="dark"] .rf-alert.is-danger  { color: var(--danger); }
:root[data-theme="dark"] .rf-alert.is-info    { color: #FF8A8C; }

.rf-toast-stack {
    position: fixed; top: 78px; right: 18px; z-index: 200;
    display: flex; flex-direction: column; gap: .55rem;
    max-width: min(380px, calc(100vw - 36px));
}
.rf-toast {
    display: flex; align-items: flex-start; gap: .6rem;
    padding: .8rem .9rem;
    background: var(--surface);
    border: 1px solid var(--border-color);
    border-left: 4px solid var(--text-muted);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    font-size: .875rem;
    animation: rf-toast-in 220ms cubic-bezier(.2,.8,.3,1);
}
.rf-toast.is-success { border-left-color: var(--success); }
.rf-toast.is-danger  { border-left-color: var(--danger); }
.rf-toast.is-warning { border-left-color: var(--warning); }
.rf-toast.is-info    { border-left-color: var(--racio-red); }
.rf-toast.is-success .rf-toast-icon { color: var(--success); }
.rf-toast.is-danger  .rf-toast-icon { color: var(--danger); }
.rf-toast.is-warning .rf-toast-icon { color: var(--warning); }
.rf-toast.is-info    .rf-toast-icon { color: var(--racio-red); }
.rf-toast-icon { flex: none; margin-top: 1px; }
.rf-toast-body { flex: 1; min-width: 0; }
.rf-toast-close { background: none; border: 0; color: var(--text-muted); cursor: pointer; padding: 0; line-height: 1; }
.rf-toast-close:hover { color: var(--text-primary); }
.rf-toast.is-leaving { animation: rf-toast-out 180ms ease-in forwards; }
@keyframes rf-toast-in  { from { opacity: 0; transform: translateX(24px); } to { opacity: 1; transform: none; } }
@keyframes rf-toast-out { to { opacity: 0; transform: translateX(24px); } }

.rf-modal-backdrop {
    position: fixed; inset: 0; z-index: 150;
    background: rgba(0,0,0,.55);
    display: none; align-items: center; justify-content: center;
    padding: 1rem;
    backdrop-filter: blur(3px);
}
.rf-modal-backdrop.is-open { display: flex; }
.rf-modal {
    background: var(--surface);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    width: 100%;
    max-width: 520px;
    max-height: calc(100vh - 2rem);
    display: flex; flex-direction: column;
    animation: rf-modal-in 180ms cubic-bezier(.2,.8,.3,1);
}
.rf-modal.is-lg { max-width: 780px; }
.rf-modal.is-xl { max-width: 1040px; }
@keyframes rf-modal-in { from { opacity: 0; transform: translateY(12px) scale(.985); } to { opacity: 1; transform: none; } }
.rf-modal-head {
    display: flex; align-items: flex-start; justify-content: space-between; gap: .75rem;
    padding: 1.15rem 1.25rem .9rem;
    border-bottom: 1px solid var(--border-color);
}
.rf-modal-head h3 { margin: 0; font-size: 1.05rem; font-weight: 650; }
.rf-modal-head p  { margin: .2rem 0 0; font-size: .8125rem; color: var(--text-muted); }
.rf-modal-body { padding: 1.25rem; overflow-y: auto; }
.rf-modal-foot {
    display: flex; gap: .5rem; justify-content: flex-end; flex-wrap: wrap;
    padding: .95rem 1.25rem;
    border-top: 1px solid var(--border-color);
    background: var(--surface-secondary);
    border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}
.rf-modal-foot.is-split { justify-content: space-between; }

/* =====================================================================
   Empty & loading states
   ================================================================== */

.rf-empty { padding: 3rem 1.5rem; text-align: center; }
.rf-empty-icon {
    width: 64px; height: 64px; margin: 0 auto .9rem;
    border-radius: var(--radius-lg);
    display: grid; place-items: center;
    background: var(--surface-sunken);
    color: var(--text-muted);
    position: relative;
}
.rf-empty-icon::after {
    content: ""; position: absolute; inset: auto -6px -6px auto;
    width: 22px; height: 22px; border-radius: 5px;
    background: var(--primary-soft);
    transform: rotate(12deg);
    z-index: -1;
}
.rf-empty-title { font-size: 1rem; font-weight: 650; margin: 0 0 .3rem; }
.rf-empty-text  { font-size: .875rem; color: var(--text-muted); margin: 0 auto; max-width: 42ch; }
.rf-empty-action { margin-top: 1.15rem; }

.rf-skeleton {
    background: linear-gradient(90deg, var(--surface-sunken) 25%, var(--surface-hover) 37%, var(--surface-sunken) 63%);
    background-size: 400% 100%;
    animation: rf-shimmer 1.3s ease-in-out infinite;
    border-radius: var(--radius-sm);
}
@keyframes rf-shimmer { 0% { background-position: 100% 50%; } 100% { background-position: 0 50%; } }

.rf-spinner {
    width: 20px; height: 20px; border-radius: 50%;
    border: 2px solid var(--border-strong); border-top-color: var(--racio-red);
    animation: rf-spin .7s linear infinite;
    display: inline-block;
}
.rf-loading-row { display: flex; align-items: center; justify-content: center; gap: .6rem; padding: 2rem; color: var(--text-muted); font-size: .875rem; }

/* =====================================================================
   Avatars
   ================================================================== */

.rf-avatar {
    border-radius: 50%;
    object-fit: cover;
    flex: none;
    display: inline-grid;
    place-items: center;
    background: var(--surface-sunken);
    border: 1px solid var(--border-color);
}
.rf-avatar-initials {
    color: #fff;
    font-weight: 650;
    letter-spacing: .02em;
    border: 0;
    line-height: 1;
    text-transform: uppercase;
}
.rf-avatar-stack { display: inline-flex; }
.rf-avatar-stack .rf-avatar { margin-left: -8px; border: 2px solid var(--surface); }
.rf-avatar-stack .rf-avatar:first-child { margin-left: 0; }

.rf-presence {
    position: relative; display: inline-flex;
}
.rf-presence::after {
    content: ""; position: absolute; right: 0; bottom: 0;
    width: 10px; height: 10px; border-radius: 50%;
    background: var(--text-muted);
    border: 2px solid var(--surface);
}
.rf-presence.is-online::after { background: var(--success); }

/* =====================================================================
   Pagination
   ================================================================== */

.rf-pagination {
    display: flex; align-items: center; justify-content: space-between;
    gap: .75rem; flex-wrap: wrap;
    padding: .85rem 1.15rem;
    border-top: 1px solid var(--border-color);
}
.rf-pagination-info { font-size: .8125rem; color: var(--text-muted); }
.rf-pagination-pages { display: flex; gap: .25rem; flex-wrap: wrap; }
.rf-page {
    min-width: 34px; height: 34px; padding: 0 .5rem;
    display: inline-flex; align-items: center; justify-content: center;
    border: 1px solid var(--border-color); border-radius: var(--radius-sm);
    font-size: .8125rem; font-weight: 600; color: var(--text-secondary);
    background: var(--surface);
    transition: background var(--transition), color var(--transition), border-color var(--transition);
}
a.rf-page:hover { background: var(--surface-hover); color: var(--text-primary); border-color: var(--border-strong); }
.rf-page.is-active { background: var(--racio-red); border-color: var(--racio-red); color: #fff; }
.rf-page.is-disabled { opacity: .4; }
.rf-page.is-gap { border: 0; background: none; }

/* =====================================================================
   Tabs
   ================================================================== */

.rf-tabs {
    display: flex; gap: .2rem; overflow-x: auto;
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 1.25rem;
    scrollbar-width: none;
}
.rf-tabs::-webkit-scrollbar { display: none; }
.rf-tab {
    padding: .65rem .9rem;
    font-size: .875rem; font-weight: 600;
    color: var(--text-secondary);
    border-bottom: 2px solid transparent;
    white-space: nowrap;
    display: inline-flex; align-items: center; gap: .4rem;
    background: none; border-top: 0; border-left: 0; border-right: 0;
    font-family: inherit; cursor: pointer;
}
.rf-tab:hover { color: var(--text-primary); }
.rf-tab.is-active { color: var(--racio-red); border-bottom-color: var(--racio-red); }
.rf-tab-count {
    background: var(--surface-sunken); color: var(--text-muted);
    border-radius: var(--radius-pill); padding: 0 .4rem; font-size: .6875rem; font-weight: 700;
}
.rf-tab.is-active .rf-tab-count { background: var(--primary-soft); color: var(--racio-red); }

/* =====================================================================
   Searchable select (assets/js/app.js)
   ================================================================== */

.rf-combo { position: relative; }
.rf-combo-toggle {
    width: 100%; min-height: 42px;
    display: flex; align-items: center; justify-content: space-between; gap: .5rem;
    padding: .5rem .75rem;
    border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
    background: var(--surface); color: var(--text-primary);
    font-family: inherit; font-size: .9rem; text-align: left; cursor: pointer;
}
.rf-combo-toggle:focus { outline: none; border-color: var(--racio-red); box-shadow: 0 0 0 3px rgba(229,3,5,.10); }
.rf-combo-toggle.is-placeholder { color: var(--text-muted); }
.rf-combo-panel {
    position: absolute; z-index: 90; top: calc(100% + 4px); left: 0; right: 0;
    background: var(--surface); border: 1px solid var(--border-color);
    border-radius: var(--radius); box-shadow: var(--shadow-lg);
    display: none; overflow: hidden;
}
.rf-combo-panel.is-open { display: block; }
.rf-combo-search { padding: .5rem; border-bottom: 1px solid var(--border-color); }
.rf-combo-search input {
    width: 100%; height: 36px; padding: 0 .6rem; font-family: inherit; font-size: .875rem;
    border: 1px solid var(--border-color); border-radius: var(--radius-sm);
    background: var(--surface-secondary); color: var(--text-primary);
}
.rf-combo-search input:focus { outline: none; border-color: var(--racio-red); }
.rf-combo-list { max-height: 240px; overflow-y: auto; padding: .25rem; }
.rf-combo-option {
    display: flex; align-items: center; gap: .55rem;
    padding: .45rem .55rem; border-radius: var(--radius-sm);
    font-size: .875rem; cursor: pointer;
}
.rf-combo-option:hover, .rf-combo-option.is-active { background: var(--surface-hover); }
.rf-combo-option.is-selected { background: var(--primary-soft); color: var(--racio-red-dark); font-weight: 600; }
.rf-combo-option .rf-co-sub { font-size: .75rem; color: var(--text-muted); }
.rf-combo-empty { padding: .9rem; text-align: center; font-size: .8125rem; color: var(--text-muted); }

/* =====================================================================
   Utilities
   ================================================================== */

.u-flex        { display: flex; }
.u-text-danger { color: var(--danger) !important; }
.rf-btn-warning { background: var(--warning); color: var(--warning-contrast); border-color: var(--warning); }
.u-inline-flex { display: inline-flex; }
.u-items-center{ align-items: center; }
.u-items-start { align-items: flex-start; }
.u-justify-between { justify-content: space-between; }
.u-justify-end { justify-content: flex-end; }
.u-gap-1 { gap: .25rem; } .u-gap-2 { gap: .5rem; } .u-gap-3 { gap: .75rem; } .u-gap-4 { gap: 1rem; }
.u-wrap  { flex-wrap: wrap; }
.u-flex-1{ flex: 1; min-width: 0; }
.u-grow  { flex-grow: 1; }

.u-mt-0 { margin-top: 0; }     .u-mt-1 { margin-top: .35rem; }  .u-mt-2 { margin-top: .75rem; }
.u-mt-3 { margin-top: 1.15rem; } .u-mt-4 { margin-top: 1.5rem; }
.u-mb-0 { margin-bottom: 0; }  .u-mb-1 { margin-bottom: .35rem; } .u-mb-2 { margin-bottom: .75rem; }
.u-mb-3 { margin-bottom: 1.15rem; } .u-mb-4 { margin-bottom: 1.5rem; }

.u-text-sm    { font-size: .8125rem; }
.u-text-xs    { font-size: .75rem; }
.u-text-lg    { font-size: 1.05rem; }
.u-muted      { color: var(--text-muted); }
.u-secondary  { color: var(--text-secondary); }
.u-brand      { color: var(--racio-red); }
.u-success    { color: var(--success); }
.u-danger     { color: var(--danger); }
.u-warning    { color: var(--warning); }
.u-bold       { font-weight: 700; }
.u-semibold   { font-weight: 600; }
.u-mono       { font-family: var(--font-mono); }
.u-nowrap     { white-space: nowrap; }
.u-truncate   { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.u-center     { text-align: center; }
.u-right      { text-align: right; }
.u-uppercase  { text-transform: uppercase; letter-spacing: .06em; }
.u-tabular    { font-variant-numeric: tabular-nums; }
.u-hidden     { display: none !important; }
.u-full       { width: 100%; }

.rf-divider { height: 1px; background: var(--border-color); margin: 1.15rem 0; }

.rf-section-heading {
    display: flex;
    align-items: center;
    gap: .75rem;
    margin: 0 0 .85rem;
    font-size: .75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .08em;
    color: var(--text-muted);
}
.rf-section-heading::after {
    content: "";
    flex: 1;
    height: 1px;
    background: var(--border-color);
}

/* Brand geometric motif used on auth pages and empty states */
.rf-motif { position: absolute; pointer-events: none; opacity: .9; }
