/* ==========================================================================
   Rushd Soft — modern visual layer for the web CRM.
   Loaded AFTER crm-custom.css, so it restyles the shared classes (card-glass,
   btn-primary, header, sidebar, tables, inputs…) for every page at once.
   Motion is built on one easing curve and respects prefers-reduced-motion.
   ========================================================================== */

:root {
    --rs-ease: cubic-bezier(0.22, 1, 0.36, 1);
    --rs-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
    --rs-fast: 0.18s;
    --rs-base: 0.35s;
    --rs-slow: 0.7s;

    --rs-accent: #4f46e5;
    --rs-accent-2: #7c3aed;
    --rs-ink: #14142b;
    --rs-radius: 22px;
    --rs-radius-sm: 14px;

    --rs-card: rgba(255, 255, 255, 0.86);
    --rs-card-solid: #ffffff;
    --rs-card-border: rgba(255, 255, 255, 0.95);
    --rs-hairline: rgba(99, 102, 241, 0.10);
    --rs-shadow: 0 1px 2px rgba(23, 23, 70, 0.04), 0 14px 34px -16px rgba(52, 52, 140, 0.18);
    --rs-shadow-hover: 0 2px 4px rgba(23, 23, 70, 0.05), 0 24px 46px -18px rgba(52, 52, 140, 0.30);
    --rs-focus: 0 0 0 4px rgba(99, 102, 241, 0.18);

    --rs-mesh-a: rgba(99, 102, 241, 0.13);
    --rs-mesh-b: rgba(244, 114, 182, 0.09);
    --rs-mesh-c: rgba(56, 189, 248, 0.10);
}

[data-theme="dark"],
.dark {
    --rs-card: rgba(22, 28, 54, 0.72);
    --rs-card-solid: #141b34;
    --rs-card-border: rgba(255, 255, 255, 0.07);
    --rs-hairline: rgba(129, 140, 248, 0.16);
    --rs-shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 18px 40px -18px rgba(0, 0, 0, 0.65);
    --rs-shadow-hover: 0 2px 4px rgba(0, 0, 0, 0.35), 0 28px 54px -20px rgba(0, 0, 0, 0.8);
    --rs-focus: 0 0 0 4px rgba(129, 140, 248, 0.25);
    --rs-mesh-a: rgba(99, 102, 241, 0.20);
    --rs-mesh-b: rgba(236, 72, 153, 0.10);
    --rs-mesh-c: rgba(14, 165, 233, 0.10);
}

/* ── Canvas: a soft colour mesh behind everything ─────────────────────── */
html body {
    background-image:
        radial-gradient(900px 540px at 6% -8%, var(--rs-mesh-a), transparent 62%),
        radial-gradient(760px 480px at 100% 2%, var(--rs-mesh-b), transparent 58%),
        radial-gradient(720px 540px at 62% 108%, var(--rs-mesh-c), transparent 62%);
    background-attachment: fixed;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}

html { scroll-behavior: smooth; }

/* ── Cards ────────────────────────────────────────────────────────────── */
html .card-glass,
html .glass {
    background: var(--rs-card);
    border: 1px solid var(--rs-card-border);
    border-radius: var(--rs-radius);
    box-shadow: var(--rs-shadow);
    -webkit-backdrop-filter: blur(18px) saturate(1.15);
    backdrop-filter: blur(18px) saturate(1.15);
    transition: box-shadow var(--rs-base) var(--rs-ease), border-color var(--rs-base) var(--rs-ease),
        transform var(--rs-base) var(--rs-ease), background-color var(--rs-base) var(--rs-ease);
}

/* Large containers must not jump around; only clickable cards lift. */
html .card-glass:hover,
html .glass:hover {
    transform: none;
    box-shadow: var(--rs-shadow-hover);
    border-color: var(--rs-hairline);
}

html a.card-glass:hover,
html .card-glass.rs-lift:hover {
    transform: translateY(-3px);
}

html a.card-glass:active,
html .card-glass.rs-lift:active {
    transform: translateY(-1px) scale(0.995);
    transition-duration: var(--rs-fast);
}

/* ── Buttons ──────────────────────────────────────────────────────────── */
html .btn-primary,
html .btn-secondary {
    border-radius: var(--rs-radius-sm);
    letter-spacing: -0.005em;
    position: relative;
    overflow: hidden;
    transition: transform var(--rs-fast) var(--rs-ease), box-shadow var(--rs-base) var(--rs-ease),
        filter var(--rs-base) var(--rs-ease), background-color var(--rs-base) var(--rs-ease);
}

