/* ==========================================================================
   Rushd Unified — one design language for every page, sub-page and modal.
   Loaded AFTER crm-custom.css and crm-modern.css. Pages were built by several
   people with different markup, so this layer normalises what they share:
   page titles, primary actions, tabs, forms, tables, modals, mobile layout,
   and entrance motion. It never changes meaning colours (danger stays red).
   ========================================================================== */

:root {
    --ru-accent: #4f46e5;
    --ru-accent-hover: #4338ca;
    --ru-accent-soft: rgba(79, 70, 229, 0.10);
    --ru-accent-grad: linear-gradient(135deg, #5b54f0 0%, #7c3aed 100%);
    --ru-title: #14142b;
    --ru-muted: #6b7280;
    --ru-field-h: 2.6rem;
    --ru-field-radius: 12px;
    --ru-field-border: #dfe2ee;
    --ru-field-bg: #ffffff;
    --ru-gap: 1rem;
    --ru-page-pad: 1.5rem;
    --rs-radius: 18px;
}

[data-theme="dark"], .dark {
    --ru-accent-soft: rgba(129, 140, 248, 0.16);
    --ru-title: #f3f4ff;
    --ru-muted: #9aa3c7;
    --ru-field-border: rgba(255, 255, 255, 0.12);
    --ru-field-bg: rgba(255, 255, 255, 0.04);
}

/* ── Тёмная тема: нативные выпадающие списки ────────────────────────────────
   Без color-scheme браузер рисует раскрытый список светлым, а текст пунктов остаётся светлым
   (наследуется от тёмного поля), и невыбранные пункты не видно. Тема говорит браузеру, что она тёмная,
   а цвета пунктов заданы явно на случай прозрачного фона списка. */
:is(.dark, [data-theme="dark"]) { color-scheme: dark; }
:is(.dark, [data-theme="dark"]) select option,
:is(.dark, [data-theme="dark"]) select optgroup { background-color: #1b1f2e; color: #e6e8f5; }
:is(.dark, [data-theme="dark"]) select option:checked { background-color: #4f46e5; color: #ffffff; }
:is(.dark, [data-theme="dark"]) select option:disabled { color: #6b7391; }
/* Активная вкладка: тёмно-индиговый акцент на тёмной карточке читался на 2.7:1 — в тёмной теме берём светлый индиго */
:is(.dark, [data-theme="dark"]) .ru-tab:hover,
:is(.dark, [data-theme="dark"]) .ru-tab.is-active,
:is(.dark, [data-theme="dark"]) .ru-seg button.is-active,
:is(.dark, [data-theme="dark"]) .ru-chip.is-active { color: #c7d2fe; }

@media (max-width: 767px) {
    :root { --ru-page-pad: 0.875rem; --rs-radius: 16px; }
}

/* ── Page titles: one size, one weight, solid ink ───────────────────────── */
main h1:not(.text-white):not(.rs-keep) {
    font-family: 'Outfit', 'Inter', sans-serif;
    font-size: clamp(1.3rem, 1.05rem + 0.9vw, 1.7rem) !important;
    line-height: 1.2 !important;
    font-weight: 700 !important;
    letter-spacing: -0.02em;
    color: var(--ru-title);
    background: none !important;
    -webkit-text-fill-color: currentColor !important;
}

main h1 + p,
main h1 ~ p.text-sm {
    color: var(--ru-muted);
    font-size: 0.875rem;
    line-height: 1.45;
    margin-top: 0.25rem;
}

/* Hero-style header cards are calmer: compact padding, no oversize gaps */
main .card-glass.p-6:has(> div > h1:not(.text-white)),
main .card-glass.p-8:has(> div > h1:not(.text-white)) {
    padding: 1rem 1.25rem;
}

@media (max-width: 767px) {
    main .card-glass.p-6,
    main .card-glass.p-8 { padding: 1rem; }
}

/* ── Primary actions: a single accent colour ────────────────────────────── */
main :is(a, button, input[type="submit"]):is(.bg-emerald-600, .bg-blue-600, .bg-purple-600, .bg-violet-600, .bg-indigo-600, .bg-pink-600).text-white,
.modal-shell :is(a, button):is(.bg-emerald-600, .bg-blue-600, .bg-purple-600, .bg-violet-600, .bg-indigo-600).text-white,
#modal-header-actions :is(a, button) {
    background: var(--ru-accent-grad) !important;
    border-color: transparent !important;
    color: #fff !important;
    border-radius: 12px;
    font-weight: 600;
    box-shadow: 0 1px 0 rgba(255, 255, 255, 0.22) inset, 0 8px 18px -8px rgba(79, 70, 229, 0.55);
}

main :is(a, button, input[type="submit"]):is(.bg-emerald-600, .bg-blue-600, .bg-purple-600, .bg-violet-600, .bg-indigo-600, .bg-pink-600).text-white:hover,
#modal-header-actions :is(a, button):hover {
    filter: brightness(1.06);
    transform: translateY(-1px);
}

/* Secondary (outlined/gray) actions share one look */
main :is(a, button).bg-white.border,
main :is(a, button).bg-gray-100.text-gray-700,
main :is(a, button).bg-gray-100.text-gray-600 {
    border-radius: 12px;
    font-weight: 600;
}

/* ── Tabs / filter pills: one pattern ───────────────────────────────────── */
.rs-tabs,
main nav[aria-label*="ab"],
main [role="tablist"] {
    display: flex;
    gap: 0.25rem;
    overflow-x: auto;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
}

.rs-tabs::-webkit-scrollbar,
main [role="tablist"]::-webkit-scrollbar { display: none; }

/* ── Forms: one rhythm for every create/edit form and modal ─────────────── */
form label.block,
form label[for] {
    font-size: 0.8125rem;
    font-weight: 600;
    letter-spacing: 0;
    text-transform: none;
    color: var(--ru-title);
    margin-bottom: 0.3rem;
}

form label.uppercase {
    text-transform: none;
    letter-spacing: 0;
    font-size: 0.8125rem;
}

form :is(input:not([type="checkbox"]):not([type="radio"]):not([type="hidden"]):not([type="range"]):not([type="file"]):not([type="color"]), select) {
    min-height: var(--ru-field-h);
    border-radius: var(--ru-field-radius);
    border-color: var(--ru-field-border);
    background-color: var(--ru-field-bg);
    font-size: 0.9rem;
}

form textarea {
    border-radius: var(--ru-field-radius);
    border-color: var(--ru-field-border);
    background-color: var(--ru-field-bg);
    font-size: 0.9rem;
}

form :is(input[type="text"], input[type="email"], input[type="tel"], input[type="url"], input[type="number"], input[type="password"], input[type="date"], input[type="datetime-local"], input[type="search"], select, textarea) {
    max-width: 100%;
}

form .helptext,
form .text-xs.text-gray-500 { color: var(--ru-muted); }

form .errorlist,
form ul.errorlist {
    list-style: none;
    margin: 0.25rem 0 0;
    padding: 0;
    color: #e11d48;
    font-size: 0.78rem;
}

/* Form label with no visible control (hidden field) must not show */
form label:has(+ input[type="hidden"]:last-child) { display: none; }

/* ── Modals ──────────────────────────────────────────────────────────────── */
#modal-content { scroll-behavior: smooth; }

#modal-content form { padding: 0.75rem 1rem 1rem; }

/* hidden inputs (csrf) come first in space-y forms and used to push the first block down */
#modal-content form > div:first-of-type { margin-top: 0; }

@media (max-width: 639px) {
    #modal-content form { padding: 0.625rem 0.75rem 0.875rem; }
}

/* Modal entrance: lift + fade; backdrop fades */
@keyframes ru-modal-in {
    from { opacity: 0; transform: translateY(14px) scale(0.98); }
    to   { opacity: 1; transform: none; }
}

[id*="modal"]:not(#modal-content):not([id*="actions"]):not([id*="source"]) > .card-glass,
[id*="modal"] > div > .card-glass:first-child {
    animation: ru-modal-in 0.28s var(--rs-ease) both;
}

/* ── Tables ──────────────────────────────────────────────────────────────── */
.ru-table-scroll {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    border-radius: inherit;
}

main table thead th {
    white-space: nowrap;
    color: var(--ru-muted);
    padding-top: 0.7rem;
    padding-bottom: 0.7rem;
}

main table tbody td { vertical-align: middle; }

/* ── Cards inside lists: consistent radius and breathing room ───────────── */
main .grid { gap: var(--ru-gap); }

/* ── Empty states ────────────────────────────────────────────────────────── */
.ru-empty {
    text-align: center;
    padding: 3rem 1rem;
    color: var(--ru-muted);
}

/* ── PWA banner: compact strip instead of a hero card ───────────────────── */
#pwa-install-banner { margin-top: 0.5rem; }

#pwa-install-banner > .card-glass { padding: 0.55rem 0.75rem !important; border-radius: 14px; }

#pwa-install-banner h4 { font-size: 0.82rem; }

@media (max-width: 639px) {
    #pwa-install-banner { margin-left: 0.75rem; margin-right: 0.75rem; }
    #pwa-install-banner > .card-glass {
        flex-direction: row !important;
        align-items: center !important;
        gap: 0.5rem !important;
    }
    #pwa-install-banner p,
    #pwa-install-banner .rounded-full { display: none !important; }
    #pwa-install-banner .w-10 { width: 2rem; height: 2rem; border-radius: 10px; }
    #pwa-install-banner .flex.items-center.gap-2.w-full { width: auto !important; }
    #pwa-install-banner #pwa-dismiss-btn span { display: none; }
    #pwa-install-btn { min-height: 34px !important; padding: 0.35rem 0.8rem !important; }
}

/* ── Mobile layout fixes (Android / iOS) ─────────────────────────────────── */
@media (max-width: 767px) {
    main { padding-left: var(--ru-page-pad) !important; padding-right: var(--ru-page-pad) !important; }

    /* page header rows: stack title and actions, let actions wrap */
    main .flex.items-center.justify-between,
    main .flex.justify-between.items-center {
        flex-wrap: wrap;
        gap: 0.65rem;
    }

    main .flex.items-center.justify-between > .flex.items-center.gap-2:last-child,
    main .flex.items-center.justify-between > .flex.gap-2:last-child,
    main .flex.items-center.justify-between > .flex.gap-3:last-child {
        flex-wrap: wrap;
    }

    main h1 { overflow-wrap: anywhere; }

    /* long page titles in the top bar must not push the buttons out */
    #breadcrumb-page-title {
        max-width: 42vw;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
        font-size: 1rem;
    }

    /* wide tables scroll inside their card, never the whole page */
    main table { min-width: 36rem; }

    /* stat strips: two per row, no orphan stretched across the screen */
    main .grid.grid-cols-1.sm\:grid-cols-2 > :last-child:nth-child(odd),
    main .grid.grid-cols-2 > :last-child:nth-child(odd),
    main .rs-kpis > :last-child:nth-child(odd) { grid-column: 1 / -1; }

    /* keep content clear of the floating buttons and iOS home bar */
    main { padding-bottom: calc(6rem + env(safe-area-inset-bottom, 0px)) !important; }

    /* comfortable touch targets */
    main :is(a, button).btn-primary,
    main :is(a, button).btn-secondary { min-height: 2.5rem; }

    /* modals become near-fullscreen sheets */
    #modal-content { max-height: calc(100dvh - 4.5rem); }
}

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

/* iOS zooms inputs under 16px; keep them 16px on phones */
@media (max-width: 767px) {
    input:not([type="checkbox"]):not([type="radio"]):not([type="range"]),
    select,
    textarea { font-size: 16px !important; }
}

/* ── Entrance motion (CSS only, so nothing is ever stuck invisible) ─────── */
@keyframes ru-rise {
    from { opacity: 0; transform: translateY(10px); }
    to   { opacity: 1; transform: none; }
}

main.animate-fade-in { animation: none; }

main > *:not(script):not(style):not(.rs-reveal) {
    animation: ru-rise 0.45s var(--rs-ease) both;
}

main > *:nth-child(2) { animation-delay: 0.04s; }
main > *:nth-child(3) { animation-delay: 0.08s; }
main > *:nth-child(4) { animation-delay: 0.12s; }
main > *:nth-child(n+5) { animation-delay: 0.16s; }

main .grid > .card-glass,
main .grid > a.card-glass {
    animation: ru-rise 0.45s var(--rs-ease) both;
}

main .grid > :nth-child(2) { animation-delay: 0.05s; }
main .grid > :nth-child(3) { animation-delay: 0.10s; }
main .grid > :nth-child(4) { animation-delay: 0.15s; }
main .grid > :nth-child(5) { animation-delay: 0.20s; }
main .grid > :nth-child(n+6) { animation-delay: 0.24s; }

main table tbody tr { animation: ru-rise 0.35s var(--rs-ease) both; }
main table tbody tr:nth-child(2) { animation-delay: 0.03s; }
main table tbody tr:nth-child(3) { animation-delay: 0.06s; }
main table tbody tr:nth-child(4) { animation-delay: 0.09s; }
main table tbody tr:nth-child(n+5) { animation-delay: 0.12s; }

@media (prefers-reduced-motion: reduce) {
    main > *, main .grid > *, main table tbody tr,
    [id*="modal"] .card-glass { animation: none !important; }
}

/* ── Reusable components ─────────────────────────────────────────────────── */
/* Segmented tabs: <nav class="ru-tabs"><a class="ru-tab is-active">…</a></nav> */
.ru-tabs {
    display: inline-flex;
    max-width: 100%;
    gap: 0.25rem;
    padding: 0.25rem;
    border-radius: 14px;
    background: var(--ru-accent-soft);
    overflow-x: auto;
    scrollbar-width: none;
}

.ru-tabs::-webkit-scrollbar { display: none; }

.ru-tab {
    flex: 0 0 auto;
    padding: 0.45rem 0.95rem;
    border-radius: 10px;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--ru-muted);
    white-space: nowrap;
    transition: background-color var(--rs-fast) var(--rs-ease), color var(--rs-fast) var(--rs-ease), box-shadow var(--rs-base) var(--rs-ease);
}

.ru-tab:hover { color: var(--ru-accent); }

.ru-tab.is-active {
    background: var(--rs-card-solid);
    color: var(--ru-accent);
    box-shadow: 0 1px 2px rgba(23, 23, 70, 0.08), 0 6px 14px -8px rgba(79, 70, 229, 0.4);
}

/* Filter bar: fields and the apply button on one tidy row */
.ru-filter {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 0.75rem;
}

.ru-filter label { font-size: 0.8125rem; font-weight: 600; color: var(--ru-title); }

.ru-filter select,
.ru-filter input { margin-top: 0.25rem; min-height: var(--ru-field-h); border-radius: var(--ru-field-radius); }

/* Neutral dark buttons become the accent too */
main :is(a, button).bg-gray-900.text-white,
main :is(a, button).bg-gray-800.text-white {
    background: var(--ru-accent-grad) !important;
    border-radius: 12px;
}

/* ── Toolbar pattern (clients, deals, orders, tasks, leads) on phones ───── */
@media (max-width: 767px) {
    main .toolbar { flex-wrap: wrap !important; padding-left: 0.75rem; padding-right: 0.75rem; gap: 0.5rem; }
    main .toolbar-search-wrap { flex: 1 1 100% !important; max-width: 100% !important; min-width: 0; }
    main .toolbar > .flex-shrink-0.ml-auto,
    main .toolbar > .ml-auto {
        flex: 1 1 100%;
        flex-wrap: wrap;
        margin-left: 0 !important;
        justify-content: flex-start;
        min-width: 0;
    }
    main .toolbar > .ml-auto > * { min-width: 0; }
}

@media (max-width: 767px) {
    /* grid children may shrink below their content, so nothing pushes the page wider */
    main .grid > * { min-width: 0; }

    /* underline-style tab rows scroll sideways instead of widening the page */
    main :has(> a.border-b-2),
    main :has(> button.border-b-2) {
        display: flex;
        flex-wrap: nowrap;
        overflow-x: auto;
        scrollbar-width: none;
        max-width: 100%;
    }
    main :has(> a.border-b-2) > a,
    main :has(> button.border-b-2) > button { flex: 0 0 auto; white-space: nowrap; padding-left: 1rem; padding-right: 1rem; }
}

/* FullCalendar on phones: toolbar wraps, title shrinks, view stays inside the card */
@media (max-width: 767px) {
    .fc { max-width: 100%; }
    .fc .fc-toolbar { flex-wrap: wrap; justify-content: center; gap: 0.5rem; }
    .fc .fc-toolbar-title { font-size: 1.05rem; }
    .fc .fc-button { padding: 0.35rem 0.6rem; font-size: 0.8rem; }
    .fc .fc-view-harness { overflow-x: auto; }
}

/* Modal header actions never wrap; on phones the title yields space to the button */
#modal-header-actions :is(a, button) { white-space: nowrap; }

@media (max-width: 639px) {
    #modal-header-actions :is(a, button) { padding: 0.4rem 0.8rem; font-size: 0.8rem; min-height: 2.25rem; }
    #modal-header-actions :is(a, button) svg { display: none; }
}

/* ── Dark theme: pastel badges written without dark: variants ──────────── */
:is(.dark, [data-theme="dark"]) main [class*="bg-blue-50"]:not([class*="dark:bg"]):not(.card-glass):not([class*="hover:bg"]):where(span, a, td, div[class*="rounded"], p), :is(.dark, [data-theme="dark"]) main [class*="bg-blue-100"]:not([class*="dark:bg"]):not(.card-glass):not([class*="hover:bg"]):where(span, a, td, div[class*="rounded"], p) { background-color: rgba(59,130,246, 0.16) !important; color: #93c5fd !important; border-color: rgba(59,130,246, 0.3); }
:is(.dark, [data-theme="dark"]) main [class*="bg-purple-50"]:not([class*="dark:bg"]):not(.card-glass):not([class*="hover:bg"]):where(span, a, td, div[class*="rounded"], p), :is(.dark, [data-theme="dark"]) main [class*="bg-purple-100"]:not([class*="dark:bg"]):not(.card-glass):not([class*="hover:bg"]):where(span, a, td, div[class*="rounded"], p) { background-color: rgba(168,85,247, 0.16) !important; color: #d8b4fe !important; border-color: rgba(168,85,247, 0.3); }
:is(.dark, [data-theme="dark"]) main [class*="bg-violet-50"]:not([class*="dark:bg"]):not(.card-glass):not([class*="hover:bg"]):where(span, a, td, div[class*="rounded"], p), :is(.dark, [data-theme="dark"]) main [class*="bg-violet-100"]:not([class*="dark:bg"]):not(.card-glass):not([class*="hover:bg"]):where(span, a, td, div[class*="rounded"], p) { background-color: rgba(139,92,246, 0.16) !important; color: #c4b5fd !important; border-color: rgba(139,92,246, 0.3); }
:is(.dark, [data-theme="dark"]) main [class*="bg-indigo-50"]:not([class*="dark:bg"]):not(.card-glass):not([class*="hover:bg"]):where(span, a, td, div[class*="rounded"], p), :is(.dark, [data-theme="dark"]) main [class*="bg-indigo-100"]:not([class*="dark:bg"]):not(.card-glass):not([class*="hover:bg"]):where(span, a, td, div[class*="rounded"], p) { background-color: rgba(99,102,241, 0.16) !important; color: #a5b4fc !important; border-color: rgba(99,102,241, 0.3); }
:is(.dark, [data-theme="dark"]) main [class*="bg-red-50"]:not([class*="dark:bg"]):not(.card-glass):not([class*="hover:bg"]):where(span, a, td, div[class*="rounded"], p), :is(.dark, [data-theme="dark"]) main [class*="bg-red-100"]:not([class*="dark:bg"]):not(.card-glass):not([class*="hover:bg"]):where(span, a, td, div[class*="rounded"], p) { background-color: rgba(239,68,68, 0.16) !important; color: #fca5a5 !important; border-color: rgba(239,68,68, 0.3); }
:is(.dark, [data-theme="dark"]) main [class*="bg-rose-50"]:not([class*="dark:bg"]):not(.card-glass):not([class*="hover:bg"]):where(span, a, td, div[class*="rounded"], p), :is(.dark, [data-theme="dark"]) main [class*="bg-rose-100"]:not([class*="dark:bg"]):not(.card-glass):not([class*="hover:bg"]):where(span, a, td, div[class*="rounded"], p) { background-color: rgba(244,63,94, 0.16) !important; color: #fda4af !important; border-color: rgba(244,63,94, 0.3); }
:is(.dark, [data-theme="dark"]) main [class*="bg-pink-50"]:not([class*="dark:bg"]):not(.card-glass):not([class*="hover:bg"]):where(span, a, td, div[class*="rounded"], p), :is(.dark, [data-theme="dark"]) main [class*="bg-pink-100"]:not([class*="dark:bg"]):not(.card-glass):not([class*="hover:bg"]):where(span, a, td, div[class*="rounded"], p) { background-color: rgba(236,72,153, 0.16) !important; color: #f9a8d4 !important; border-color: rgba(236,72,153, 0.3); }
:is(.dark, [data-theme="dark"]) main [class*="bg-green-50"]:not([class*="dark:bg"]):not(.card-glass):not([class*="hover:bg"]):where(span, a, td, div[class*="rounded"], p), :is(.dark, [data-theme="dark"]) main [class*="bg-green-100"]:not([class*="dark:bg"]):not(.card-glass):not([class*="hover:bg"]):where(span, a, td, div[class*="rounded"], p) { background-color: rgba(34,197,94, 0.16) !important; color: #86efac !important; border-color: rgba(34,197,94, 0.3); }
:is(.dark, [data-theme="dark"]) main [class*="bg-emerald-50"]:not([class*="dark:bg"]):not(.card-glass):not([class*="hover:bg"]):where(span, a, td, div[class*="rounded"], p), :is(.dark, [data-theme="dark"]) main [class*="bg-emerald-100"]:not([class*="dark:bg"]):not(.card-glass):not([class*="hover:bg"]):where(span, a, td, div[class*="rounded"], p) { background-color: rgba(16,185,129, 0.16) !important; color: #6ee7b7 !important; border-color: rgba(16,185,129, 0.3); }
:is(.dark, [data-theme="dark"]) main [class*="bg-teal-50"]:not([class*="dark:bg"]):not(.card-glass):not([class*="hover:bg"]):where(span, a, td, div[class*="rounded"], p), :is(.dark, [data-theme="dark"]) main [class*="bg-teal-100"]:not([class*="dark:bg"]):not(.card-glass):not([class*="hover:bg"]):where(span, a, td, div[class*="rounded"], p) { background-color: rgba(20,184,166, 0.16) !important; color: #5eead4 !important; border-color: rgba(20,184,166, 0.3); }
:is(.dark, [data-theme="dark"]) main [class*="bg-cyan-50"]:not([class*="dark:bg"]):not(.card-glass):not([class*="hover:bg"]):where(span, a, td, div[class*="rounded"], p), :is(.dark, [data-theme="dark"]) main [class*="bg-cyan-100"]:not([class*="dark:bg"]):not(.card-glass):not([class*="hover:bg"]):where(span, a, td, div[class*="rounded"], p) { background-color: rgba(6,182,212, 0.16) !important; color: #67e8f9 !important; border-color: rgba(6,182,212, 0.3); }
:is(.dark, [data-theme="dark"]) main [class*="bg-sky-50"]:not([class*="dark:bg"]):not(.card-glass):not([class*="hover:bg"]):where(span, a, td, div[class*="rounded"], p), :is(.dark, [data-theme="dark"]) main [class*="bg-sky-100"]:not([class*="dark:bg"]):not(.card-glass):not([class*="hover:bg"]):where(span, a, td, div[class*="rounded"], p) { background-color: rgba(14,165,233, 0.16) !important; color: #7dd3fc !important; border-color: rgba(14,165,233, 0.3); }
:is(.dark, [data-theme="dark"]) main [class*="bg-amber-50"]:not([class*="dark:bg"]):not(.card-glass):not([class*="hover:bg"]):where(span, a, td, div[class*="rounded"], p), :is(.dark, [data-theme="dark"]) main [class*="bg-amber-100"]:not([class*="dark:bg"]):not(.card-glass):not([class*="hover:bg"]):where(span, a, td, div[class*="rounded"], p) { background-color: rgba(245,158,11, 0.16) !important; color: #fcd34d !important; border-color: rgba(245,158,11, 0.3); }
:is(.dark, [data-theme="dark"]) main [class*="bg-yellow-50"]:not([class*="dark:bg"]):not(.card-glass):not([class*="hover:bg"]):where(span, a, td, div[class*="rounded"], p), :is(.dark, [data-theme="dark"]) main [class*="bg-yellow-100"]:not([class*="dark:bg"]):not(.card-glass):not([class*="hover:bg"]):where(span, a, td, div[class*="rounded"], p) { background-color: rgba(234,179,8, 0.16) !important; color: #fde047 !important; border-color: rgba(234,179,8, 0.3); }
:is(.dark, [data-theme="dark"]) main [class*="bg-orange-50"]:not([class*="dark:bg"]):not(.card-glass):not([class*="hover:bg"]):where(span, a, td, div[class*="rounded"], p), :is(.dark, [data-theme="dark"]) main [class*="bg-orange-100"]:not([class*="dark:bg"]):not(.card-glass):not([class*="hover:bg"]):where(span, a, td, div[class*="rounded"], p) { background-color: rgba(249,115,22, 0.16) !important; color: #fdba74 !important; border-color: rgba(249,115,22, 0.3); }

/* Toolbars must sit below the sticky top bar (z-30) so its dropdowns (notifications, profile) are never covered */
main .toolbar { z-index: 20 !important; }

/* The modal loader wraps forms in an extra p-4/p-6 box; the form already pads itself, so drop the doubled gap */
#modal-content > div[class*="p-4"],
#modal-content > div[class*="p-5"],
#modal-content > div[class*="p-6"] { padding: 0 !important; }

#modal-content :is(div, section):has(> form) { padding: 0 !important; }
#modal-content > div[class^="p-"],
#modal-content > div[class*=" p-"] { padding: 0 !important; }
#modal-content .tfm { padding: 0.75rem !important; }
#modal-content form.tfm-grid { padding: 0; }
#modal-content .tfm-section { padding: 0.75rem 1rem; }

/* ── Unsaved-changes confirmation ────────────────────────────────────────── */
.ru-confirm {
    position: fixed;
    inset: 0;
    z-index: 6000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    background: rgba(17, 24, 39, 0.42);
    -webkit-backdrop-filter: blur(2px);
    backdrop-filter: blur(2px);
    animation: ru-fade 0.18s var(--rs-ease) both;
}

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

.ru-confirm__card {
    width: 100%;
    max-width: 22rem;
    padding: 1.75rem 1.5rem 1.25rem;
    border-radius: 24px;
    background: var(--rs-card-solid);
    border: 1px solid var(--rs-hairline);
    box-shadow: 0 40px 80px -24px rgba(15, 15, 60, 0.5);
    text-align: center;
    animation: ru-modal-in 0.26s var(--rs-ease) both;
}

.ru-confirm__icon {
    width: 3.25rem;
    height: 3.25rem;
    margin: 0 auto 1rem;
    display: grid;
    place-items: center;
    border-radius: 50%;
    background: radial-gradient(circle at 30% 30%, rgba(251, 191, 36, 0.28), rgba(245, 158, 11, 0.14));
    color: #d97706;
}

.ru-confirm__title { margin: 0 0 0.4rem; font-size: 1.15rem; font-weight: 700; color: var(--ru-title); letter-spacing: -0.01em; }
.ru-confirm__text { margin: 0 auto 1.4rem; max-width: 17rem; font-size: 0.875rem; color: var(--ru-muted); line-height: 1.5; }
.ru-confirm__actions { display: flex; flex-direction: column; gap: 0.5rem; }

.ru-confirm__btn {
    width: 100%;
    min-height: 2.75rem;
    padding: 0.55rem 1rem;
    border-radius: 14px;
    border: 1px solid var(--ru-field-border);
    background: transparent;
    color: var(--ru-title);
    font-size: 0.9rem;
    font-weight: 600;
    line-height: 1.2;
    cursor: pointer;
    transition: transform var(--rs-fast) var(--rs-ease), background-color var(--rs-fast) var(--rs-ease), border-color var(--rs-fast) var(--rs-ease), box-shadow var(--rs-base) var(--rs-ease);
}

.ru-confirm__btn:hover { background: var(--ru-accent-soft); border-color: rgba(99, 102, 241, 0.4); }
.ru-confirm__btn:active { transform: scale(0.98); }
.ru-confirm__btn:focus-visible { outline: 2px solid rgba(99, 102, 241, 0.7); outline-offset: 2px; }

.ru-confirm__btn--primary {
    border-color: transparent;
    color: #fff;
    background: var(--ru-accent-grad);
    box-shadow: 0 10px 22px -10px rgba(79, 70, 229, 0.7);
}

.ru-confirm__btn--primary:hover { background: var(--ru-accent-grad); filter: brightness(1.07); border-color: transparent; }

/* destructive choice is a quiet text button, so it is never hit by accident */
.ru-confirm__btn--danger {
    min-height: 2.25rem;
    border-color: transparent;
    color: #e11d48;
    font-weight: 600;
    font-size: 0.85rem;
    margin-top: 0.15rem;
}

.ru-confirm__btn--danger:hover { background: rgba(225, 29, 72, 0.08); border-color: transparent; }

/* ── Client interaction timeline ────────────────────────────────────────── */
.ru-tl { padding: 0.25rem 0.25rem 1rem; }

.ru-tl__filters { display: flex; gap: 0.4rem; overflow-x: auto; padding: 0.25rem 0 0.75rem; scrollbar-width: none; }
.ru-tl__filters::-webkit-scrollbar { display: none; }

.ru-chip {
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.35rem 0.75rem;
    border-radius: 999px;
    border: 1px solid var(--ru-field-border);
    background: transparent;
    color: var(--ru-muted);
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    transition: background-color var(--rs-fast) var(--rs-ease), color var(--rs-fast) var(--rs-ease), border-color var(--rs-fast) var(--rs-ease);
}

.ru-chip:hover { color: var(--ru-accent); border-color: rgba(99, 102, 241, 0.4); }
.ru-chip.is-active { background: var(--ru-accent-soft); color: var(--ru-accent); border-color: rgba(99, 102, 241, 0.45); }
.ru-chip__n { font-size: 0.7rem; padding: 0 0.35rem; border-radius: 999px; background: rgba(99, 102, 241, 0.12); }

.ru-tl__day {
    position: sticky;
    top: 0;
    z-index: 1;
    padding: 0.4rem 0;
    margin-top: 0.5rem;
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--ru-muted);
    background: linear-gradient(var(--rs-card-solid) 70%, transparent);
}

.ru-tl__list { list-style: none; margin: 0; padding: 0 0 0 0.25rem; position: relative; }
.ru-tl__list::before { content: ''; position: absolute; left: 1.05rem; top: 0.5rem; bottom: 0.5rem; width: 2px; background: var(--ru-field-border); }

.ru-tl__item { position: relative; display: flex; gap: 0.75rem; padding: 0.45rem 0; animation: ru-rise 0.35s var(--rs-ease) both; }

.ru-tl__dot {
    position: relative;
    z-index: 1;
    flex: 0 0 auto;
    width: 1.75rem;
    height: 1.75rem;
    display: grid;
    place-items: center;
    border-radius: 50%;
    font-size: 0.72rem;
    background: rgba(107, 114, 128, 0.14);
    color: #6b7280;
    box-shadow: 0 0 0 3px var(--rs-card-solid);
}

.ru-tl__dot[data-tone="emerald"] { background: rgba(16, 185, 129, 0.16); color: #059669; }
.ru-tl__dot[data-tone="sky"] { background: rgba(14, 165, 233, 0.16); color: #0284c7; }
.ru-tl__dot[data-tone="indigo"] { background: rgba(99, 102, 241, 0.16); color: #4f46e5; }
.ru-tl__dot[data-tone="violet"] { background: rgba(139, 92, 246, 0.16); color: #7c3aed; }
.ru-tl__dot[data-tone="amber"] { background: rgba(245, 158, 11, 0.18); color: #d97706; }
.ru-tl__dot[data-tone="rose"] { background: rgba(244, 63, 94, 0.14); color: #e11d48; }
.ru-tl__dot[data-tone="blue"] { background: rgba(59, 130, 246, 0.15); color: #2563eb; }
.ru-tl__dot[data-tone="yellow"] { background: rgba(234, 179, 8, 0.2); color: #a16207; }

.ru-tl__body { flex: 1; min-width: 0; padding-bottom: 0.25rem; }
.ru-tl__head { display: flex; align-items: baseline; justify-content: space-between; gap: 0.75rem; }
.ru-tl__title { font-size: 0.875rem; font-weight: 600; color: var(--ru-title); overflow-wrap: anywhere; }
a.ru-tl__title:hover { color: var(--ru-accent); }
.ru-tl__time { flex: 0 0 auto; font-size: 0.75rem; color: var(--ru-muted); }
.ru-tl__sub { margin-top: 0.1rem; font-size: 0.82rem; color: var(--ru-muted); overflow-wrap: anywhere; }
.ru-tl__who { margin-top: 0.1rem; font-size: 0.72rem; color: var(--ru-muted); opacity: 0.8; }

/* ── Kanban: column colours, column menu, add-column, priority tint ─────── */
.ru-dot { display: inline-block; width: 0.65rem; height: 0.65rem; border-radius: 50%; flex: 0 0 auto; background: #9ca3af; }
.ru-dot[data-color="gray"] { background: #9ca3af; }
.ru-dot[data-color="blue"] { background: #3b82f6; }
.ru-dot[data-color="indigo"] { background: #6366f1; }
.ru-dot[data-color="violet"] { background: #8b5cf6; }
.ru-dot[data-color="pink"] { background: #ec4899; }
.ru-dot[data-color="rose"] { background: #f43f5e; }
.ru-dot[data-color="amber"] { background: #f59e0b; }
.ru-dot[data-color="emerald"] { background: #10b981; }
.ru-dot[data-color="teal"] { background: #14b8a6; }
.ru-dot[data-color="sky"] { background: #0ea5e9; }

.ru-col-done { color: #10b981; font-size: 0.8rem; }

.ru-menu {
    position: absolute;
    right: 0;
    top: calc(100% + 4px);
    z-index: 60;
    min-width: 12.5rem;
    padding: 0.35rem;
    border-radius: 14px;
    background: var(--rs-card-solid);
    border: 1px solid var(--rs-hairline);
    box-shadow: 0 18px 40px -16px rgba(30, 30, 90, 0.35);
}

.ru-menu button {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    width: 100%;
    padding: 0.5rem 0.65rem;
    border-radius: 10px;
    font-size: 0.85rem;
    font-weight: 500;
    text-align: left;
    color: var(--ru-title);
}

.ru-menu button i { width: 1rem; text-align: center; font-size: 0.75rem; color: var(--ru-muted); }
.ru-menu button:hover { background: var(--ru-accent-soft); }
.ru-menu button.is-danger { color: #e11d48; }
.ru-menu button.is-danger i { color: #e11d48; }
.ru-menu button.is-danger:hover { background: rgba(225, 29, 72, 0.08); }

.ru-col-add {
    flex: 0 0 auto;
    min-width: 15rem;
    align-self: flex-start;
    background: transparent !important;
    border: 2px dashed var(--ru-field-border) !important;
    box-shadow: none !important;
    border-radius: 18px;
}

.ru-col-add button {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    width: 100%;
    padding: 0.9rem 1rem;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--ru-muted);
    transition: color var(--rs-fast) var(--rs-ease), background-color var(--rs-fast) var(--rs-ease);
}

.ru-col-add:hover { border-color: rgba(99, 102, 241, 0.5) !important; }
.ru-col-add button:hover { color: var(--ru-accent); background: var(--ru-accent-soft); border-radius: 16px; }

/* Task cards: soft priority tint + accent edge */
.crm-kanban-card[data-priority] {
    --pc: 99, 102, 241;
    background-image: linear-gradient(135deg, rgba(var(--pc), 0.10), rgba(var(--pc), 0) 60%);
    box-shadow: inset 3px 0 0 rgba(var(--pc), 0.75), 0 1px 2px rgba(23, 23, 70, 0.04);
    transition: box-shadow var(--rs-base) var(--rs-ease), transform var(--rs-base) var(--rs-ease), background-color var(--rs-base) var(--rs-ease);
}

.crm-kanban-card[data-priority="urgent"] { --pc: 244, 63, 94; }
.crm-kanban-card[data-priority="high"] { --pc: 249, 115, 22; }
.crm-kanban-card[data-priority="medium"] { --pc: 99, 102, 241; }
.crm-kanban-card[data-priority="low"] { --pc: 16, 185, 129; }

.crm-kanban-card[data-priority]:hover {
    transform: translateY(-2px);
    box-shadow: inset 3px 0 0 rgba(var(--pc), 0.95), 0 14px 26px -14px rgba(var(--pc), 0.55);
}

.ru-prio {
    align-self: flex-start;
    padding: 0.08rem 0.5rem;
    border-radius: 999px;
    font-size: 0.65rem;
    font-weight: 700;
    letter-spacing: 0.02em;
    color: rgb(var(--pc, 99, 102, 241));
    background: rgba(var(--pc, 99, 102, 241), 0.14);
}

.ru-prio[data-priority="urgent"] { --pc: 225, 29, 72; }
.ru-prio[data-priority="high"] { --pc: 234, 88, 12; }

:is(.dark, [data-theme="dark"]) .ru-prio[data-priority="urgent"] { --pc: 251, 113, 133; }
:is(.dark, [data-theme="dark"]) .ru-prio[data-priority="high"] { --pc: 251, 146, 60; }

/* Column colour picker in the column form */
.ru-swatches { display: flex; flex-wrap: wrap; gap: 0.6rem; margin-top: 0.35rem; }
.ru-swatch { position: relative; cursor: pointer; }
.ru-swatch input { position: absolute; opacity: 0; inset: 0; cursor: pointer; }
.ru-swatch .ru-dot { width: 1.75rem; height: 1.75rem; transition: transform var(--rs-fast) var(--rs-spring), box-shadow var(--rs-fast) var(--rs-ease); }
.ru-swatch:hover .ru-dot { transform: scale(1.12); }
.ru-swatch input:checked + .ru-dot { box-shadow: 0 0 0 3px var(--rs-card-solid), 0 0 0 5px rgba(99, 102, 241, 0.7); }
.ru-swatch input:focus-visible + .ru-dot { box-shadow: 0 0 0 3px var(--rs-card-solid), 0 0 0 5px #4f46e5; }

.ru-alert { padding: 0.6rem 0.8rem; border-radius: 12px; font-size: 0.85rem; color: #be123c; background: rgba(244, 63, 94, 0.1); border: 1px solid rgba(244, 63, 94, 0.25); }
.ru-hint { margin-top: 0.35rem; font-size: 0.78rem; color: var(--ru-muted); }
.ru-text { font-size: 0.9rem; line-height: 1.5; color: var(--ru-title); }
.ru-label { font-size: 0.8125rem; font-weight: 600; color: var(--ru-title); }

/* ── Modal header on phones: title + close on top, the action button on its own full-width row ── */
@media (max-width: 639px) {
    .ru-modal-head { flex-wrap: wrap; row-gap: 0.5rem; }
    .ru-modal-head > div:first-child { order: 1; flex: 1 1 0; min-width: 0; padding-right: 0; }
    .ru-modal-tools { display: contents; }
    .ru-modal-tools > #modal-header-actions { order: 3; flex: 1 1 100%; }
    .ru-modal-tools > #modal-header-actions:empty { display: none; }
    .ru-modal-tools > #modal-header-actions > :is(a, button) { flex: 1 1 auto; justify-content: center; min-height: 2.5rem; }
    .ru-modal-sep { display: none; }
    .ru-modal-tools > button { order: 2; }
    #modal-content { max-height: calc(100dvh - 7.5rem); }

    .ru-tab { padding: 0.4rem 0.65rem; font-size: 0.8rem; }
}

/* full-bleed pages (chat center) use negative margins; never let them add a sideways scrollbar */
main[class] { overflow-x: clip; }

/* Chat center: a framed card with breathing room on every side instead of a full-bleed layout */
.rs-inbox-shell {
    height: calc(100vh - 7.5rem);
    min-height: 28rem;
    border-radius: 22px;
    border: 1px solid var(--rs-hairline);
    box-shadow: var(--rs-shadow);
}

@media (max-width: 1023px) {
    .rs-inbox-shell { height: calc(100dvh - 10.5rem); border-radius: 18px; }
}

/* ── Task modal: tabs under the form (work log, comments, history, chats) ─ */
#task-modal-tabs .tfm-tabnav {
    display: flex;
    flex-wrap: nowrap;
    gap: 0.35rem;
    margin: 0.65rem 0.75rem 0;
    padding: 0.3rem;
    border: 0;
    border-radius: 16px;
    background: var(--ru-accent-soft);
    overflow-x: auto;
    scrollbar-width: none;
}

#task-modal-tabs .tfm-tabnav::-webkit-scrollbar { display: none; }

#task-modal-tabs .tfm-tab {
    flex: 1 1 0;
    min-width: max-content;
    padding: 0.55rem 1rem;
    border: 0;
    border-radius: 12px;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--ru-muted);
    white-space: nowrap;
    transition: background-color var(--rs-fast) var(--rs-ease), color var(--rs-fast) var(--rs-ease), box-shadow var(--rs-base) var(--rs-ease), transform var(--rs-fast) var(--rs-ease);
}

#task-modal-tabs .tfm-tab svg { opacity: 0.75; transition: transform var(--rs-base) var(--rs-spring), opacity var(--rs-fast) var(--rs-ease); }
#task-modal-tabs .tfm-tab:hover { color: var(--ru-accent); background: rgba(99, 102, 241, 0.08); border: 0; }
#task-modal-tabs .tfm-tab:hover svg { transform: scale(1.12); opacity: 1; }
#task-modal-tabs .tfm-tab:active { transform: scale(0.97); }

#task-modal-tabs .tfm-tab.is-active {
    color: var(--ru-accent);
    background: var(--rs-card-solid);
    box-shadow: 0 1px 2px rgba(23, 23, 70, 0.08), 0 8px 18px -10px rgba(79, 70, 229, 0.45);
}

#task-modal-tabs .tfm-tab.is-active svg { opacity: 1; }

#task-modal-tabs .tfm-tabbody { padding: 1rem 1.25rem 1.25rem; }
#task-modal-tabs .tfm-pane { animation: ru-fade 0.25s var(--rs-ease) both; }

@media (max-width: 639px) {
    #task-modal-tabs .tfm-tabnav { margin: 0.5rem 0.5rem 0; }
    #task-modal-tabs .tfm-tab { flex: 0 0 auto; padding: 0.5rem 0.8rem; }
    #task-modal-tabs .tfm-tabbody { padding: 0.75rem; }
}

/* ── Dialog (integrations: connect a messenger channel) ─────────────────── */
.ru-dialog {
    position: fixed;
    inset: 0;
    z-index: 5600;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    background: rgba(17, 24, 39, 0.55);
    -webkit-backdrop-filter: blur(4px);
    backdrop-filter: blur(4px);
    overflow-y: auto;
}

.ru-dialog__card {
    width: 100%;
    max-width: 38rem;
    margin: auto;
    border-radius: 24px;
    background: var(--rs-card-solid);
    border: 1px solid var(--rs-hairline);
    box-shadow: 0 40px 80px -24px rgba(15, 15, 60, 0.5);
    animation: ru-modal-in 0.26s var(--rs-ease) both;
}

.ru-dialog__head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: 1.1rem 1.4rem 0.9rem; border-bottom: 1px solid var(--rs-hairline); }
.ru-dialog__head h3 { margin: 0; font-size: 1.1rem; font-weight: 700; letter-spacing: -0.01em; color: var(--ru-title); }
.ru-dialog__close { padding: 0.4rem; border-radius: 10px; color: var(--ru-muted); transition: background-color var(--rs-fast) var(--rs-ease), color var(--rs-fast) var(--rs-ease); }
.ru-dialog__close:hover { background: var(--ru-accent-soft); color: var(--ru-accent); }
.ru-dialog__body { display: flex; flex-direction: column; gap: 1rem; padding: 1.1rem 1.4rem 1.3rem; }
.ru-dialog__foot { display: flex; justify-content: flex-end; gap: 0.6rem; padding-top: 0.9rem; border-top: 1px solid var(--rs-hairline); }

.ru-field { display: flex; flex-direction: column; gap: 0.3rem; min-width: 0; }
.ru-field label { font-size: 0.8125rem; font-weight: 600; color: var(--ru-title); }
.ru-field input,
.ru-field select,
.ru-field textarea {
    width: 100%;
    min-height: var(--ru-field-h);
    padding: 0.5rem 0.8rem;
    border: 1px solid var(--ru-field-border);
    border-radius: var(--ru-field-radius);
    background-color: var(--ru-field-bg);
    color: var(--ru-title);
    font-size: 0.9rem;
}

.ru-field input::placeholder { color: var(--ru-muted); opacity: 0.75; }
.ru-field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 0.8rem; }
@media (max-width: 560px) { .ru-field-row { grid-template-columns: 1fr; } }

.ru-check { display: flex; align-items: flex-start; gap: 0.6rem; font-size: 0.85rem; color: var(--ru-title); cursor: pointer; }
.ru-check input { margin-top: 0.2rem; width: 1rem; height: 1rem; accent-color: #4f46e5; }

/* Receive-mode cards (Long-Polling / Webhook) */
.ru-mode { margin: 0; padding: 0; border: 0; min-width: 0; }
.ru-mode legend { padding: 0; margin-bottom: 0.4rem; font-size: 0.8125rem; font-weight: 600; color: var(--ru-title); }
.ru-mode__grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0.6rem; }
@media (max-width: 560px) { .ru-mode__grid { grid-template-columns: 1fr; } }

.ru-mode__opt {
    position: relative;
    display: flex;
    gap: 0.65rem;
    padding: 0.8rem 0.85rem;
    border-radius: 16px;
    border: 1.5px solid var(--ru-field-border);
    background: var(--ru-field-bg);
    cursor: pointer;
    transition: border-color var(--rs-fast) var(--rs-ease), background-color var(--rs-fast) var(--rs-ease), box-shadow var(--rs-base) var(--rs-ease);
}

.ru-mode__opt:hover { border-color: rgba(99, 102, 241, 0.5); }
.ru-mode__opt.is-active { border-color: #6366f1; background: var(--ru-accent-soft); box-shadow: 0 8px 20px -12px rgba(79, 70, 229, 0.55); }
.ru-mode__opt input { position: absolute; opacity: 0; inset: 0; cursor: pointer; }
.ru-mode__icon { font-size: 1.25rem; line-height: 1.4; }
.ru-mode__text { display: flex; flex-direction: column; gap: 0.2rem; min-width: 0; }
.ru-mode__text b { font-size: 0.875rem; color: var(--ru-title); }
.ru-mode__text em { margin-left: 0.3rem; padding: 0.05rem 0.4rem; border-radius: 999px; font-size: 0.65rem; font-style: normal; font-weight: 700; color: #059669; background: rgba(16, 185, 129, 0.14); }
.ru-mode__text small { font-size: 0.75rem; line-height: 1.35; color: var(--ru-muted); }

/* Segmented switch in the channels table */
.ru-seg { display: inline-flex; padding: 0.2rem; gap: 0.15rem; border-radius: 12px; background: var(--ru-accent-soft); }
.ru-seg button { padding: 0.3rem 0.65rem; border-radius: 9px; font-size: 0.72rem; font-weight: 600; white-space: nowrap; color: var(--ru-muted); transition: background-color var(--rs-fast) var(--rs-ease), color var(--rs-fast) var(--rs-ease), box-shadow var(--rs-base) var(--rs-ease); }
.ru-seg button:hover:not(:disabled) { color: var(--ru-accent); }
.ru-seg button.is-active { background: var(--rs-card-solid); color: var(--ru-accent); box-shadow: 0 1px 2px rgba(23, 23, 70, 0.1); }
.ru-seg button:disabled { opacity: 0.6; cursor: progress; }
.ru-seg-note { max-width: 14rem; margin-top: 0.35rem; font-size: 0.7rem; line-height: 1.3; color: var(--ru-muted); white-space: normal; }
.ru-seg-note.is-error { color: #e11d48; }

/* ───────── Мессенджер внутренних чатов ───────── */
.message-item { position: relative; }
.message-item .rm-more {
    position: absolute; top: 4px; right: 4px; width: 24px; height: 24px; display: flex; align-items: center; justify-content: center;
    border-radius: 999px; border: 0; background: rgba(255,255,255,.85); color: #6b7280; opacity: 0; transition: opacity .15s; cursor: pointer;
    box-shadow: 0 1px 4px rgba(0,0,0,.12);
}
.message-item:hover .rm-more, .rm-more:focus-visible { opacity: 1; }
@media (hover: none) { .message-item .rm-more { display: none; } }
.dark .message-item .rm-more { background: rgba(31,41,55,.9); color: #d1d5db; }
.rm-author { font-size: 11px; font-weight: 600; color: #6366f1; margin-bottom: 2px; }
.rm-edited { opacity: .75; font-style: italic; }
.rm-tick { font-size: 11px; letter-spacing: -2px; }
.rm-tick.is-sent { color: rgba(199,210,254,.85); }
.rm-tick.is-read { color: #67e8f9; }
.rm-reactions { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 4px; }
.rm-chip {
    display: inline-flex; align-items: center; gap: 3px; padding: 1px 7px; border-radius: 999px; font-size: 12px; line-height: 18px;
    border: 1px solid rgba(107,114,128,.25); background: rgba(255,255,255,.7); color: #374151; cursor: pointer;
}
.rm-chip b { font-size: 11px; font-weight: 600; }
.rm-chip.is-mine { border-color: #6366f1; background: rgba(99,102,241,.15); }
.dark .rm-chip { background: rgba(55,65,81,.7); color: #e5e7eb; }
.rm-date-sep { display: flex; justify-content: center; margin: 12px 0 6px; }
.rm-date-sep span {
    font-size: 11px; font-weight: 500; padding: 2px 10px; border-radius: 999px; color: #6b7280;
    background: rgba(229,231,235,.8);
}
.dark .rm-date-sep span { background: rgba(55,65,81,.8); color: #d1d5db; }
.rm-menu {
    position: fixed; z-index: 400; min-width: 210px; padding: 6px; border-radius: 14px; background: #fff;
    border: 1px solid rgba(107,114,128,.2); box-shadow: 0 12px 32px rgba(0,0,0,.18);
}
.dark .rm-menu { background: #1f2937; border-color: rgba(75,85,99,.6); }
.rm-menu__quick { display: flex; gap: 2px; padding: 2px 2px 6px; border-bottom: 1px solid rgba(107,114,128,.15); margin-bottom: 4px; }
.rm-menu__quick button { flex: 1; font-size: 20px; padding: 4px 0; border: 0; background: none; border-radius: 8px; cursor: pointer; }
.rm-menu__quick button:hover { background: rgba(99,102,241,.12); }
.rm-menu__item {
    display: flex; align-items: center; gap: 10px; width: 100%; padding: 8px 10px; border: 0; background: none; border-radius: 8px;
    font-size: 14px; color: #111827; text-align: left; cursor: pointer;
}
.dark .rm-menu__item { color: #f3f4f6; }
.rm-menu__item:hover { background: rgba(99,102,241,.1); }
.rm-menu__item.is-danger { color: #dc2626; }
.rm-menu__icon { width: 20px; text-align: center; }
.rm-forward { position: fixed; inset: 0; z-index: 410; background: rgba(17,24,39,.5); display: flex; align-items: center; justify-content: center; padding: 16px; }
.rm-forward__card { width: 100%; max-width: 360px; max-height: 80vh; display: flex; flex-direction: column; gap: 10px; padding: 16px; border-radius: 16px; background: #fff; }
.dark .rm-forward__card { background: #1f2937; color: #f3f4f6; }
.rm-forward__card h3 { font-weight: 600; font-size: 16px; }
.rm-forward__list { overflow: auto; display: flex; flex-direction: column; gap: 2px; font-size: 14px; }
.rm-forward__list button { padding: 9px 10px; border: 0; background: none; border-radius: 8px; text-align: left; cursor: pointer; color: inherit; }
.rm-forward__list button:hover { background: rgba(99,102,241,.1); }
.rm-forward__cancel { padding: 8px; border: 0; border-radius: 10px; background: rgba(107,114,128,.12); cursor: pointer; color: inherit; }