html .btn-primary {
    box-shadow: 0 1px 0 rgba(255, 255, 255, 0.25) inset, 0 8px 20px -8px rgba(79, 70, 229, 0.55);
}

html .btn-primary::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(105deg, transparent 30%, rgba(255, 255, 255, 0.35) 50%, transparent 70%);
    transform: translateX(-120%);
    transition: transform 0.7s var(--rs-ease);
    pointer-events: none;
}

html .btn-primary:hover {
    transform: translateY(-1px);
    filter: none;
    box-shadow: 0 1px 0 rgba(255, 255, 255, 0.3) inset, 0 14px 28px -10px rgba(79, 70, 229, 0.65);
}

html .btn-primary:hover::after { transform: translateX(120%); }
html .btn-primary:active { transform: translateY(0) scale(0.98); }

html .btn-secondary {
    background: var(--rs-card-solid);
    border: 1px solid var(--rs-hairline);
    box-shadow: 0 1px 2px rgba(23, 23, 70, 0.05);
}

html .btn-secondary:hover {
    transform: translateY(-1px);
    border-color: rgba(99, 102, 241, 0.35);
    box-shadow: 0 10px 22px -12px rgba(79, 70, 229, 0.35);
}

html .btn-secondary:active { transform: scale(0.98); }

/* Every button gets tactile feedback, even Tailwind-only ones. */
button:not(:disabled),
[role="button"] {
    transition-property: transform, background-color, border-color, box-shadow, opacity, color;
    transition-duration: var(--rs-fast);
    transition-timing-function: var(--rs-ease);
}

button:not(:disabled):active { transform: scale(0.97); }

/* ── Form fields ──────────────────────────────────────────────────────── */
input:not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="file"]),
select,
textarea {
    transition: box-shadow var(--rs-base) var(--rs-ease), border-color var(--rs-base) var(--rs-ease),
        background-color var(--rs-base) var(--rs-ease);
}

input:not([type="checkbox"]):not([type="radio"]):not([type="range"]):focus,
select:focus,
textarea:focus {
    outline: none !important;
    border-color: #6366f1 !important;
    box-shadow: var(--rs-focus) !important;
}

a:focus-visible,
button:focus-visible,
[tabindex]:focus-visible {
    outline: 2px solid rgba(99, 102, 241, 0.65);
    outline-offset: 2px;
    border-radius: 10px;
}

/* ── Header ───────────────────────────────────────────────────────────── */
html .enterprise-header {
    background: color-mix(in srgb, var(--rs-card-solid) 72%, transparent) !important;
    -webkit-backdrop-filter: blur(22px) saturate(1.3);
    backdrop-filter: blur(22px) saturate(1.3);
    border-bottom: 1px solid transparent !important;
    box-shadow: none !important;
    transition: border-color var(--rs-base) var(--rs-ease), box-shadow var(--rs-base) var(--rs-ease), background-color var(--rs-base) var(--rs-ease);
}

html .enterprise-header.is-scrolled {
    border-bottom-color: var(--rs-hairline) !important;
    box-shadow: 0 10px 30px -22px rgba(52, 52, 140, 0.45) !important;
}

#breadcrumb-page-title {
    font-family: 'Outfit', 'Inter', sans-serif;
    font-weight: 700;
    letter-spacing: -0.02em;
}

html .enterprise-header button,
html .enterprise-header a {
    border-radius: 12px;
}

html .enterprise-header button:hover,
html .enterprise-header a:hover {
    background-color: rgba(99, 102, 241, 0.08);
}

/* ── Sidebar ──────────────────────────────────────────────────────────── */
html .enterprise-sidebar {
    background: linear-gradient(180deg, color-mix(in srgb, var(--rs-card-solid) 94%, transparent), color-mix(in srgb, var(--rs-card-solid) 88%, #6366f1 6%)) !important;
    border-right: 1px solid var(--rs-hairline) !important;
    box-shadow: 18px 0 40px -34px rgba(52, 52, 140, 0.45) !important;
}

html .enterprise-sidebar .section-toggle {
    font-size: 0.68rem;
    letter-spacing: 0.1em;
    padding-top: 0.55rem;
    padding-bottom: 0.55rem;
}

html .enterprise-sidebar .section-toggle:hover {
    background: rgba(99, 102, 241, 0.07);
    color: var(--rs-accent);
}

html .enterprise-sidebar .nav-chevron { transition: transform var(--rs-base) var(--rs-ease); }

html .enterprise-sidebar .section-content a {
    position: relative;
    transition: background-color var(--rs-base) var(--rs-ease), transform var(--rs-base) var(--rs-ease), box-shadow var(--rs-base) var(--rs-ease);
}

/* Tailwind's hover:scale-105 made the menu wobble; replace it with a calm nudge. */
html .enterprise-sidebar .section-content a:hover {
    transform: translateX(3px);
    box-shadow: none;
    background: rgba(99, 102, 241, 0.09);
}

html .enterprise-sidebar .section-content a:active { transform: translateX(1px) scale(0.99); }

html .enterprise-sidebar .section-content a svg { transition: transform var(--rs-base) var(--rs-spring); }
html .enterprise-sidebar .section-content a:hover svg { transform: scale(1.12) rotate(-4deg); }

/* ── Tables ───────────────────────────────────────────────────────────── */
table thead th {
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.07em;
    text-transform: uppercase;
}

table tbody tr {
    transition: background-color var(--rs-fast) var(--rs-ease);
}

table tbody tr:hover {
    background-color: rgba(99, 102, 241, 0.045);
}

/* ── Scrollbars ───────────────────────────────────────────────────────── */
* { scrollbar-width: thin; scrollbar-color: rgba(99, 102, 241, 0.28) transparent; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: rgba(99, 102, 241, 0.25); border-radius: 10px; border: 3px solid transparent; background-clip: content-box; }
::-webkit-scrollbar-thumb:hover { background: rgba(99, 102, 241, 0.45); background-clip: content-box; border: 3px solid transparent; }
::selection { background: rgba(99, 102, 241, 0.22); }

/* ── Motion primitives ────────────────────────────────────────────────── */
@keyframes rs-rise {
    from { opacity: 0; transform: translateY(18px); }
    to   { opacity: 1; transform: translateY(0); }
}

@keyframes rs-fade {
    from { opacity: 0; }
    to   { opacity: 1; }
}

@keyframes rs-pop {
    0%   { opacity: 0; transform: scale(0.92); }
    60%  { opacity: 1; transform: scale(1.02); }
    100% { opacity: 1; transform: scale(1); }
}

@keyframes rs-float {
    0%, 100% { transform: translate3d(0, 0, 0) scale(1); }
    50%      { transform: translate3d(14px, -18px, 0) scale(1.06); }
}

@keyframes rs-shimmer {
    0%   { background-position: -200% 0; }
    100% { background-position: 200% 0; }
}

/* Elements start hidden only when JS is available, so nothing is ever stuck invisible. */
html.rs-js .rs-reveal {
    opacity: 0;
    transform: translateY(18px);
    transition: opacity var(--rs-slow) var(--rs-ease), transform var(--rs-slow) var(--rs-ease);
    transition-delay: calc(var(--i, 0) * 70ms);
    will-change: opacity, transform;
}

html.rs-js .rs-reveal.is-in {
    opacity: 1;
    transform: none;
}

.rs-skeleton {
    border-radius: 12px;
    background: linear-gradient(100deg, rgba(148, 163, 184, 0.14) 30%, rgba(148, 163, 184, 0.28) 50%, rgba(148, 163, 184, 0.14) 70%);
    background-size: 200% 100%;
    animation: rs-shimmer 1.4s linear infinite;
}

/* Page transitions (htmx boosts navigation and uses View Transitions). */
::view-transition-old(root) { animation: rs-fade 0.16s var(--rs-ease) reverse both; }
::view-transition-new(root) { animation: rs-rise 0.38s var(--rs-ease) both; }

#top-progress-bar { height: 3px; border-radius: 0 3px 3px 0; }

/* ── Dashboard: hero ──────────────────────────────────────────────────── */
.rs-hero {
    position: relative;
    overflow: hidden;
    isolation: isolate;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1.5rem;
    flex-wrap: wrap;
    padding: 1.75rem 2rem;
    border-radius: 28px;
    background: linear-gradient(120deg, #eef0ff 0%, #f6efff 52%, #ffeee8 100%);
    border: 1px solid rgba(255, 255, 255, 0.9);
    box-shadow: var(--rs-shadow);
}

[data-theme="dark"] .rs-hero,
.dark .rs-hero {
    background: linear-gradient(120deg, #1b2050 0%, #2a1f5c 55%, #3b1f4a 100%);
    border-color: rgba(255, 255, 255, 0.08);
}

.rs-hero::before,
.rs-hero::after {
    content: '';
    position: absolute;
    z-index: -1;
    border-radius: 50%;
    filter: blur(48px);
    animation: rs-float 14s ease-in-out infinite;
}

.rs-hero::before { width: 260px; height: 260px; right: -60px; top: -90px; background: rgba(99, 102, 241, 0.35); }
.rs-hero::after  { width: 220px; height: 220px; left: 38%; bottom: -120px; background: rgba(244, 114, 182, 0.30); animation-delay: -6s; }

.rs-eyebrow {
    font-size: 0.78rem;
    font-weight: 600;
    letter-spacing: 0.04em;
    color: var(--text-secondary);
}

.rs-hero h1 {
    margin: 0.25rem 0 0.35rem;
    font-family: 'Outfit', 'Inter', sans-serif;
    font-size: clamp(1.6rem, 3.4vw, 2.4rem);
    font-weight: 700;
    letter-spacing: -0.03em;
    line-height: 1.1;
    color: var(--text-primary);
}

.rs-hero p.rs-sub { margin: 0; color: var(--text-secondary); font-size: 0.95rem; }

.rs-hero-actions { display: flex; align-items: center; gap: 0.75rem; flex-wrap: wrap; }

.rs-pill {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    padding: 0.45rem 0.85rem;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.7);
    border: 1px solid rgba(255, 255, 255, 0.9);
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-primary);
    backdrop-filter: blur(10px);
}

[data-theme="dark"] .rs-pill,
.dark .rs-pill { background: rgba(255, 255, 255, 0.08); border-color: rgba(255, 255, 255, 0.12); }

/* ── Dashboard: quick links ───────────────────────────────────────────── */
.rs-chips {
    display: flex;
    gap: 0.5rem;
    overflow-x: auto;
    padding: 0.4rem;
    border-radius: 999px;
    background: var(--rs-card);
    border: 1px solid var(--rs-card-border);
    box-shadow: var(--rs-shadow);
    -webkit-backdrop-filter: blur(18px);
    backdrop-filter: blur(18px);
    scrollbar-width: none;
}

.rs-chips::-webkit-scrollbar { display: none; }

.rs-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    flex: none;
    padding: 0.55rem 1rem;
    border-radius: 999px;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-secondary);
    white-space: nowrap;
    transition: background-color var(--rs-base) var(--rs-ease), color var(--rs-base) var(--rs-ease), transform var(--rs-fast) var(--rs-ease), box-shadow var(--rs-base) var(--rs-ease);
}

.rs-chip svg { width: 1rem; height: 1rem; transition: transform var(--rs-base) var(--rs-spring); }
.rs-chip:hover { background: rgba(99, 102, 241, 0.1); color: var(--rs-accent); }
.rs-chip:hover svg { transform: scale(1.18) rotate(-6deg); }
.rs-chip:active { transform: scale(0.96); }

/* ── Dashboard: KPI cards ─────────────────────────────────────────────── */
.rs-kpis {
    display: grid;
    gap: 1.1rem;
    grid-template-columns: repeat(auto-fit, minmax(176px, 1fr));
}

.rs-kpi {
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    padding: 1.25rem 1.35rem;
    border-radius: var(--rs-radius);
    background: var(--rs-card);
    border: 1px solid var(--rs-card-border);
    box-shadow: var(--rs-shadow);
    overflow: hidden;
    isolation: isolate;
    color: var(--text-primary);
    transition: transform var(--rs-base) var(--rs-ease), box-shadow var(--rs-base) var(--rs-ease), border-color var(--rs-base) var(--rs-ease);
}

.rs-kpi:hover { transform: translateY(-4px); box-shadow: var(--rs-shadow-hover); border-color: var(--rs-hairline); }
.rs-kpi:active { transform: translateY(-1px) scale(0.99); transition-duration: var(--rs-fast); }

.rs-kpi__top { display: flex; align-items: center; justify-content: space-between; gap: 0.75rem; }

.rs-kpi__label {
    font-size: 0.78rem;
    font-weight: 600;
    letter-spacing: 0.02em;
    color: var(--text-secondary);
}

.rs-kpi__icon {
    width: 2.6rem;
    height: 2.6rem;
    border-radius: 14px;
    display: grid;
    place-items: center;
    transition: transform var(--rs-base) var(--rs-spring);
}

.rs-kpi__icon svg { width: 1.3rem; height: 1.3rem; }
.rs-kpi:hover .rs-kpi__icon { transform: scale(1.1) rotate(-6deg); }

.rs-kpi .stat-value,
.rs-kpi__value {
    margin: 0;
    font-family: 'Outfit', 'Inter', sans-serif;
    font-size: clamp(1.7rem, 2.6vw, 2.2rem);
    line-height: 1.05;
    font-weight: 700;
    letter-spacing: -0.035em;
    font-variant-numeric: tabular-nums;
    color: var(--text-primary);
    text-shadow: none;
}

.rs-kpi__value small { font-size: 0.55em; font-weight: 600; margin-left: 0.2em; color: var(--text-tertiary); letter-spacing: 0; }

.rs-kpi__hint {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.78rem;
    font-weight: 500;
    color: var(--text-tertiary);
}

.rs-kpi__hint svg { width: 0.85rem; height: 0.85rem; transition: transform var(--rs-base) var(--rs-ease); }
.rs-kpi:hover .rs-kpi__hint svg { transform: translateX(4px); }

/* Tones for the icon tiles */
.rs-tone-indigo  { background: rgba(99, 102, 241, 0.12);  color: #4f46e5; }
.rs-tone-emerald { background: rgba(16, 185, 129, 0.14);  color: #059669; }
.rs-tone-violet  { background: rgba(139, 92, 246, 0.14);  color: #7c3aed; }
.rs-tone-amber   { background: rgba(245, 158, 11, 0.16);  color: #d97706; }
.rs-tone-sky     { background: rgba(14, 165, 233, 0.14);  color: #0284c7; }
.rs-tone-rose    { background: rgba(244, 63, 94, 0.12);   color: #e11d48; }
.rs-tone-blue    { background: rgba(59, 130, 246, 0.13);  color: #2563eb; }

[data-theme="dark"] .rs-tone-indigo, .dark .rs-tone-indigo { color: #a5b4fc; }
[data-theme="dark"] .rs-tone-emerald, .dark .rs-tone-emerald { color: #6ee7b7; }
[data-theme="dark"] .rs-tone-violet, .dark .rs-tone-violet { color: #c4b5fd; }
[data-theme="dark"] .rs-tone-amber, .dark .rs-tone-amber { color: #fcd34d; }
[data-theme="dark"] .rs-tone-sky, .dark .rs-tone-sky { color: #7dd3fc; }
[data-theme="dark"] .rs-tone-rose, .dark .rs-tone-rose { color: #fda4af; }
[data-theme="dark"] .rs-tone-blue, .dark .rs-tone-blue { color: #93c5fd; }

/* The featured card: deep ink with a coloured glow */
.rs-kpi--ink {
    background: linear-gradient(150deg, #1c1b4b 0%, #14142b 60%, #1d1740 100%);
    border-color: rgba(255, 255, 255, 0.08);
    color: #fff;
}

.rs-kpi--ink::before {
    content: '';
    position: absolute;
    z-index: -1;
    width: 220px;
    height: 220px;
    right: -70px;
    top: -80px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(129, 140, 248, 0.55), transparent 65%);
    animation: rs-float 12s ease-in-out infinite;
}

.rs-kpi--ink .rs-kpi__label,
.rs-kpi--ink .rs-kpi__hint { color: rgba(226, 232, 240, 0.72); }
.rs-kpi--ink .stat-value,
.rs-kpi--ink .rs-kpi__value { color: #fff; }
.rs-kpi--ink .rs-kpi__value small { color: rgba(226, 232, 240, 0.6); }
.rs-kpi--ink .rs-kpi__icon { background: rgba(255, 255, 255, 0.12); color: #c7d2fe; }

/* Thin progress under a KPI */
.rs-progress {
    height: 6px;
    border-radius: 999px;
    background: rgba(148, 163, 184, 0.22);
    overflow: hidden;
}

.rs-progress > span {
    display: block;
    height: 100%;
    width: 0;
    border-radius: inherit;
    background: linear-gradient(90deg, #6366f1, #a855f7);
    transition: width 1.2s var(--rs-ease) 0.2s;
}

/* ── Dashboard: compact money / service tiles ─────────────────────────── */
.rs-minis {
    display: grid;
    gap: 1rem;
    grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
}

.rs-mini {
    display: flex;
    align-items: center;
    gap: 0.95rem;
    padding: 1rem 1.15rem;
    border-radius: 20px;
    background: var(--rs-card);
    border: 1px solid var(--rs-card-border);
    box-shadow: var(--rs-shadow);
    color: var(--text-primary);
    transition: transform var(--rs-base) var(--rs-ease), box-shadow var(--rs-base) var(--rs-ease);
}

.rs-mini:hover { transform: translateY(-3px); box-shadow: var(--rs-shadow-hover); }
.rs-mini:active { transform: scale(0.985); }
.rs-mini__icon { width: 2.5rem; height: 2.5rem; border-radius: 13px; display: grid; place-items: center; font-size: 1.05rem; flex: none; }
.rs-mini__label { font-size: 0.74rem; font-weight: 600; color: var(--text-secondary); }
.rs-mini__value { margin-top: 0.1rem; font-family: 'Outfit', 'Inter', sans-serif; font-size: 1.25rem; font-weight: 700; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }

/* ── Responsive tweaks ────────────────────────────────────────────────── */
@media (max-width: 640px) {
    .rs-hero { padding: 1.25rem 1.1rem; border-radius: 22px; }
    .rs-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.8rem; }
    .rs-kpi { padding: 1rem; gap: 0.75rem; }
    .rs-kpi__icon { width: 2.2rem; height: 2.2rem; }
}

/* Smooth cross-fade while the theme is switching (class is toggled by crm-motion.js) */
html.rs-theming,
html.rs-theming *,
html.rs-theming *::before,
html.rs-theming *::after {
    transition: background-color 0.45s var(--rs-ease), color 0.45s var(--rs-ease), border-color 0.45s var(--rs-ease),
        fill 0.45s var(--rs-ease), stroke 0.45s var(--rs-ease), box-shadow 0.45s var(--rs-ease) !important;
}

/* ── Respect users who prefer less motion ─────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.001ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.001ms !important;
        scroll-behavior: auto !important;
    }
    html.rs-js .rs-reveal { opacity: 1; transform: none; }
}

/* ── Sidebar v2: calm, flat, two levels ───────────────────────────────── */
html .rs-sidebar a, html .rs-sidebar a:hover, html .rs-sidebar a.active {
    transform: none !important;
    box-shadow: none !important;
    filter: none;
    margin-bottom: 0;
}
html .rs-sidebar a::before { display: none !important; }

.rs-brand { display: flex; align-items: center; justify-content: space-between; height: 4rem; padding: 0 1rem 0 1.1rem; flex-shrink: 0; }
.rs-brand-link { display: flex; align-items: center; gap: .7rem; min-width: 0; background: none !important; }
.rs-brand-mark { width: 2.25rem; height: 2.25rem; border-radius: 10px; display: grid; place-items: center; flex-shrink: 0;
    font-weight: 800; font-size: 1.1rem; color: #fff; background: linear-gradient(135deg, var(--rs-accent), var(--rs-accent-2)); }
.rs-brand-text { display: flex; flex-direction: column; min-width: 0; line-height: 1.2; }
.rs-brand-name { font-weight: 700; font-size: 1rem; color: var(--rs-ink); }
.rs-brand-tenant { font-size: .72rem; color: #8b8fa7; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rs-brand-close { padding: .4rem; border-radius: 8px; color: #8b8fa7; }

.rs-nav { flex: 1; overflow-y: auto; padding: .25rem .75rem 1rem; display: flex; flex-direction: column; gap: 2px; }
.rs-group-top { display: flex; flex-direction: column; gap: 2px; padding-bottom: .6rem; margin-bottom: .4rem; border-bottom: 1px solid var(--rs-hairline); }

.rs-link, .rs-head {
    display: flex; align-items: center; gap: .7rem; width: 100%; height: 2.4rem; padding: 0 .7rem;
    border-radius: 10px; font-size: .9rem; font-weight: 500; color: #4b5068; text-align: left;
    text-transform: none; letter-spacing: 0; background: transparent; transition: background-color var(--rs-fast) var(--rs-ease), color var(--rs-fast) var(--rs-ease);
}
html .rs-sidebar .section-toggle.rs-head { font-size: .9rem; letter-spacing: 0; text-transform: none; padding-top: 0; padding-bottom: 0; color: #4b5068; }
.rs-ico { width: 1.2rem; height: 1.2rem; flex-shrink: 0; color: #8b8fa7; transition: color var(--rs-fast) var(--rs-ease); }
.rs-label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rs-chev { width: .95rem; height: .95rem; color: #a3a7bd; flex-shrink: 0; }

html .rs-sidebar .rs-link:hover, html .rs-sidebar .rs-head:hover { background: rgba(99, 102, 241, .07); color: var(--rs-ink); }
html .rs-sidebar .rs-link:hover .rs-ico, html .rs-sidebar .rs-head:hover .rs-ico { color: var(--rs-accent); }
html .rs-sidebar .rs-link.active { background: rgba(99, 102, 241, .12); color: var(--rs-accent); font-weight: 600; }
html .rs-sidebar .rs-link.active .rs-ico { color: var(--rs-accent) !important; }
.nav-section:not(.collapsed) > .rs-head { color: var(--rs-ink); font-weight: 600; }
.nav-section:not(.collapsed) > .rs-head .rs-ico { color: var(--rs-accent); }

/* children: text only, one thin rail, no icons */
.rs-sub { margin: 2px 0 6px 1.55rem; padding-left: .55rem; border-left: 1px solid var(--rs-hairline); }
.rs-sublink { display: flex; align-items: center; justify-content: space-between; gap: .5rem; height: 2rem; padding: 0 .65rem;
    border-radius: 8px; font-size: .84rem; color: #6b7088; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
html .rs-sidebar .rs-sublink:hover { background: rgba(99, 102, 241, .07); color: var(--rs-ink); }
html .rs-sidebar .rs-sublink.active { background: rgba(99, 102, 241, .12); color: var(--rs-accent); font-weight: 600; }
.rs-tag { font-size: .6rem; font-weight: 700; padding: 1px 6px; border-radius: 999px; background: rgba(124, 58, 237, .12); color: var(--rs-accent-2); }

.rs-foot { flex-shrink: 0; padding: .5rem .75rem .75rem; border-top: 1px solid var(--rs-hairline); display: flex; flex-direction: column; gap: 2px; }

[data-theme="dark"] .rs-brand-name, .dark .rs-brand-name { color: #eef0ff; }
[data-theme="dark"] .rs-link, [data-theme="dark"] .rs-head, [data-theme="dark"] html .rs-sidebar .section-toggle.rs-head,
.dark .rs-link, .dark .rs-head { color: #b9bdd6; }
[data-theme="dark"] .rs-sublink, .dark .rs-sublink { color: #9a9fbb; }
[data-theme="dark"] html .rs-sidebar .rs-link:hover, [data-theme="dark"] html .rs-sidebar .rs-head:hover,
[data-theme="dark"] html .rs-sidebar .rs-sublink:hover { color: #fff; }
[data-theme="dark"] html .rs-sidebar .rs-link.active, [data-theme="dark"] html .rs-sidebar .rs-sublink.active { color: #c7d2fe; background: rgba(129, 140, 248, .18); }
[data-theme="dark"] .nav-section:not(.collapsed) > .rs-head { color: #fff; }
[data-theme="dark"] .rs-ico { color: #8f94b3; }

/* ── Settings area: one tab bar on top, one header style for every page ── */
.st-tabs { display: flex; gap: .15rem; overflow-x: auto; border-bottom: 1px solid var(--rs-hairline); scrollbar-width: none; }
.st-tabs::-webkit-scrollbar { display: none; }
.st-tab { display: inline-flex; align-items: center; gap: .5rem; padding: .75rem .95rem; font-size: .875rem; font-weight: 500; color: #6b7088;
    white-space: nowrap; border-bottom: 2px solid transparent; margin-bottom: -1px; transition: color var(--rs-fast) var(--rs-ease), border-color var(--rs-fast) var(--rs-ease); }
.st-tab svg { width: 1rem; height: 1rem; flex-shrink: 0; opacity: .8; }
.st-tab:hover { color: var(--rs-ink); }
.st-tab.is-active { color: var(--rs-accent); border-bottom-color: var(--rs-accent); font-weight: 600; }
.st-tab.is-active svg { opacity: 1; }

.st-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 1rem; }
.st-title { font-size: 1.5rem; line-height: 1.2; font-weight: 700; color: var(--rs-ink); }
.st-sub { margin-top: .3rem; font-size: .875rem; color: #6b7088; max-width: 46rem; }
.st-actions { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; }
.st-btn { display: inline-flex; align-items: center; gap: .5rem; height: 2.4rem; padding: 0 1rem; border-radius: 10px; font-size: .85rem; font-weight: 600;
    background: var(--rs-card-solid); color: #3b3f57; border: 1px solid rgba(99, 102, 241, .22); cursor: pointer; transition: background-color var(--rs-fast) var(--rs-ease); }
.st-btn:hover { background: rgba(99, 102, 241, .08); }
.st-btn svg { width: 1rem; height: 1rem; margin: 0 !important; flex-shrink: 0; }
.st-btn-primary { background: var(--rs-accent); color: #fff; border-color: transparent; }
.st-btn-primary:hover { background: #4338ca; }
.st-btn-danger { background: #e11d48; color: #fff; border-color: transparent; }
.st-btn-danger:hover { background: #be123c; }

[data-theme="dark"] .st-title, .dark .st-title { color: #eef0ff; }
[data-theme="dark"] .st-sub, [data-theme="dark"] .st-tab, .dark .st-sub, .dark .st-tab { color: #9a9fbb; }
[data-theme="dark"] .st-tab:hover, .dark .st-tab:hover { color: #fff; }
[data-theme="dark"] .st-tab.is-active, .dark .st-tab.is-active { color: #a5b4fc; border-bottom-color: #a5b4fc; }
[data-theme="dark"] .st-btn, .dark .st-btn { color: #d5d8ee; border-color: rgba(129, 140, 248, .3); }
[data-theme="dark"] .st-btn-primary, .dark .st-btn-primary { color: #fff; }

/* ── Sidebar rail (collapsed, icons only) ─────────────────────────────── */
.rs-rail-btn { display: none; width: 1.9rem; height: 1.9rem; place-items: center; border-radius: 8px; color: #8b8fa7; flex-shrink: 0;
    transition: background-color var(--rs-fast) var(--rs-ease), color var(--rs-fast) var(--rs-ease); }
.rs-rail-btn:hover { background: rgba(99, 102, 241, .1); color: var(--rs-accent); }
.rs-rail-btn svg { width: 1.1rem; height: 1.1rem; transition: transform var(--rs-base) var(--rs-ease); }
@media (min-width: 1024px) {
    .rs-rail-btn { display: grid; }
    html #sidebar { transition: width var(--rs-base) var(--rs-ease), transform var(--rs-base) var(--rs-ease); }
    html #main-content { transition: padding-left var(--rs-base) var(--rs-ease); }

    html.rs-rail #sidebar { width: 4.5rem; }
    html.rs-rail #main-content { padding-left: 4.5rem; }
    html.rs-rail .rs-brand { flex-direction: column; justify-content: center; height: auto; padding: .75rem 0 .25rem; gap: .5rem; }
    html.rs-rail .rs-brand-text, html.rs-rail .rs-label, html.rs-rail .rs-chev,
    html.rs-rail .rs-sub, html.rs-rail .rs-tag { display: none; }
    html.rs-rail .rs-rail-btn svg { transform: rotate(180deg); }
    html.rs-rail .rs-nav, html.rs-rail .rs-foot { padding-left: .6rem; padding-right: .6rem; }
    html.rs-rail .rs-link, html.rs-rail .rs-head { justify-content: center; padding: 0; gap: 0; }
    html.rs-rail .rs-group-top { padding-bottom: .4rem; }
}

#rs-flyout { position: fixed; z-index: 70; min-width: 13.5rem; max-width: 18rem; padding: .4rem; border-radius: 14px;
    background: var(--rs-card-solid); border: 1px solid var(--rs-hairline); box-shadow: var(--rs-shadow-hover); animation: fadeIn .15s var(--rs-ease) both; }
#rs-flyout .rs-flyout-title { padding: .4rem .65rem .45rem; font-size: .72rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: #8b8fa7; }
#rs-flyout a { display: flex; align-items: center; height: 2.1rem; padding: 0 .65rem; border-radius: 8px; font-size: .85rem; color: #4b5068; white-space: nowrap; }
#rs-flyout a:hover { background: rgba(99, 102, 241, .08); color: var(--rs-ink); }
#rs-flyout a.active { background: rgba(99, 102, 241, .12); color: var(--rs-accent); font-weight: 600; }
#rs-flyout .rs-tag { margin-left: auto; }
[data-theme="dark"] #rs-flyout a { color: #b9bdd6; }
[data-theme="dark"] #rs-flyout a:hover { color: #fff; }
[data-theme="dark"] #rs-flyout a.active { color: #c7d2fe; background: rgba(129, 140, 248, .18); }
