:root {
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --bg: #f4f6f9;
    --card-bg: #ffffff;
    --border: #e2e8f0;
    --text: #1e293b;
    --text-muted: #64748b;

    /* ---- Розширені токени дизайн-системи (SaaS-стиль) ----
       Не перевизначаються темами (render_theme_style() керує лише
       базовими 7 змінними вище) — це навмисно єдині для всіх тем
       нейтральні відтінки поверхонь/тіней/радіусів. */
    --surface-sunken: #f8fafc;
    --surface-hover: #f1f5f9;
    --border-strong: #cbd5e1;
    --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.05);
    --shadow-md: 0 1px 3px rgba(15, 23, 42, 0.06), 0 4px 12px rgba(15, 23, 42, 0.05);
    --shadow-lg: 0 8px 24px rgba(15, 23, 42, 0.10), 0 2px 6px rgba(15, 23, 42, 0.06);
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --focus-ring: 0 0 0 3px color-mix(in srgb, var(--primary) 20%, transparent);
    --sidebar-bg: #ffffff;
    --sidebar-border: #eef1f6;
    --sidebar-width: 248px;
    --gradient-primary: linear-gradient(135deg, var(--primary), color-mix(in srgb, var(--primary) 65%, #7c3aed));
    --ease-out: cubic-bezier(.16, 1, .3, 1);
}

* { box-sizing: border-box; }

html { -webkit-font-smoothing: antialiased; scroll-behavior: smooth; }

body {
    margin: 0;
    font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
    font-size: 14px;
    line-height: 1.5;
}

h1, h2, h3 { letter-spacing: -0.02em; font-weight: 700; }
h1 { font-size: 24px; }
h2 { font-size: 17px; }

/* ---- Базові keyframe-анімації дизайн-системи ---- */
@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}
@keyframes scaleIn {
    from { opacity: 0; transform: scale(.96); }
    to { opacity: 1; transform: scale(1); }
}
@keyframes softPulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(185, 28, 28, .35); }
    50% { box-shadow: 0 0 0 4px rgba(185, 28, 28, 0); }
}
@keyframes spin {
    to { transform: rotate(360deg); }
}
@keyframes driftA {
    0%, 100% { transform: translate(0, 0); }
    50% { transform: translate(20px, -16px); }
}
@keyframes driftB {
    0%, 100% { transform: translate(0, 0); }
    50% { transform: translate(-18px, 14px); }
}

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

.container {
    max-width: 960px;
    margin: 0 auto;
    padding: 24px 16px 48px;
}

.container.centered {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 90vh;
}

.topbar {
    background: var(--card-bg);
    border-bottom: 1px solid var(--border);
}

.topbar-inner {
    max-width: 1080px;
    margin: 0 auto;
    padding: 14px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 8px;
}

/* ---- Ліва група шапки клієнтського кабінету: логотип + "Нова заявка"/
   "Мої заявки" одразу після нього, зліва — не в правій навігації разом з
   меню користувача. ---- */
.topbar-left {
    display: flex;
    align-items: center;
    gap: 24px;
    flex-wrap: wrap;
}
.topbar-nav {
    display: flex;
    align-items: center;
}

/* Клієнтський кабінет лишається на класичній верхній панелі (як портали
   для кінцевих користувачів у Zendesk/Freshdesk) — лише візуально освіжений. */
.topbar.topbar-staff {
    background: var(--card-bg);
    box-shadow: var(--shadow-sm);
}
.topbar.topbar-staff .brand { color: var(--text); }
.topbar.topbar-staff nav a { color: var(--text-muted); }
.topbar.topbar-staff .user-name { color: var(--text); }

.brand-mark {
    width: 26px;
    height: 26px;
    border-radius: 8px;
    background: var(--gradient-primary);
    flex-shrink: 0;
}

.nav-user {
    padding: 5px 12px 5px 5px;
    border-radius: 999px;
    text-decoration: none;
    transition: background-color .15s ease, transform .15s var(--ease-out);
}
.nav-user:hover { background: var(--surface-hover); transform: translateY(-1px); }

.brand {
    font-weight: 700;
    font-size: 16px;
    color: var(--text);
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 8px;
    letter-spacing: -0.01em;
}

.brand-logo {
    height: 24px;
    width: auto;
    display: block;
}

.brand-logo-lg {
    height: 48px;
    width: auto;
    display: block;
    margin: 0 auto 16px;
}

nav {
    display: flex;
    align-items: center;
    gap: 16px;
}

nav a {
    color: var(--text-muted);
    text-decoration: none;
    font-size: 14px;
    font-weight: 500;
}
nav a:hover { color: var(--primary); }
nav a.active { color: var(--primary); font-weight: 700; }

/* ---- "Нова заявка"/"Мої заявки" у шапці клієнтського кабінету — стандартні
   кнопки .btn-primary/.btn-secondary (активна вкладка/неактивна), як і
   решта кнопок застосунку; .btn-secondary тут без стандартного
   margin-top, щоб не зсувалась відносно логотипа й меню користувача. ---- */
.topbar-nav { gap: 8px; }
.topbar-nav .btn.btn-secondary { margin-top: 0; border-color: transparent; }
.topbar-nav .btn.btn-secondary:hover { border-color: transparent; }
.topbar-nav .btn.btn-secondary.topbar-nav-active {
    background: var(--surface-sunken);
    font-weight: 700;
}

.user-name {
    font-size: 14px;
    color: var(--text-muted);
}

.btn-link {
    color: var(--primary) !important;
}

/* ---- Випадаюче меню користувача в шапці клієнтського кабінету (Профіль /
   Вилогінитися) — той самий тригер+спадне меню, що й app-user-trigger/
   app-user-dropdown у персоналу, але відкривається ВНИЗ від горизонтальної
   шапки (top: 100%), а не вгору від нижнього краю бічної панелі. ---- */
.client-user-menu { position: relative; }
.client-user-trigger {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 5px 10px 5px 5px;
    border-radius: 999px;
    background: transparent;
    border: none;
    cursor: pointer;
    font-family: inherit;
    color: var(--text);
    transition: background-color .15s ease, transform .15s var(--ease-out);
}
.client-user-trigger:hover { background: var(--surface-hover); transform: translateY(-1px); }
.client-user-trigger-chevron {
    color: var(--text-muted);
    width: 14px;
    height: 14px;
    flex-shrink: 0;
    display: inline-flex;
    transition: transform .2s var(--ease-out);
}
.client-user-trigger-chevron svg { width: 100%; height: 100%; }
.client-user-trigger.open .client-user-trigger-chevron { transform: rotate(180deg); }
.client-user-dropdown {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    width: 220px;
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    padding: 6px;
    z-index: 60;
    opacity: 0;
    visibility: hidden;
    transform: translateY(6px) scale(.97);
    transform-origin: top right;
    pointer-events: none;
    transition: opacity .15s var(--ease-out), transform .15s var(--ease-out), visibility 0s linear .15s;
}
.client-user-dropdown.open {
    opacity: 1;
    visibility: visible;
    transform: translateY(0) scale(1);
    pointer-events: auto;
    transition: opacity .15s var(--ease-out), transform .15s var(--ease-out), visibility 0s linear;
}
.client-user-dropdown a {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    padding: 8px 10px;
    border-radius: 6px;
    font-size: 13.5px;
    font-weight: 500;
    color: var(--text);
    text-decoration: none;
    text-align: left;
    transition: background-color .12s ease, transform .12s ease;
}
.client-user-dropdown a:hover { background: var(--surface-hover); transform: translateX(2px); }
.client-user-dropdown a.danger { color: #b91c1c; }

.card {
    background: var(--card-bg);
    border: 1px solid rgba(15, 23, 42, .06);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    padding: 24px;
    margin-bottom: 20px;
    animation: fadeInUp .4s var(--ease-out) both;
}

.auth-select, .auth-form {
    width: 100%;
    max-width: 380px;
    text-align: center;
}

.auth-form { text-align: left; }

.card h1 { margin-top: 0; }

label {
    display: block;
    margin-bottom: 16px;
    font-size: 14px;
    font-weight: 600;
    color: var(--text);
}

input[type=text], input[type=email], input[type=password], input[type=file],
input[type=number], input[type=date], input[type=datetime-local], textarea, select {
    display: block;
    width: 100%;
    margin-top: 6px;
    padding: 9px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-family: inherit;
    background: var(--card-bg);
    color: var(--text);
    transition: border-color .12s ease, box-shadow .12s ease;
}

input:focus, textarea:focus, select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: var(--focus-ring);
}

textarea { resize: vertical; }

.btn {
    display: inline-block;
    padding: 9px 16px;
    border-radius: var(--radius-sm);
    border: none;
    font-size: 14px;
    font-family: inherit;
    font-weight: 600;
    line-height: 1.5;
    cursor: pointer;
    text-decoration: none;
    text-align: center;
    transition: background-color .15s ease, box-shadow .15s ease, transform .15s var(--ease-out), filter .15s ease;
    position: relative;
}
.btn:active { transform: translateY(1px) scale(.98); }
.btn[disabled] { opacity: .55; cursor: not-allowed; transform: none !important; }

.btn-primary {
    background: var(--gradient-primary);
    color: #fff;
    box-shadow: var(--shadow-sm);
}
.btn-primary:hover:not([disabled]) {
    filter: brightness(1.06);
    box-shadow: var(--shadow-md);
    transform: translateY(-1px);
}

.btn-secondary {
    background: var(--card-bg);
    color: var(--text);
    border: 1px solid var(--border);
    margin-top: 8px;
}
.btn-secondary:hover:not([disabled]) {
    background: var(--surface-hover);
    border-color: var(--border-strong);
    transform: translateY(-1px);
    box-shadow: var(--shadow-sm);
}

.auth-select .btn { display: block; margin-top: 12px; }

.alert {
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    margin-bottom: 16px;
    font-size: 14px;
    border: 1px solid transparent;
}
.alert ul { margin: 0; padding-left: 18px; }
.alert-error { background: #fef2f2; color: #b91c1c; border-color: #fecaca; }
.alert-success { background: #f0fdf4; color: #15803d; border-color: #bbf7d0; }

/* ---- Панель фільтрів журналу аудиту (staff/settings_audit.php) — по стовпцю
   таблиці: дата від/до, автор, дія, текст у деталях. Поля в ряд, переносяться
   на вужчих екранах; кнопки "Знайти"/"Скинути" притиснуті до низу поля. ---- */
.audit-filter-form {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 12px;
}
.audit-filter-form label {
    flex: 1 1 160px;
    min-width: 140px;
    margin-bottom: 0;
}
.audit-filter-form label input, .audit-filter-form label select {
    min-width: 0;
}
.audit-filter-actions {
    display: flex;
    gap: 8px;
    flex: 0 0 auto;
}

/* ---- Таблиця, що не влазить у ширину екрана (багато колонок / довгі дії),
   скролиться сама всередині обгортки — сторінка при цьому не розтягується
   і не з'являється горизонтальний скрол на весь екран. ---- */
.table-responsive {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    border-radius: var(--radius-md);
}
.table-responsive .table { box-shadow: none; }

/* ---- Захист від "розпирання" грід-колонок широким вмістом (таблиці,
   рядки дій без переносу тощо): без min-width:0 грід-колонка не стискається
   нижче ширини свого вмісту і виштовхує сторінку в горизонтальний скрол. ---- */
.dashboard-layout > *,
.ticket-layout > *,
.settings-layout > *,
.report-layout > * {
    min-width: 0;
}

.table {
    width: 100%;
    border-collapse: collapse;
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
}
.table th, .table td {
    padding: 12px 16px;
    text-align: left;
    border-bottom: 1px solid var(--border);
    font-size: 13.5px;
}
.table th {
    background: var(--surface-sunken);
    font-weight: 600;
    color: var(--text-muted);
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}
.table tbody tr:last-child td { border-bottom: none; }
.table tbody tr { transition: background-color .12s ease, transform .12s ease; }
.clickable-row { cursor: pointer; }
.clickable-row:hover { background: var(--surface-hover); transform: translateX(2px); }

.badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 3px 10px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 600;
    line-height: 1.6;
    animation: fadeIn .3s ease both;
}
.badge::before {
    content: "";
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: currentColor;
    opacity: .55;
    flex-shrink: 0;
}
.badge-pending { background: #ede9fe; color: #5b21b6; }
.badge-open { background: #dbeafe; color: #1e40af; }
.badge-progress { background: #fef3c7; color: #92400e; }
.badge-waiting { background: #f3e8ff; color: #6b21a8; }
.badge-done { background: #dcfce7; color: #166534; }
.badge-archived { background: #e2e8f0; color: #475569; }
.badge-closed { background: #eef2ff; color: #3730a3; }
.badge-overdue { background: #fef2f2; color: #b91c1c; border: 1px solid #fecaca; animation: softPulse 2.2s ease-in-out infinite; }

.badge-low { background: #f1f5f9; color: #475569; }
.badge-medium { background: #e0f2fe; color: #075985; }
.badge-high { background: #ffedd5; color: #9a3412; }
.badge-critical { background: #fee2e2; color: #991b1b; }

.chart-card {
    background: var(--card-bg);
    border: 1px solid rgba(15, 23, 42, .06);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    padding: 20px;
    margin-bottom: 20px;
    animation: fadeInUp .4s var(--ease-out) both;
}

/* ---- Дашборд: ліворуч великі графіки (як і раніше), праворуч вузька
   колонка з пріоритетом + двома компактними віджетами. ---- */
.dashboard-layout {
    display: grid;
    grid-template-columns: 1fr 340px;
    gap: 20px;
    align-items: start;
}
@media (max-width: 900px) {
    .dashboard-layout { grid-template-columns: 1fr; }
}
.dashboard-main .chart-card:last-child,
.dashboard-side .chart-card:last-child { margin-bottom: 0; }
.mini-chart-wrap {
    position: relative;
    height: 260px;
}

.stat-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 12px;
    margin-bottom: 20px;
}
.stat-card {
    background: var(--card-bg);
    border: 1px solid rgba(15, 23, 42, .06);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    padding: 16px 18px;
    animation: fadeInUp .4s var(--ease-out) both;
    transition: transform .15s var(--ease-out), box-shadow .15s ease;
}
.stat-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-md); }
.stat-cards .stat-card:nth-child(1) { animation-delay: .02s; }
.stat-cards .stat-card:nth-child(2) { animation-delay: .07s; }
.stat-cards .stat-card:nth-child(3) { animation-delay: .12s; }
.stat-cards .stat-card:nth-child(4) { animation-delay: .17s; }
.stat-card-label { font-size: 12.5px; color: var(--text-muted); font-weight: 600; text-transform: uppercase; letter-spacing: .03em; }
.stat-card-value { font-size: 28px; font-weight: 800; margin-top: 4px; letter-spacing: -0.03em; }
.stat-card-value.stat-danger { color: #b91c1c; }

/* ---- Каталог типових заявок (client/dashboard.php): клієнт обирає готову
   "картку послуги" замість вільного тексту. Чіпи-фільтри перевикористовують
   .filter-tabs-scroll, лише додаючи стилі для <button> (там уже були <a>). ---- */
.filter-tabs button,
.filter-tabs-scroll button {
    font: inherit;
    background: transparent;
    border: none;
    cursor: pointer;
    color: var(--text-muted);
    padding: 7px 14px;
    border-radius: 6px;
    font-size: 13.5px;
    font-weight: 500;
    transition: background-color .15s ease, color .15s ease, transform .15s var(--ease-out), box-shadow .15s ease;
}
.filter-tabs-scroll button {
    display: flex;
    align-items: center;
    gap: 7px;
    flex-shrink: 0;
    padding: 8px 14px;
    border-radius: 999px;
    white-space: nowrap;
}
.filter-tabs button:hover,
.filter-tabs-scroll button:hover { color: var(--text); background: var(--surface-hover); transform: translateY(-1px); }
.filter-tabs button.active { background: var(--card-bg); color: var(--text); box-shadow: var(--shadow-sm); font-weight: 600; }
.filter-tabs-scroll button.active { background: var(--gradient-primary); color: #fff; box-shadow: var(--shadow-md); }

.catalog-hero { margin-bottom: 22px; }
.catalog-hero h1 { margin: 0 0 4px; font-size: 27px; letter-spacing: -0.02em; }
.catalog-hero p { margin: 0; color: var(--text-muted); font-size: 14.5px; }

/* ---- Каталог заявок: бічна панель категорій зліва (замість рядка чіпів, що
   або ховав категорії за горизонтальним скролом, або "стрибав" на кілька
   рядків) — стандартний патерн для 5-8 категорій у порталах самообслуговування
   (Zendesk Guide, Jira Service Management), той самий стиль, що й "Перегляди"
   у заявках персоналу. ---- */
.catalog-layout {
    display: grid;
    grid-template-columns: 220px 1fr;
    grid-template-areas: "sidebar grid";
    gap: 20px;
    align-items: start;
}
@media (max-width: 720px) {
    .catalog-layout {
        grid-template-columns: 1fr;
        grid-template-areas: "sidebar" "grid";
    }
}
/* Категорії + "Зв'язок із технічною підтримкою" — один блок в одній
   grid-комірці (не два окремі ряди, що ділили висоту зі сіткою плиток
   праворуч): раніше при фільтрації категорій висота сітки плиток
   змінювалась, і через це картка контакту "плавала" вгору-вниз. Тепер
   висота лівого сайдбару визначається лише його власним вмістом. */
.catalog-sidebar {
    grid-area: sidebar;
    display: flex;
    flex-direction: column;
    gap: 20px;
}
.catalog-categories {
    display: flex;
    flex-direction: column;
    gap: 2px;
    background: var(--surface-sunken);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    padding: 8px;
    margin-bottom: 0;
}
.catalog-category-link {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    width: 100%;
    gap: 10px;
    padding: 8px 10px;
    border-radius: var(--radius-sm);
    background: transparent;
    border: none;
    cursor: pointer;
    font: inherit;
    font-size: 13.5px;
    font-weight: 500;
    color: var(--text-muted);
    text-align: left;
    transition: background-color .15s ease, color .15s ease, transform .15s var(--ease-out);
}
.catalog-category-link:hover { background: var(--surface-hover); color: var(--text); }
.catalog-category-link.active {
    background: var(--card-bg);
    color: var(--text);
    font-weight: 600;
    box-shadow: var(--shadow-sm);
    animation: scaleIn .18s var(--ease-out);
}
.catalog-category-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    flex: 0 0 18px;
    opacity: .75;
}
.catalog-category-icon svg { width: 100%; height: 100%; }
.catalog-category-link.active .catalog-category-icon { opacity: 1; color: var(--primary); }
.catalog-category-label {
    flex: 1 1 auto;
    min-width: 0;
    text-align: left;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Під списком категорій зліва (не у верхній частині основної колонки з
   плитками, куди вона потрапляла без явного grid-area). */
.contact-card { margin-bottom: 0; }

.catalog-grid {
    grid-area: grid;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
    gap: 12px;
    margin-bottom: 28px;
}
.catalog-tile {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
    text-align: left;
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    padding: 16px;
    cursor: pointer;
    font: inherit;
    color: var(--text);
    animation: fadeInUp .35s var(--ease-out) both;
    transition: transform .15s var(--ease-out), box-shadow .15s ease, border-color .15s ease;
}
.catalog-tile:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-md);
    border-color: var(--border-strong);
}
.catalog-tile-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 42px;
    height: 42px;
    border-radius: var(--radius-sm);
    background: color-mix(in srgb, var(--primary) 12%, transparent);
    color: var(--primary);
    flex-shrink: 0;
}
.catalog-tile-icon svg { width: 21px; height: 21px; }
.catalog-tile-name { font-size: 14px; font-weight: 600; line-height: 1.35; }
.catalog-tile-other {
    border-style: dashed;
    border-color: var(--border-strong);
    background: var(--surface-sunken);
}
.catalog-tile-other .catalog-tile-icon { background: transparent; color: var(--text-muted); border: 1.5px dashed var(--border-strong); }

.catalog-section-title { margin: 0 0 14px; font-size: 18px; }

.filter-tabs {
    display: flex;
    gap: 4px;
    margin-bottom: 20px;
    flex-wrap: wrap;
    background: var(--surface-sunken);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 4px;
    width: fit-content;
}
.filter-tabs a {
    padding: 7px 14px;
    border-radius: 6px;
    text-decoration: none;
    font-size: 13.5px;
    font-weight: 500;
    color: var(--text-muted);
    background: transparent;
    transition: background-color .15s ease, color .15s ease, transform .15s var(--ease-out), box-shadow .15s ease;
}
.filter-tabs a:hover { color: var(--text); transform: translateY(-1px); }
.filter-tabs a.active {
    background: var(--card-bg);
    color: var(--text);
    box-shadow: var(--shadow-sm);
    font-weight: 600;
    animation: scaleIn .18s var(--ease-out);
}

/* ---- Рядок фільтрів заявок: іконка + назва + лічильник, завжди в один
   рядок (горизонтальний скрол замість переносу на вузьких колонках). ---- */
.filter-tabs-scroll {
    flex-wrap: nowrap;
    overflow-x: auto;
    max-width: 100%;
    border-radius: 999px;
    padding: 5px;
    -ms-overflow-style: none;
    scrollbar-width: none;
}
.filter-tabs-scroll::-webkit-scrollbar { display: none; }
.filter-tabs-scroll a {
    display: flex;
    align-items: center;
    gap: 7px;
    flex-shrink: 0;
    padding: 8px 14px 8px 10px;
    border-radius: 999px;
    white-space: nowrap;
}
.filter-tabs-scroll a:hover { background: var(--surface-hover); transform: translateY(-1px); }
.filter-tabs-scroll a.active {
    background: var(--gradient-primary);
    color: #fff;
    box-shadow: var(--shadow-md);
}
.filter-tab-icon {
    display: flex;
    width: 20px;
    height: 20px;
    flex-shrink: 0;
    color: inherit;
    opacity: .75;
}
.filter-tab-icon svg { width: 100%; height: 100%; }
.filter-tabs-scroll a.active .filter-tab-icon { opacity: 1; }
.filter-tab-count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 20px;
    height: 20px;
    padding: 0 6px;
    border-radius: 999px;
    font-size: 11.5px;
    font-weight: 700;
    background: var(--surface-sunken);
    color: var(--text-muted);
}
.filter-tabs-scroll a.active .filter-tab-count {
    background: rgba(255, 255, 255, .25);
    color: #fff;
}

/* ---- Панель "Перегляди" на сторінці "Заявки" (staff/tickets.php) — вертикальний
   список фільтрів над формою "Створити заявку" в правій колонці, за зразком
   Zendesk Agent Workspace / Freshdesk / Jira Service Management: ніколи не
   обрізається по ширині екрана (на відміну від рядка вкладок, якому
   доводилось або горизонтально скролитись, або переноситись), і всі пункти
   вирівняні по лівому краю — так само, як поля форми нижче. ---- */
.ticket-views {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 2px;
    background: var(--surface-sunken);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    padding: 8px;
    margin-bottom: 20px;
    animation: fadeInUp .4s var(--ease-out) both;
}
.ticket-view-link {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    width: 100%;
    gap: 10px;
    padding: 8px 10px;
    border-radius: var(--radius-sm);
    text-decoration: none;
    font-size: 13.5px;
    font-weight: 500;
    color: var(--text-muted);
    text-align: left;
    transition: background-color .15s ease, color .15s ease, transform .15s var(--ease-out);
}
.ticket-view-link:hover { background: var(--surface-hover); color: var(--text); }
.ticket-view-link.active {
    background: var(--card-bg);
    color: var(--text);
    font-weight: 600;
    box-shadow: var(--shadow-sm);
    animation: scaleIn .18s var(--ease-out);
}
.ticket-view-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    flex: 0 0 18px;
    opacity: .75;
}
.ticket-view-icon svg { width: 100%; height: 100%; }
.ticket-view-link.active .ticket-view-icon { opacity: 1; color: var(--primary); }
.ticket-view-label {
    flex: 1 1 auto;
    min-width: 0;
    text-align: left;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.ticket-view-count {
    flex-shrink: 0;
    min-width: 22px;
    height: 20px;
    padding: 0 6px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 999px;
    font-size: 11.5px;
    font-weight: 700;
    background: var(--card-bg);
    color: var(--text-muted);
}
.ticket-view-link.active .ticket-view-count {
    background: var(--gradient-primary);
    color: #fff;
}
.ticket-views-divider {
    height: 1px;
    background: var(--border);
    margin: 4px 6px;
}
.ticket-view-group-filter {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 4px 10px;
}
.ticket-view-group-filter select {
    flex: 1 1 auto;
    min-width: 0;
    font-size: 13px;
    padding: 6px 8px;
    margin: 0;
}

.hint { font-size: 13px; color: var(--text-muted); text-align: center; margin-top: 12px; }
.hint-inline { font-weight: 400; color: var(--text-muted); font-size: 12px; }

.theme-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 10px;
}

.theme-option {
    display: flex;
    flex-direction: column;
    gap: 8px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 10px;
    cursor: pointer;
    margin-bottom: 0;
    font-weight: 400;
    transition: transform .15s var(--ease-out), box-shadow .15s ease, border-color .15s ease;
}
.theme-option:hover { transform: translateY(-2px); box-shadow: var(--shadow-sm); }

.theme-option-active {
    border-color: var(--primary);
    box-shadow: 0 0 0 1px var(--primary);
    animation: scaleIn .2s var(--ease-out);
}

.theme-swatches {
    display: flex;
    gap: 4px;
}

.theme-swatches span {
    width: 20px;
    height: 20px;
    border-radius: 4px;
    border: 1px solid var(--border);
}

.theme-option-label {
    font-size: 13px;
    color: var(--text);
}

.ticket-layout {
    display: grid;
    grid-template-columns: 1fr 320px;
    gap: 20px;
    align-items: start;
}

@media (max-width: 720px) {
    .ticket-layout { grid-template-columns: 1fr; }
}

.ticket-actions {
    position: sticky;
    top: 20px;
}

/* Форма "Надіслати інструкцію" з бази знань у вкладці "Спілкування з
   клієнтом" (v1.4.4) -- пошук + список результатів у бічній панелі. */
.kb-send-results { display: flex; flex-direction: column; gap: 6px; margin-top: 10px; max-height: 360px; overflow-y: auto; }
.kb-send-result-item {
    display: flex; align-items: flex-start; justify-content: space-between; gap: 8px;
    padding: 8px 10px; border: 1px solid var(--border); border-radius: var(--radius-sm);
    background: var(--surface-sunken);
}
.kb-send-result-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.kb-send-result-text strong { font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.kb-send-result-space { font-size: 11px; color: var(--primary); }
.kb-send-result-snippet { font-size: 12px; color: var(--text-muted); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.kb-send-result-item .btn { flex-shrink: 0; }

/* Модальне вікно ручного перегляду дерева бази знань (v1.4.4) -- та сама
   розмітка дерева, що й на сторінці простору (.kb-page-tree/.kb-tree-node),
   лише рядок обирається подвійним кліком (додається в .kb-browse-selected
   внизу), а не окремою кнопкою -- звідси підсвітка обраного рядка й список
   "до відправки" з можливістю прибрати зайве перед натисканням "Відправити". */
.kb-browse-tree { max-height: 40vh; overflow-y: auto; margin-top: 10px; text-align: left; }
.kb-browse-space + .kb-browse-space { margin-top: 14px; }
.kb-browse-space-header { font-size: 12px; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: .03em; margin-bottom: 4px; }
.kb-tree-row[data-page-id] { cursor: pointer; }
.kb-browse-row-selected > .kb-page-tree-link { color: var(--primary); font-weight: 600; }
.kb-browse-row-selected { background: color-mix(in srgb, var(--primary) 10%, transparent); border-radius: var(--radius-sm); }
.kb-browse-selected {
    display: flex; flex-direction: column; gap: 6px; margin-top: 12px;
    padding-top: 10px; border-top: 1px solid var(--border);
    max-height: 160px; overflow-y: auto;
}
.kb-browse-selected-item {
    display: flex; align-items: center; justify-content: space-between; gap: 8px;
    padding: 6px 10px; border: 1px solid var(--border); border-radius: var(--radius-sm);
    background: var(--surface-sunken); font-size: 13px;
}
.kb-browse-selected-item span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.kb-browse-selected-remove {
    flex-shrink: 0; display: inline-flex; align-items: center; justify-content: center;
    width: 20px; height: 20px; border: none; background: none; padding: 0;
    color: var(--text-muted); cursor: pointer; border-radius: 50%;
}
.kb-browse-selected-remove:hover { background: var(--surface-hover); color: var(--text); }
.kb-browse-selected-remove svg { width: 12px; height: 12px; }

.contact-box {
    background: var(--surface-sunken);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 12px 14px;
    margin: 12px 0;
    font-size: 14px;
}

.contact-icon {
    font-style: normal;
    color: var(--text-muted);
}

.app-footer-credit a {
    color: var(--text-muted);
    font-weight: 600;
    text-decoration: underline;
    text-underline-offset: 2px;
}
.app-footer-credit a:hover { color: var(--primary); }
.app-footer-credit-sep { color: var(--border); }
.app-footer-version {
    margin: 0;
    padding: 0;
    font-size: 12.5px;
    font-family: inherit;
    font-variant-numeric: tabular-nums;
    color: var(--text-muted);
    background: none;
    border: none;
    cursor: pointer;
    text-decoration: underline dotted;
    text-underline-offset: 2px;
}
.app-footer-version:hover { color: var(--primary); }

/* ---- Вікно історії версій (клік по номеру версії в підвалі) ---- */
.changelog-modal {
    max-width: 640px;
    width: 92%;
    max-height: 82vh;
    display: flex;
    flex-direction: column;
    position: relative;
    text-align: left;
    padding-top: 36px;
}
.changelog-modal-body { overflow-y: auto; padding-right: 4px; }
.changelog-version { padding-bottom: 20px; margin-bottom: 20px; border-bottom: 1px solid var(--border); }
.changelog-version:last-child { border-bottom: none; margin-bottom: 0; padding-bottom: 0; }
.changelog-version-head { display: flex; align-items: baseline; gap: 10px; margin-bottom: 10px; }
.changelog-version-date { font-size: 12.5px; color: var(--text-muted); }
.changelog-version-head .badge { font-variant-numeric: tabular-nums; }
.changelog-version h4 { margin: 14px 0 6px; font-size: 13px; color: var(--text-muted); text-transform: uppercase; letter-spacing: .04em; }
.changelog-version h4:first-child { margin-top: 0; }
.changelog-version ul { margin: 0 0 4px; padding-left: 20px; }
.changelog-version li { margin-bottom: 8px; font-size: 13.5px; line-height: 1.55; color: var(--text); }
.changelog-version li strong { color: var(--text); }
.changelog-version li code { font-size: 12px; background: var(--surface-hover); padding: 1px 5px; border-radius: 4px; }
.changelog-version p { font-size: 13.5px; line-height: 1.55; color: var(--text); }

/* ---- Підпис розробника внизу кабінету (персонал і клієнт) — статичний
   рядок, що не залежить від жодних налаштувань сайту (не редагується
   адміном), в один рядок за зразком підвалів світових SaaS-продуктів. ---- */
.app-footer-credit {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    text-align: center;
    color: var(--text-muted);
    font-size: 12.5px;
    padding: 18px 28px;
    margin-top: 8px;
    border-top: 1px solid var(--border);
}
.app-footer-credit-row {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
    gap: 6px;
}

.history-entry {
    border-left: 3px solid var(--border);
    padding: 4px 0 4px 14px;
    margin-bottom: 10px;
}
.history-meta {
    font-size: 13px;
    color: var(--text-muted);
    font-weight: 600;
}
.history-comment {
    font-size: 14px;
    margin-top: 4px;
    white-space: pre-line;
}

.badge-blocked { background: #fee2e2; color: #991b1b; }
.badge-inactive { background: #f1f5f9; color: #64748b; }
.badge-role-admin { background: #ede9fe; color: #5b21b6; }
.badge-role-agent { background: #e0f2fe; color: #075985; }

.table-actions-cell { white-space: nowrap; }
.table-actions-cell form { display: inline-block; margin: 0 2px 0 0; }

.report-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 16px;
}

.report-card {
    background: var(--card-bg);
    border: 1px solid rgba(15, 23, 42, .06);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    padding: 18px;
    transition: transform .15s var(--ease-out), box-shadow .15s ease;
}
.report-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-md); }

.report-card h3 { margin-top: 0; margin-bottom: 6px; }
.report-card p { color: var(--text-muted); font-size: 13px; margin: 0 0 14px; }
.report-card .btn { margin-right: 6px; margin-bottom: 6px; }

.report-toolbar {
    display: flex;
    gap: 8px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}

.chat-list {
    max-height: 320px;
    overflow-y: auto;
    margin-bottom: 12px;
    padding-right: 4px;
}

.chat-bubble {
    background: var(--surface-sunken);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 8px 12px;
    margin-bottom: 8px;
}

.chat-bubble-meta {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-muted);
    margin-bottom: 3px;
}

.chat-bubble-text {
    font-size: 14px;
    white-space: pre-line;
}

.chat-attachment {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin-top: 6px;
    padding: 5px 10px;
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 12.5px;
}
.chat-attachment svg { width: 14px; height: 14px; flex-shrink: 0; color: var(--text-muted); }
.chat-attachment a { color: var(--primary); text-decoration: none; font-weight: 600; }
.chat-attachment a:hover { text-decoration: underline; }

/* ---- Чат із клієнтом (на відміну від внутрішніх нотаток для ІТ вище) —
   вхідні повідомлення клієнта виділені кольором і смужкою зліва, щоб одразу
   було видно, хто писав, навіть побіжним поглядом на список. ---- */
.chat-bubble-inbound {
    background: color-mix(in srgb, var(--primary) 6%, var(--surface-sunken));
    border-color: color-mix(in srgb, var(--primary) 25%, var(--border));
    box-shadow: inset 3px 0 0 var(--primary);
}
.chat-channel-badge {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    font-size: 10.5px;
    font-weight: 600;
    padding: 1px 7px;
    border-radius: 999px;
    background: var(--surface-sunken);
    color: var(--text-muted);
    margin-left: 6px;
    text-transform: uppercase;
    letter-spacing: .02em;
}
.chat-bubble-inbound .chat-channel-badge { background: var(--card-bg); }

.pagination {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    margin: 16px 0;
}

.pagination-link {
    display: inline-block;
    padding: 6px 12px;
    border-radius: var(--radius-sm);
    background: var(--surface-sunken);
    border: 1px solid var(--border);
    color: var(--text-muted);
    text-decoration: none;
    font-size: 13.5px;
    transition: background-color .15s ease, color .15s ease, transform .15s var(--ease-out), box-shadow .15s ease;
}
.pagination-link:hover { transform: translateY(-1px); box-shadow: var(--shadow-sm); color: var(--text); }

.pagination-link.active {
    background: var(--gradient-primary);
    color: #fff;
    border-color: transparent;
}

.survey-scale {
    display: flex;
    gap: 10px;
    margin-top: 6px;
}

.survey-scale label {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    font-weight: 400;
    font-size: 13px;
    margin-bottom: 0;
}

.survey-scale input[type=radio] {
    width: auto;
    margin: 0;
}

.nav-user {
    display: flex;
    align-items: center;
    gap: 8px;
}

.avatar-circle {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    object-fit: cover;
    border: 1px solid var(--border);
    display: block;
}

.avatar-circle-lg {
    width: 96px;
    height: 96px;
    border-radius: 50%;
    object-fit: cover;
    border: 1px solid var(--border);
    display: block;
    margin: 0 auto 12px;
}

.avatar-circle-sm {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    object-fit: cover;
    border: 1px solid var(--border);
    display: inline-block;
    vertical-align: middle;
    margin-right: 6px;
}

/* ---- Сторінка "Мій профіль": hero-картка з градієнтною шапкою й фото,
   що "виходить" за межі банера — плюс двоколонковий макет (форма зліва,
   зведення про акаунт справа), у стилі сучасних профілів (GitHub/Linear). ---- */
.profile-hero {
    padding: 0;
    overflow: hidden;
}
.profile-hero-cover {
    height: 96px;
    background: var(--gradient-primary);
}
.profile-hero-body {
    display: flex;
    align-items: flex-end;
    gap: 20px;
    padding: 0 28px 24px;
    margin-top: -48px;
    flex-wrap: wrap;
}
.profile-hero-avatar-wrap { flex-shrink: 0; }
.profile-hero-avatar-wrap .avatar-circle-lg,
.profile-hero-avatar-wrap .avatar-fallback-xl {
    margin: 0;
    border: 4px solid var(--card-bg);
    box-shadow: var(--shadow-md);
}
.avatar-fallback-xl {
    width: 96px;
    height: 96px;
    border-radius: 50%;
    background: var(--gradient-primary);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 34px;
    font-weight: 700;
    flex-shrink: 0;
}
.profile-hero-info { min-width: 0; padding-bottom: 6px; }
.profile-hero-info h1 { margin: 0 0 8px; font-size: 21px; }
.profile-hero-meta { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; color: var(--text-muted); font-size: 13.5px; }
.profile-hero-meta-item { display: inline-flex; align-items: center; gap: 5px; }
.profile-hero-meta-item svg { width: 14px; height: 14px; }

.profile-layout {
    display: grid;
    grid-template-columns: 1fr 320px;
    gap: 20px;
    align-items: start;
}
@media (max-width: 900px) {
    .profile-layout { grid-template-columns: 1fr; }
}
.profile-layout > * { min-width: 0; }

.profile-meta-list { display: flex; flex-direction: column; }
.profile-meta-row {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
}
.profile-meta-row:last-child { border-bottom: none; }
.profile-meta-row-text { min-width: 0; flex: 1; }
.profile-meta-row-label { display: block; font-size: 11px; text-transform: uppercase; letter-spacing: .04em; color: var(--text-muted); }
.profile-meta-row-value { display: block; font-size: 13.5px; font-weight: 600; color: var(--text); margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---- Telegram / MFA картки поруч у профілі (staff/profile.php, client/settings.php) ---- */
.profile-side-cards-row {
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
    align-items: stretch;
}
.profile-side-cards-row > .card {
    flex: 1 1 0;
    min-width: 320px;
    display: flex;
    flex-direction: column;
}
/* Кнопка дії (прив'язати Telegram / підключити застосунок) завжди внизу
   картки, навіть якщо тексту-підказки над нею більше в одній картці, ніж
   в іншій — так обидві кнопки лишаються на одній висоті. */
.profile-side-cards-row > .card > *:last-child { margin-top: auto; }

/* ---- Двофакторна автентифікація (MFA) ---- */
.mfa-shield-icon {
    width: 56px;
    height: 56px;
    margin: 0 auto 12px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: color-mix(in srgb, var(--primary) 12%, transparent);
    color: var(--primary);
}
.mfa-shield-icon svg { width: 28px; height: 28px; }

.mfa-otp-boxes {
    display: flex;
    justify-content: center;
    gap: 8px;
    margin: 18px 0;
}
.mfa-otp-boxes-sm { justify-content: flex-start; margin: 12px 0; }
/* Специфічність вища за глобальне input[type=text]{width:100%} (style.css:309) —
   інакше кожна цифра розтягується на всю ширину і клітинки переносяться в стовпчик. */
.mfa-otp-boxes .mfa-otp-box {
    flex: 0 0 44px;
    width: 44px;
    height: 52px;
    text-align: center;
    font-size: 22px;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    border-radius: var(--radius-sm, 8px);
    border: 1.5px solid var(--border);
    background: var(--surface);
    color: var(--text);
    transition: border-color .15s var(--ease-out), box-shadow .15s var(--ease-out);
}
.mfa-otp-boxes-sm .mfa-otp-box { flex-basis: 38px; width: 38px; height: 44px; font-size: 18px; }
.mfa-otp-box:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 18%, transparent);
}

.mfa-setup-wizard { display: flex; flex-direction: column; gap: 18px; text-align: left; }
.mfa-step { display: flex; gap: 12px; }
.mfa-step-num {
    flex: 0 0 auto;
    width: 26px;
    height: 26px;
    border-radius: 50%;
    background: color-mix(in srgb, var(--primary) 14%, transparent);
    color: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    font-weight: 700;
}
.mfa-step-body { flex: 1; min-width: 0; }
.mfa-step-body strong { display: block; font-size: 14px; margin-bottom: 2px; }
.mfa-step-body p { margin: 0; color: var(--text-muted); font-size: 13px; line-height: 1.5; }

.mfa-qr-wrap {
    display: flex;
    justify-content: center;
    padding: 14px;
    margin-top: 10px;
    background: #fff;
    border-radius: var(--radius-sm, 8px);
    width: fit-content;
}
.mfa-qr-code { width: 176px; height: 176px; }

.mfa-manual-key {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    margin-top: 6px;
}
.mfa-manual-key code {
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 13px;
    letter-spacing: .03em;
    padding: 6px 10px;
    background: var(--surface-hover);
    border-radius: 6px;
    color: var(--text);
}

/* ---- Пропозиція увімкнути MFA (банер одразу після входу) ---- */
.mfa-suggestion-banner {
    display: flex;
    align-items: center;
    gap: 14px;
    flex-wrap: wrap;
    padding: 14px 18px;
    margin-bottom: 20px;
    border-radius: var(--radius-lg, 12px);
    border: 1px solid color-mix(in srgb, var(--primary) 25%, var(--border));
    background: color-mix(in srgb, var(--primary) 7%, var(--surface));
}
.mfa-suggestion-banner-text { flex: 1; min-width: 200px; }
.mfa-suggestion-banner-text strong { display: block; font-size: 14px; margin-bottom: 2px; }
.mfa-suggestion-banner-text p { margin: 0; color: var(--text-muted); font-size: 13px; line-height: 1.5; }
.mfa-suggestion-banner-cta { flex: 0 0 auto; white-space: nowrap; }

/* Клікабельний аватар у hero — сам є кнопкою завантаження фото: наведення
   показує напівпрозорий оверлей з іконкою "змінити", як у сучасних SaaS
   (GitHub/Slack). Прихований input[type=file] — усередині цього ж <label>. */
.profile-avatar-edit {
    position: relative;
    display: block;
    width: 96px;
    height: 96px;
    border-radius: 50%;
    cursor: pointer;
}
.profile-avatar-edit input[type=file] {
    position: absolute;
    width: 1px;
    height: 1px;
    opacity: 0;
    overflow: hidden;
}
.profile-avatar-edit-overlay {
    position: absolute;
    inset: 0;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(15, 23, 42, .5);
    color: #fff;
    opacity: 0;
    transition: opacity .15s ease;
}
.profile-avatar-edit-overlay svg { width: 22px; height: 22px; }
.profile-avatar-edit:hover .profile-avatar-edit-overlay,
.profile-avatar-edit input[type=file]:focus-visible ~ .profile-avatar-edit-overlay {
    opacity: 1;
}

/* ============================================================
   App shell для кабінету техпідтримки — бокова панель (сайдбар)
   у стилі сучасних SaaS-продуктів service desk (Zendesk Agent
   Workspace, Jira Service Management, Freshdesk): іконка + підпис,
   активний пункт підсвічено, унизу — картка користувача з меню.
   Клієнтський кабінет (topbar.topbar-staff вище) навмисно лишається
   на класичній верхній панелі — так само, як портали кінцевих
   користувачів у цих самих продуктах.
   ============================================================ */

.app-shell {
    display: flex;
    min-height: 100vh;
    align-items: stretch;
}

.app-sidebar {
    width: var(--sidebar-width);
    flex-shrink: 0;
    background: var(--sidebar-bg);
    border-right: 1px solid var(--sidebar-border);
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
    z-index: 40;
}

.app-sidebar-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 18px 20px;
    font-weight: 700;
    font-size: 15px;
    color: var(--text);
    text-decoration: none;
    letter-spacing: -0.01em;
    border-bottom: 1px solid var(--sidebar-border);
}

.app-sidebar-nav {
    flex: 1;
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 2px;
    overflow-y: auto;
}

.app-nav-item {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    width: 100%;
    gap: 10px;
    padding: 9px 12px;
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    text-decoration: none;
    text-align: left;
    font-size: 13.5px;
    font-weight: 500;
    position: relative;
    transition: background-color .15s ease, color .15s ease, transform .15s var(--ease-out);
}
.app-nav-item:hover { background: var(--surface-hover); color: var(--text); transform: translateX(2px); }
.app-nav-item.active {
    background: linear-gradient(90deg, color-mix(in srgb, var(--primary) 12%, transparent), color-mix(in srgb, var(--primary) 4%, transparent));
    color: var(--primary-dark);
    font-weight: 600;
    /* inset, а не окремий зсунутий вліво елемент — так смужка ніколи не
       "вилазить" за межі пункту меню й не створює враження різних відступів
       між пунктами. */
    box-shadow: inset 3px 0 0 var(--primary);
    animation: fadeIn .2s ease both;
}
.app-nav-icon {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
    display: inline-flex;
    transition: transform .15s var(--ease-out);
}
.app-nav-icon svg { width: 100%; height: 100%; }
.app-nav-item:hover .app-nav-icon { transform: scale(1.1); }
/* Явний елемент для підпису (а не "голий" текстовий вузол одразу в
   flex-рядку) — так усі пункти меню мають ідентичну розмітку, і жоден не
   може випадково отримати інший відступ через різне форматування шаблону. */
.app-nav-label { flex: 1 1 auto; min-width: 0; text-align: left; }

.app-nav-badge {
    margin-left: auto;
    background: #fef2f2;
    color: #b91c1c;
    font-size: 11px;
    font-weight: 700;
    padding: 1px 7px;
    border-radius: 999px;
}

.app-sidebar-footer {
    padding: 10px;
    border-top: 1px solid var(--sidebar-border);
    position: relative;
}

.app-user-trigger {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    padding: 8px 10px;
    border-radius: var(--radius-sm);
    background: transparent;
    border: none;
    cursor: pointer;
    text-align: left;
    font-family: inherit;
    color: var(--text);
}
.app-user-trigger:hover { background: var(--surface-hover); }
.app-user-trigger .avatar-circle,
.app-user-trigger .avatar-fallback { flex-shrink: 0; }

.avatar-fallback {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--primary);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 700;
    flex-shrink: 0;
}

.app-user-name {
    font-size: 13px;
    font-weight: 600;
    color: var(--text);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.app-user-role {
    font-size: 11.5px;
    color: var(--text-muted);
}
.app-user-trigger-chevron {
    margin-left: auto;
    color: var(--text-muted);
    width: 14px;
    height: 14px;
    flex-shrink: 0;
    transition: transform .2s var(--ease-out);
}
.app-user-trigger.open .app-user-trigger-chevron { transform: rotate(180deg); }

.app-user-dropdown {
    position: absolute;
    bottom: calc(100% + 6px);
    left: 10px;
    right: 10px;
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-lg);
    padding: 6px;
    z-index: 50;
    opacity: 0;
    visibility: hidden;
    transform: translateY(6px) scale(.97);
    transform-origin: bottom;
    pointer-events: none;
    transition: opacity .15s var(--ease-out), transform .15s var(--ease-out), visibility 0s linear .15s;
}
.app-user-dropdown.open {
    opacity: 1;
    visibility: visible;
    transform: translateY(0) scale(1);
    pointer-events: auto;
    transition: opacity .15s var(--ease-out), transform .15s var(--ease-out), visibility 0s linear;
}
.app-user-dropdown a {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 10px;
    border-radius: 6px;
    font-size: 13.5px;
    color: var(--text);
    text-decoration: none;
    transition: background-color .12s ease, transform .12s ease;
}
.app-user-dropdown a:hover { background: var(--surface-hover); transform: translateX(2px); }
.app-user-dropdown a.danger { color: #b91c1c; }
.app-user-dropdown-divider { height: 1px; background: var(--border); margin: 4px 6px; }

.app-main {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.app-topbar {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px 28px;
    background: var(--card-bg);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 30;
}

/* Заголовок сторінки живе тільки в топбарі (на частині сторінок дубльований
   <h1> у контенті прибрано) — тому тут він основний: великий, темний,
   добре читається одразу під час завантаження сторінки. */
.app-topbar-title {
    font-size: 20px;
    font-weight: 700;
    margin: 0;
    letter-spacing: -0.02em;
    color: var(--text);
}

.sidebar-toggle {
    display: none;
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    width: 34px;
    height: 34px;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: var(--text);
    flex-shrink: 0;
}
.sidebar-toggle svg { width: 18px; height: 18px; }

.app-notif-bell-wrap {
    position: relative;
    margin-left: auto;
    flex-shrink: 0;
}
.app-notif-bell-trigger {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: transparent;
    border: 1px solid transparent;
    cursor: pointer;
    color: var(--text-muted);
    transition: background-color .12s ease, color .12s ease, border-color .12s ease;
}
.app-notif-bell-trigger svg { width: 19px; height: 19px; }
.app-notif-bell-trigger:hover,
.app-notif-bell-trigger.open {
    background: var(--surface-hover);
    color: var(--text);
    border-color: var(--border);
}
.app-notif-badge {
    position: absolute;
    top: 2px;
    right: 2px;
    min-width: 16px;
    height: 16px;
    padding: 0 4px;
    border-radius: 999px;
    background: #dc2626;
    color: #fff;
    font-size: 10px;
    font-weight: 700;
    line-height: 16px;
    text-align: center;
    box-shadow: 0 0 0 2px var(--card-bg);
}
.app-notif-dropdown {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    width: 340px;
    max-width: calc(100vw - 32px);
    max-height: 420px;
    overflow-y: auto;
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    z-index: 60;
    opacity: 0;
    visibility: hidden;
    transform: translateY(6px) scale(.97);
    transform-origin: top right;
    pointer-events: none;
    transition: opacity .15s var(--ease-out), transform .15s var(--ease-out), visibility 0s linear .15s;
}
.app-notif-dropdown.open {
    opacity: 1;
    visibility: visible;
    transform: translateY(0) scale(1);
    pointer-events: auto;
    transition: opacity .15s var(--ease-out), transform .15s var(--ease-out), visibility 0s linear;
}
.app-notif-dropdown-header {
    padding: 12px 14px;
    font-size: 13px;
    font-weight: 700;
    color: var(--text);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    background: var(--card-bg);
}
.app-notif-item {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 10px 14px;
    text-decoration: none;
    border-bottom: 1px solid var(--border);
    transition: background-color .12s ease;
}
.app-notif-item:last-child { border-bottom: none; }
.app-notif-item:hover { background: var(--surface-hover); }
.app-notif-item-icon {
    flex-shrink: 0;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}
.app-notif-item-icon svg { width: 15px; height: 15px; }
.app-notif-item-icon-new_ticket { background: rgba(37, 99, 235, .12); color: #2563eb; }
.app-notif-item-icon-overdue { background: rgba(220, 38, 38, .12); color: #dc2626; }
.app-notif-item-icon-client_message { background: rgba(22, 163, 74, .12); color: #16a34a; }
.app-notif-item-icon-status_changed { background: rgba(37, 99, 235, .12); color: #2563eb; }
.app-notif-item-icon-staff_message { background: rgba(22, 163, 74, .12); color: #16a34a; }
.app-notif-item-body { min-width: 0; }
.app-notif-item-text {
    display: block;
    font-size: 13px;
    color: var(--text);
    line-height: 1.4;
}
.app-notif-item-time {
    display: block;
    font-size: 11.5px;
    color: var(--text-muted);
    margin-top: 2px;
}
.app-notif-empty {
    padding: 24px 14px;
    text-align: center;
    font-size: 13px;
    color: var(--text-muted);
}

.app-sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.35);
    z-index: 39;
}

.app-content {
    flex: 1;
    max-width: 1600px;
    width: 100%;
    margin: 0 auto;
    padding: 24px 28px 48px;
}

@media (max-width: 900px) {
    .app-sidebar {
        position: fixed;
        left: 0;
        top: 0;
        transform: translateX(-100%);
        transition: transform .18s ease;
        box-shadow: var(--shadow-lg);
    }
    .app-sidebar.open { transform: translateX(0); }
    .sidebar-toggle { display: inline-flex; }
    .app-sidebar-backdrop.open { display: block; }
    .app-topbar { padding: 14px 16px; }
    .app-content { padding: 16px 16px 40px; }
}

/* ---- Освіжені сторінки входу (index/login/forgot/reset) ---- */
.container.centered {
    position: relative;
    overflow: hidden;
    isolation: isolate;
}
.container.centered::before,
.container.centered::after {
    content: "";
    position: absolute;
    z-index: -1;
    width: 55vmax;
    height: 55vmax;
    border-radius: 50%;
    filter: blur(2px);
    pointer-events: none;
}
.container.centered::before {
    top: -18%;
    left: -12%;
    background: radial-gradient(circle, color-mix(in srgb, var(--primary) 10%, transparent), transparent 60%);
    animation: driftA 22s ease-in-out infinite;
}
.container.centered::after {
    bottom: -20%;
    right: -14%;
    background: radial-gradient(circle, color-mix(in srgb, var(--primary) 8%, transparent), transparent 60%);
    animation: driftB 26s ease-in-out infinite;
}
.auth-form, .auth-select {
    box-shadow: var(--shadow-lg);
    border-radius: var(--radius-lg);
    padding: 32px 28px;
    animation: fadeInUp .45s var(--ease-out) both;
    position: relative;
}

/* ---- Модальні вікна (waiting / due-date) з анімованим відкриттям/закриттям ---- */
.modal-overlay {
    display: flex;
    align-items: center;
    justify-content: center;
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, .5);
    z-index: 50;
    opacity: 0;
    visibility: hidden;
    transition: opacity .18s var(--ease-out), visibility 0s linear .18s;
}
.modal-overlay.open {
    opacity: 1;
    visibility: visible;
    transition: opacity .18s var(--ease-out), visibility 0s linear;
}
.modal-overlay .card {
    transform: scale(.94) translateY(8px);
    opacity: 0;
    transition: transform .18s var(--ease-out), opacity .18s var(--ease-out);
}
.modal-overlay.open .card {
    transform: scale(1) translateY(0);
    opacity: 1;
}

/* ---- Картка-варіант вибору (радіо), напр. майстер увімкнення модуля бази знань ---- */
.radio-card { display: flex; align-items: flex-start; gap: 12px; border: 2px solid var(--border); border-radius: var(--radius-md, 10px); padding: 14px 16px; margin-top: 12px; cursor: pointer; }
.radio-card:hover { border-color: var(--primary-light, var(--primary)); }
.radio-card input { margin-top: 3px; flex-shrink: 0; }
.radio-card .radio-card-title { font-weight: 600; font-size: 14px; margin-bottom: 2px; display: block; }
.radio-card .radio-card-desc { font-size: 13px; color: var(--muted); line-height: 1.5; }
.radio-card:has(input:checked) { border-color: var(--primary); background: var(--primary-bg-subtle, rgba(59, 130, 246, .07)); }

/* ---- Вступний тур кабінету клієнта (client/dashboard.php) ---- */
.onboarding-modal {
    max-width: 420px;
    width: 90%;
    text-align: center;
    padding-top: 36px;
}
.onboarding-close {
    position: absolute;
    top: 12px;
    right: 12px;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    border: none;
    background: transparent;
    color: var(--text-muted);
    font-size: 18px;
    line-height: 1;
    cursor: pointer;
}
.onboarding-close:hover { background: var(--surface-hover); color: var(--text); }
.onboarding-step-icon {
    width: 56px;
    height: 56px;
    margin: 0 auto 16px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: color-mix(in srgb, var(--primary) 12%, transparent);
    color: var(--primary);
}
.onboarding-step-icon svg { width: 28px; height: 28px; }
.onboarding-step h2 { margin: 0 0 8px; font-size: 19px; }
.onboarding-step p { margin: 0; color: var(--text-muted); font-size: 14px; line-height: 1.5; }
.onboarding-progress {
    display: flex;
    justify-content: center;
    gap: 6px;
    margin: 20px 0 4px;
}
.onboarding-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--border-strong);
    transition: background-color .15s ease, transform .15s ease;
}
.onboarding-dot.active { background: var(--primary); transform: scale(1.3); }
.onboarding-controls {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 16px;
}
.onboarding-final-actions {
    display: flex;
    gap: 8px;
    justify-content: center;
    margin-top: 20px;
}

/* ============================================================
   Другий раунд полірування: контентні сторінки (дашборд, звіти,
   налаштування) виглядали "порожньо" й застаріло — плоскі числа,
   стос однакових полів без візуальної ієрархії. Додаємо кольорові
   іконки-чіпи, заголовки секцій з описом, порожні стани з іконкою
   та перемикачі замість чекбоксів — послідовно на всіх сторінках.
   ============================================================ */

.icon-chip {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: var(--radius-sm);
    flex-shrink: 0;
}
.icon-chip svg { width: 20px; height: 20px; }
.icon-chip-sm { width: 32px; height: 32px; }
.icon-chip-sm svg { width: 16px; height: 16px; }
.icon-chip-lg { width: 52px; height: 52px; border-radius: var(--radius-md); }
.icon-chip-lg svg { width: 26px; height: 26px; }

.icon-chip-blue   { background: color-mix(in srgb, #2563eb 13%, transparent); color: #1d4ed8; }
/* На відміну від решти чипів вище (фіксовані кольори категорій), цей бере
   колір з налаштувань дизайну застосунку (--primary) — для елементів, що
   мають виглядати "фірмовими", а не позначати конкретну категорію/статус. */
.icon-chip-primary { background: color-mix(in srgb, var(--primary) 13%, transparent); color: var(--primary-dark); }
.icon-chip-amber  { background: color-mix(in srgb, #f59e0b 16%, transparent); color: #92400e; }
.icon-chip-purple { background: color-mix(in srgb, #a855f7 15%, transparent); color: #6b21a8; }
.icon-chip-red    { background: color-mix(in srgb, #ef4444 13%, transparent); color: #b91c1c; }
.icon-chip-green  { background: color-mix(in srgb, #22c55e 15%, transparent); color: #15803d; }
.icon-chip-indigo { background: color-mix(in srgb, #6366f1 15%, transparent); color: #4338ca; }
.icon-chip-slate  { background: var(--surface-sunken); color: var(--text-muted); border: 1px solid var(--border); }

/* Пікер іконки категорії каталогу заявок (staff/settings_templates.php) —
   звичайні radio-інпути, візуально сховані, лейбл стилізований під
   квадратну кнопку з іконкою; :has() дає активний стан без жодного JS. */
.icon-radio-group { display: flex; flex-wrap: wrap; gap: 8px; margin: 6px 0 16px; }
.icon-radio-group input[type="radio"] { position: absolute; opacity: 0; width: 0; height: 0; }
.icon-radio {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: var(--card-bg);
    color: var(--text-muted);
    cursor: pointer;
    transition: background-color .12s ease, color .12s ease, border-color .12s ease;
}
.icon-radio svg { width: 17px; height: 17px; }
.icon-radio:hover { background: var(--surface-hover); color: var(--text); }
.icon-radio:has(input:checked) {
    background: var(--gradient-primary);
    color: #fff;
    border-color: transparent;
}

/* Заголовок секції всередині картки: іконка + назва + короткий опис —
   замінює "голий" <h2>, дає візуальну ієрархію й контекст одразу. */
.section-head {
    display: flex;
    gap: 14px;
    align-items: flex-start;
    margin-bottom: 18px;
}
.section-head-text { min-width: 0; }
.section-head-text h2 { margin: 2px 0 3px; }
.section-head-text p { margin: 0; color: var(--text-muted); font-size: 13px; line-height: 1.45; }

/* Порожній стан (замість голого рядка тексту) — іконка + заголовок +
   коротке пояснення, по центру, з відступами. */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 44px 20px;
    gap: 10px;
    animation: fadeIn .3s ease both;
}
.empty-state .icon-chip { margin-bottom: 2px; }
.empty-state-title { font-size: 14px; font-weight: 600; color: var(--text); }
.empty-state-desc { font-size: 13px; color: var(--text-muted); max-width: 340px; line-height: 1.5; }

/* Список модулів (Налаштування -> Модулі) — дві картки в ряд замість однієї
   на всю ширину сторінки (з широким текстовим блоком картка виглядала
   розтягнутою й порожньою). */
.modules-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
    align-items: start;
}
@media (max-width: 720px) {
    .modules-grid { grid-template-columns: 1fr; }
}

/* Двоколонкова сітка для довгих форм налаштувань (LDAP/SMTP/IMAP) —
   замість одноколонкового "стовпчика" полів на всю ширину картки. */
.form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0 20px;
}
.form-grid > label { min-width: 0; }
.form-grid-full { grid-column: 1 / -1; }
@media (max-width: 720px) {
    .form-grid { grid-template-columns: 1fr; }
}

/* Модалка "Додати учасника" робочої групи: прокручуваний список кандидатів
   (замість пагінації — тут очікується короткий сеанс "знайшов і додав
   подвійним кліком", а не перегляд сторінками) і "чипи" вже обраних людей. */
.wg-candidates-scroll {
    max-height: 320px;
    overflow-y: auto;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
}
.wg-candidates-scroll table { margin: 0; }
.wg-candidate-row { cursor: pointer; }
.wg-candidate-row:hover { background: var(--surface-hover); }
.wg-staged-list {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 10px;
}
.wg-staged-chip { gap: 8px; }
.wg-staged-remove {
    border: none;
    background: none;
    cursor: pointer;
    color: inherit;
    font-weight: 700;
    line-height: 1;
    padding: 0;
}

/* Двоколонкове модальне вікно "Дії" на сторінці Налаштування → Користувачі:
   зліва — інформація/редагування профілю, справа — швидкі дії. */
.user-modal-split {
    display: grid;
    grid-template-columns: 1fr 220px;
    gap: 24px;
    align-items: start;
}
@media (max-width: 640px) {
    .user-modal-split { grid-template-columns: 1fr; }
}

/* Перемикач (toggle switch) замість стандартного чекбокса — скрізь,
   де чекбокс означає "увімкнути/вимкнути" (весь проєкт use-кейс:
   telegram/smtp/mailbox/ldap/workhours/survey/closure/remove-logo). */
input[type=checkbox] {
    appearance: none;
    -webkit-appearance: none;
    width: 38px;
    height: 22px;
    min-width: 38px;
    border-radius: 999px;
    background: var(--border-strong);
    position: relative;
    cursor: pointer;
    margin: 0;
    vertical-align: middle;
    transition: background-color .18s ease;
}
input[type=checkbox]::before {
    content: "";
    position: absolute;
    top: 2px;
    left: 2px;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #fff;
    box-shadow: 0 1px 2px rgba(15, 23, 42, .3);
    transition: transform .18s var(--ease-out);
}
input[type=checkbox]:checked {
    background: var(--gradient-primary);
}
input[type=checkbox]:checked::before {
    transform: translateX(16px);
}
input[type=checkbox]:focus-visible {
    box-shadow: var(--focus-ring);
    outline: none;
}
/* Виняток: компактний вибір днів тижня (7 в ряд) — залишається
   звичайним квадратним чекбоксом, повноцінний перемикач тут заважає. */
input[type=checkbox].native-checkbox {
    appearance: auto;
    -webkit-appearance: auto;
    width: auto;
    min-width: 0;
    height: auto;
    border-radius: 0;
    background: none;
}
input[type=checkbox].native-checkbox::before { content: none; }

/* ---- Оновлений вигляд KPI-карток дашборда: іконка-чіп + велике число ---- */
.stat-card-top {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    margin-bottom: 14px;
}

/* ---- Заголовок картки з графіком ---- */
.chart-card-head {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
}
.chart-card-head h2 { margin: 0; }
.chart-card-head p { margin: 2px 0 0; font-size: 12.5px; color: var(--text-muted); }

.btn-sm { padding: 6px 12px; font-size: 12.5px; }

/* Компактна кнопка "Додати" (пошук учасника на вкладці Робочі групи) —
   без сайзингу іконка <svg> успадковує розмір за замовчуванням і виглядає
   непропорційно великою поруч із полем пошуку, тому фіксуємо явно. */
.wg-add-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    white-space: nowrap;
}
.wg-add-btn svg { width: 17px; height: 17px; flex-shrink: 0; }

.btn-ghost {
    background: transparent;
    color: var(--text-muted);
    border: 1px solid var(--border);
}
.btn-ghost:hover:not([disabled]) {
    background: var(--surface-hover);
    color: var(--text);
    border-color: var(--border-strong);
    transform: translateY(-1px);
}

/* ---- Компактна кнопка-іконка (експорт CSV / надіслати на пошту тощо) ---- */
.icon-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    padding: 0;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: var(--card-bg);
    color: var(--text-muted);
    cursor: pointer;
    transition: background-color .15s ease, color .15s ease, border-color .15s ease, transform .15s var(--ease-out);
}
.icon-btn svg { width: 16px; height: 16px; }
.icon-btn:hover:not([disabled]) {
    background: var(--surface-hover);
    color: var(--text);
    border-color: var(--border-strong);
    transform: translateY(-1px);
}

.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;
}

/* ---- Макет сторінки "Користувачі": головний список + права панель
   (пошук і акордеон налаштувань) — ширша права колонка, ніж у картки
   заявки, бо всередині живуть форми (LDAP тощо). ---- */
.settings-layout {
    display: grid;
    grid-template-columns: 1fr 400px;
    gap: 20px;
    align-items: start;
}
@media (max-width: 900px) {
    .settings-layout { grid-template-columns: 1fr; }
}

/* ---- Звіти: зліва вибраний звіт (діаграма + таблиця), справа компактний
   список усіх звітів для перемикання — замість колишньої "стіни" з 7
   однаково великих карток над контентом. ---- */
.report-layout {
    display: grid;
    grid-template-columns: 1fr 320px;
    gap: 20px;
    align-items: start;
}
@media (max-width: 900px) {
    .report-layout { grid-template-columns: 1fr; }
}
.report-actions { position: sticky; top: 20px; }

/* overflow-x:hidden — жорсткий запобіжник: що б не намагалося розпирати
   список (задовгий текст, іконка тощо), воно обрізається тут, а не виштовхує
   пункт за межі колонки. */
.report-nav-list { display: flex; flex-direction: column; width: 100%; overflow-x: hidden; }
.report-nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    min-width: 0;
    box-sizing: border-box;
    padding: 12px 16px;
    text-decoration: none;
    color: var(--text);
    border-bottom: 1px solid var(--border);
    transition: background-color .15s ease;
}
.report-nav-item:last-child { border-bottom: none; }
.report-nav-item:hover { background: var(--surface-hover); }
.report-nav-item.active {
    background: color-mix(in srgb, var(--primary) 8%, transparent);
    box-shadow: inset 3px 0 0 var(--primary);
}
.report-nav-item.active .report-nav-title { color: var(--primary); }
.report-nav-text { flex: 1; min-width: 0; }
.report-nav-title { display: block; font-size: 13.5px; font-weight: 600; }
.report-nav-desc {
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    overflow: hidden;
    margin-top: 1px;
    font-size: 12px;
    line-height: 1.4;
    color: var(--text-muted);
    word-break: break-word;
}
/* Заголовок-розділювач ("Кастомні звіти") — рядок у тому самому
   flex-стовпчику .report-nav-list, а не окремий вкладений список: єдиний
   список без вкладених <nav> прибирає ризик різного розпирання блоків. */
.report-nav-section {
    width: 100%;
    box-sizing: border-box;
    padding: 14px 16px 6px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .04em;
    text-align: left;
    color: var(--text-muted);
    border-top: 1px solid var(--border);
}

/* ---- Режим редагування таблиці звіту: перемикання між звичайним
   (тільки читання) виглядом таблиці й панеллю редагування з чекбоксами —
   клас .report-editing на спільній обгортці вмикається кнопкою "олівець". ---- */
.report-edit-panel { display: none; }
.report-editing .report-view-table { display: none; }
.report-editing .report-edit-panel { display: block; }
.report-edit-cell { width: 36px; }
.report-edit-bar {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    margin-top: 12px;
}
.report-edit-counter { font-size: 12.5px; color: var(--text-muted); }
.report-edit-panel tr:has(input[name="keep_row[]"]:not(:checked)) {
    opacity: .4;
    text-decoration: line-through;
}

/* ---- Акордеон (нативні <details>/<summary> — без JS) ---- */
.accordion-item {
    border-bottom: 1px solid var(--border);
}
.accordion-item:last-child { border-bottom: none; }
.accordion-item summary {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 16px;
    cursor: pointer;
    list-style: none;
    font-weight: 600;
    font-size: 14px;
    color: var(--text);
    transition: background-color .15s ease;
}
.accordion-item summary::-webkit-details-marker { display: none; }
.accordion-item summary::marker { content: ""; }
.accordion-item summary:hover { background: var(--surface-hover); }
.accordion-summary-text { flex: 1; min-width: 0; }
.accordion-summary-desc { display: block; font-size: 12px; font-weight: 400; color: var(--text-muted); margin-top: 1px; }
.accordion-chevron {
    color: var(--text-muted);
    width: 16px;
    height: 16px;
    flex-shrink: 0;
    transition: transform .2s var(--ease-out);
}
.accordion-item[open] summary .accordion-chevron { transform: rotate(90deg); }
.accordion-item[open] summary { background: var(--surface-hover); }
.accordion-body {
    padding: 4px 16px 20px;
    animation: fadeIn .2s ease;
}
/* Права панель вузька — форми всередині акордеону лишаються в один
   стовпчик навіть там, де .form-grid деінде розбиває їх на два. */
.accordion-body .form-grid { grid-template-columns: 1fr; }

/* ============================================================
   Модуль "База знань" (modules/knowledge_base) — той самий стиль
   карток/кнопок, що й у решті кабінету.
   ============================================================ */

/* Зміст сторінки (TOC) — тепер рендериться всередині .kb-side-panel-body
   (правої колонки сторінки простору), заголовок панелі — сам <summary>. */
.kb-toc-list { display: flex; flex-direction: column; gap: 2px; }
.kb-toc-link {
    display: block;
    padding: 5px 8px;
    border-left: 2px solid transparent;
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
    color: var(--text-muted);
    text-decoration: none;
    font-size: 13px;
    line-height: 1.4;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    transition: background-color .15s ease, color .15s ease, border-color .15s ease;
}
.kb-toc-link:hover { background: var(--surface-hover); color: var(--text); border-color: var(--border-strong); }
.kb-toc-level-2 { padding-left: 18px; }
.kb-toc-level-3 { padding-left: 28px; font-size: 12.5px; }

/* Теги сторінки — чипи під заголовком, клікабельні (ведуть у пошук за тегом). */
.kb-tag-list { display: flex; flex-wrap: wrap; gap: 6px; margin: 10px 0 0; }
.kb-tag {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 10px;
    border-radius: 999px;
    background: var(--surface-sunken);
    color: var(--text-muted);
    font-size: 12.5px;
    font-weight: 600;
    text-decoration: none;
    border: 1px solid transparent;
    transition: background-color .15s ease, color .15s ease, border-color .15s ease;
}
.kb-tag svg { width: 12px; height: 12px; }
.kb-tag:hover { background: color-mix(in srgb, var(--primary) 10%, transparent); color: var(--primary); border-color: color-mix(in srgb, var(--primary) 25%, transparent); }

/* Поле вибору тегів (редактор сторінки) — чипи, що видаляються, +
   автодоповнення випадним списком, той самий патерн, що й у GitHub
   (мітки issue), Notion (multi-select) чи Gmail (одержувачі), замість
   голого текстового поля з comma-separated значенням. */
.kb-tag-input {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
    padding: 6px 8px;
    margin-top: 6px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--card-bg);
    position: relative;
    cursor: text;
}
.kb-tag-input:focus-within { border-color: var(--primary); box-shadow: var(--focus-ring); }
.kb-tag-input-field {
    flex: 1;
    min-width: 140px;
    border: none;
    outline: none;
    padding: 4px 2px;
    margin: 0;
    font: inherit;
    background: none;
}
.kb-tag-chip {
    display: inline-flex;
    align-items: center;
    gap: 2px;
    padding: 3px 4px 3px 10px;
    border-radius: 999px;
    background: color-mix(in srgb, var(--primary) 12%, transparent);
    color: var(--primary-dark);
    font-size: 12.5px;
    font-weight: 600;
    white-space: nowrap;
    flex-shrink: 0;
}
.kb-tag-chip-remove {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    border: none;
    background: none;
    color: inherit;
    cursor: pointer;
    font-size: 14px;
    line-height: 1;
    padding: 0;
}
.kb-tag-chip-remove:hover { background: color-mix(in srgb, var(--primary) 25%, transparent); }
.kb-tag-suggestions {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    margin-top: 4px;
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-md);
    z-index: 20;
    max-height: 220px;
    overflow-y: auto;
}
.kb-tag-suggestions.open { display: block; }
.kb-tag-suggestion {
    display: block;
    width: 100%;
    text-align: left;
    padding: 8px 12px;
    border: none;
    background: none;
    font: inherit;
    font-size: 13.5px;
    cursor: pointer;
    color: var(--text);
}
.kb-tag-suggestion:hover { background: var(--surface-hover); }

/* "Останні зміни" на головній сторінці простору — компактний список замість плиток. */
.kb-recent-list { display: flex; flex-direction: column; gap: 4px; }
.kb-recent-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 8px 10px;
    border-radius: var(--radius-sm);
    color: var(--text);
    text-decoration: none;
    font-size: 13.5px;
    transition: background-color .15s ease;
}
.kb-recent-item:hover { background: var(--surface-hover); }
.kb-recent-item > span:first-child { display: flex; align-items: center; gap: 6px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* Іконка простору/документа в рядку .kb-recent-item ніколи не мала явного
   розміру — сама лише flex-розмітка не обмежує SVG без width/height, тож
   вона рендерилась величезною (той самий баг, що вже лагодили в заголовках
   через .kb-section-title-icon/.app-nav-icon, тут просто не додали раніше). */
.kb-recent-item > span:first-child svg { width: 18px; height: 18px; flex-shrink: 0; }
/* Позначка "обмежений доступ" праворуч у рядку .kb-recent-item — самостійна
   іконка-замочок замість текстового бейджа. */
.kb-recent-item-icon { display: inline-flex; align-items: center; color: var(--text-muted); flex-shrink: 0; }
.kb-recent-item-icon svg { width: 14px; height: 14px; }
/* Загальний клас для дрібної іконки поруч із текстом (.hint-inline тощо) —
   та сама причина бага щоразу: __staff_icon() без обгортки з явним розміром
   рендериться величезною (браузерний розмір SVG за замовчуванням). Обгортати
   в цей клас, а не лишати "голою", у будь-якому новому місці модуля. */
.kb-inline-icon { display: inline-flex; align-items: center; flex-shrink: 0; }
.kb-inline-icon svg { width: 14px; height: 14px; }
/* .kb-recent-item подвійно використовується і як <a> (простори/останні документи),
   і як <button> (рядок шаблону, бо клік має відкрити вибір простору, а не одразу
   перейти) — скидаємо кнопкове хромування, лишаючи спільний вигляд рядка. */
button.kb-recent-item { border: none; background: none; font: inherit; text-align: left; width: 100%; cursor: pointer; }

/* Спільний двоколонковий каркас модуля — головна сторінка (широкий блок
   зліва: міні-дашборд/останні документи, вузька колонка просторів справа)
   і сторінка простору (контент зліва, навігація справа: недавні/зміст/дерево). */
.kb-two-col { display: flex; gap: 20px; align-items: flex-start; }
.kb-two-col-main { flex: 1; min-width: 0; }
.kb-two-col-side { width: 300px; flex-shrink: 0; display: flex; flex-direction: column; gap: 16px; }
@media (max-width: 900px) {
    .kb-two-col { flex-direction: column; }
    .kb-two-col-side { width: 100%; }
}
.kb-mini-stats { margin: 14px 0 22px; }
.kb-mini-stats .stat-card { padding: 12px 14px; }
.kb-mini-stats .stat-card-value { font-size: 22px; }

/* Заголовок розділу з іконкою (Простори / Шаблони для створення / Останні
   документи / Вкладення тощо) — той самий "іконка + підпис" патерн, що й
   пункт головного бічного меню (.app-nav-icon/.app-nav-label у header_staff.php),
   а не голий __staff_icon() без обмеження розміру просто в <h2>/<h3> (без
   цього іконка розтягується на весь блок — саме так і виглядав цей баг). */
.kb-section-title { display: flex; align-items: center; gap: 10px; margin: 0 0 14px; font-size: 15px; }
.kb-section-title-icon { width: 18px; height: 18px; flex-shrink: 0; display: inline-flex; color: var(--primary); }
.kb-section-title-icon svg { width: 100%; height: 100%; }

/* Останні документи — дві колонки з розділювальною лінією, як на макеті. */
.kb-recent-docs { column-count: 2; column-gap: 20px; column-rule: 1px solid var(--border); }
.kb-recent-docs .kb-recent-item { break-inside: avoid; margin-bottom: 2px; }
@media (max-width: 640px) {
    .kb-recent-docs { column-count: 1; }
}

.kb-side-list { display: flex; flex-direction: column; gap: 2px; }

.kb-page-tree, .kb-page-tree ul {
    list-style: none;
    margin: 0;
    padding: 0;
}
.kb-page-tree ul { padding-left: 14px; border-left: 1px solid var(--border); margin-left: 6px; }

/* Рядок дерева (v1.0.9) — трикутник згорнути/розгорнути, посилання на
   сторінку, дії, що з'являються при наведенні на РЯДОК (не на саме
   посилання) — фон наведення тепер на .kb-tree-row, а не на .kb-page-tree-link. */
.kb-tree-row { display: flex; align-items: center; gap: 2px; border-radius: var(--radius-sm); transition: background-color .15s ease; }
.kb-tree-row:hover { background: var(--surface-hover); }
.kb-tree-row:hover .kb-tree-row-actions, .kb-tree-row-actions:focus-within { opacity: 1; visibility: visible; }

.kb-tree-toggle, .kb-tree-toggle-spacer { width: 18px; height: 28px; flex-shrink: 0; }
.kb-tree-toggle { display: inline-flex; align-items: center; justify-content: center; border: none; background: none; padding: 0; color: var(--text-muted); cursor: pointer; }
.kb-tree-toggle svg { width: 13px; height: 13px; transition: transform .15s ease; transform: rotate(90deg); }
.kb-tree-node.collapsed > .kb-tree-row .kb-tree-toggle svg { transform: rotate(0deg); }
.kb-tree-node.collapsed > ul { display: none; }

.kb-page-tree-link {
    display: block;
    flex: 1;
    min-width: 0;
    padding: 6px 4px;
    border-radius: var(--radius-sm);
    color: var(--text);
    text-decoration: none;
    font-size: 13.5px;
    line-height: 1.4;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.kb-page-tree-link.active { background: color-mix(in srgb, var(--primary) 12%, transparent); color: var(--primary); font-weight: 600; }

/* "+"/"олівець" з'являються лише при наведенні на рядок (як у файлових
   деревах IDE) — постійно видимі захаращували б вузьку бічну панель. */
.kb-tree-row-actions { display: flex; align-items: center; gap: 2px; flex-shrink: 0; opacity: 0; visibility: hidden; }
.kb-tree-row-action {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    flex-shrink: 0;
    border: none;
    background: none;
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    cursor: pointer;
    text-decoration: none;
}
.kb-tree-row-action:hover { background: var(--card-bg); color: var(--primary); }
.kb-tree-row-action svg { width: 14px; height: 14px; }

/* Спільне контекстне меню дерева (v1.0.9) — один екземпляр у DOM,
   позиціюється JS біля натиснутої кнопки-олівця конкретного рядка,
   а не по одному на кожен вузол дерева. */
.kb-context-menu {
    display: none;
    position: fixed;
    z-index: 60;
    min-width: 200px;
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    padding: 6px;
}
.kb-context-menu.open { display: block; }
.kb-context-menu-item {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 8px 10px;
    border: none;
    background: none;
    border-radius: var(--radius-sm);
    color: var(--text);
    font: inherit;
    font-size: 13.5px;
    text-align: left;
    cursor: pointer;
}
.kb-context-menu-item:hover { background: var(--surface-hover); }
.kb-context-menu-item svg { width: 15px; height: 15px; flex-shrink: 0; color: var(--text-muted); }
.kb-context-menu-item.kb-context-menu-danger:hover { color: #b91c1c; }
.kb-context-menu-item.kb-context-menu-danger:hover svg { color: #b91c1c; }
.kb-context-menu-divider { height: 1px; background: var(--border); margin: 6px 4px; }

/* Коментарі (v1.0.9) — до сторінки чи простору, з відповідями (вкладені
   через margin-left за глибиною, не окрема колонка — глибина рідко буває
   більшою за 1-2). */
.kb-comment-list { display: flex; flex-direction: column; gap: 14px; margin-top: 10px; }
.kb-comment { border-top: 1px solid var(--border); padding-top: 12px; }
.kb-comment-list > .kb-comment:first-child { border-top: none; padding-top: 0; }
.kb-comment-header { display: flex; align-items: baseline; gap: 8px; margin-bottom: 4px; flex-wrap: wrap; }
.kb-comment-body { font-size: 13.5px; line-height: 1.5; white-space: pre-wrap; word-break: break-word; }
.kb-comment-actions { display: flex; align-items: center; gap: 14px; margin-top: 6px; }
.kb-comment-actions form { margin: 0; }
.kb-comment-reply-btn, .kb-comment-delete-btn {
    border: none;
    background: none;
    font: inherit;
    font-size: 12.5px;
    color: var(--text-muted);
    cursor: pointer;
    padding: 0;
}
.kb-comment-reply-btn:hover { color: var(--primary); }
.kb-comment-delete-btn:hover { color: #b91c1c; }
.kb-comment-reply-form { display: none; margin-top: 10px; }
.kb-comment-reply-form.open { display: block; }
.kb-comment-reply-form textarea, .kb-comment-form textarea { width: 100%; resize: vertical; }

/* Позначена @-згадка у вмісті сторінки/опису простору (v1.0.9) — та сама
   "піл" естетика, що й у .kb-tag, лише для людини, а не мітки. */
.kb-mention { display: inline-block; padding: 1px 6px; border-radius: 999px; background: color-mix(in srgb, var(--primary) 14%, transparent); color: var(--primary); font-weight: 600; }

/* Спільне контекстне меню @-згадування (v1.0.9) — той самий принцип, що й
   .kb-context-menu дерева сторінок: один екземпляр у DOM на редактор/форму,
   позиціюється JS біля місця, де набрали "@". Пошук зверху (як просив
   користувач), список нижче, подвійний клік на рядку — вставляє тег. */
.kb-mention-picker {
    display: none;
    position: fixed;
    z-index: 70;
    width: 260px;
    max-height: 280px;
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    padding: 8px;
    flex-direction: column;
    gap: 6px;
}
.kb-mention-picker.open { display: flex; }
.kb-mention-picker-search { margin: 0; }
.kb-mention-picker-list { overflow-y: auto; display: flex; flex-direction: column; gap: 1px; }
.kb-mention-picker-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 7px 8px;
    border-radius: var(--radius-sm);
    font-size: 13.5px;
    cursor: pointer;
    user-select: none;
}
.kb-mention-picker-item:hover, .kb-mention-picker-item.active { background: var(--surface-hover); }
.kb-mention-picker-empty { padding: 7px 8px; font-size: 13px; color: var(--text-muted); }

/* Пошук за назвою в дереві сторінок (space.php, v1.0.4) — фільтрує
   .kb-page-tree-link на льоту через JS, без запиту на сервер. */
.kb-tree-search { margin: 10px 0; }
.kb-tree-search input { margin: 0; }

/* .btn без -sm "на око" мала виглядати як .icon-btn (34x34) поруч у тому ж
   рядку, але глобальний line-height:1.5 на body робить її на ~5px вищою
   (9px*2 padding + 14px*1.5 line-height = 39px, а не 34px) — фіксуємо
   висоту явно замість покладатись на цей збіг padding/line-height. */
.kb-header-btn { height: 34px; padding-top: 0; padding-bottom: 0; display: inline-flex; align-items: center; }

/* Пошук у модулі — поле й кнопка об'єднані в одну візуальну "капсулу"
   (спільна рамка), а не два окремих елементи із зазором між ними. */
.kb-search-box {
    display: flex;
    align-items: center;
    flex: 1;
    min-width: 0;
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding-left: 14px;
    transition: border-color .15s ease, box-shadow .15s ease;
}
.kb-search-box:focus-within { border-color: var(--primary); box-shadow: var(--focus-ring); }
.kb-search-box input[type="text"] {
    flex: 1;
    min-width: 0;
    border: none;
    background: none;
    padding: 9px 0;
    margin: 0;
    outline: none;
}
.kb-search-box input[type="text"]:focus { box-shadow: none; }
.kb-search-box-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 34px;
    flex-shrink: 0;
    border: none;
    background: none;
    color: var(--text-muted);
    cursor: pointer;
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
    transition: background-color .15s ease, color .15s ease;
}
.kb-search-box-btn:hover { color: var(--primary); background: var(--surface-hover); }
.kb-search-box-btn svg { width: 17px; height: 17px; }

/* "Розділи"/"Останні зміни" на сторінці простору — той самий вигляд, що й
   пункт головного бічного меню (.app-nav-item в header_staff.php): іконка +
   підпис, а не звичайна кнопка. .app-nav-item спроєктований під <a>, тут —
   <button> (клік відкриває вікно), тому скидаємо кнопкове хромування. */
button.app-nav-item { border: none; background: none; font: inherit; width: 100%; text-align: left; cursor: pointer; }
.kb-side-nav-card { padding: 6px; display: flex; flex-direction: column; gap: 2px; }

/* Бокові висувні панелі ("Останні зміни"/"Простори"/"Розділи") — той самий
   принцип, що й мобільне бічне меню (.app-sidebar.open у header_staff.php):
   position:fixed + transform:translateX(100%..0) + спільний бекдроп, лише
   висуваються з правого краю екрана й не залежать від ширини вікна. */
.kb-drawer-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, .35);
    z-index: 49;
}
.kb-drawer-backdrop.open { display: block; }
.kb-drawer {
    position: fixed;
    top: 0;
    right: 0;
    height: 100vh;
    width: 360px;
    max-width: 90vw;
    background: var(--card-bg);
    box-shadow: var(--shadow-lg);
    z-index: 50;
    transform: translateX(100%);
    transition: transform .2s ease;
    overflow-y: auto;
    padding: 20px;
}
.kb-drawer.open { transform: translateX(0); }
.kb-drawer-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.kb-drawer-header h2 { display: flex; align-items: center; gap: 8px; font-size: 17px; margin: 0; }
.kb-drawer-header h2 svg { width: 19px; height: 19px; flex-shrink: 0; }
/* Панель "Простори" — заголовок і пошук лишаються на місці, список
   прокручується сам, а "+ Створити простір" завжди видно внизу панелі
   (а не десь під довгим списком, куди треба доскролити). */
#kbSpacesDrawer { display: flex; flex-direction: column; overflow-y: hidden; }
#kbSpacesDrawer .kb-side-list { flex: 1; overflow-y: auto; min-height: 0; }
#kbSpacesDrawer .kb-drawer-footer { flex-shrink: 0; }
.kb-recent-item.active { background: color-mix(in srgb, var(--primary) 12%, transparent); color: var(--primary); font-weight: 600; }
/* У вузькій панелі "Останні зміни" (360px) назва й "автор · дата" поруч не
   вміщались — дата переносилась у два рядки й наїжджала на назву. Рядок
   складаємо в колонку — але ЛИШЕ тут: панель "Простори" (той самий
   .kb-recent-item у тому самому .kb-drawer) має простий рядок іконка+назва
   зліва / замочок обмеженого доступу справа, і мала ламатись тим самим
   правилом, якби воно чіплялось до .kb-drawer загалом. */
#kbRecentPagesDrawer .kb-recent-item { flex-direction: column; align-items: flex-start; gap: 3px; }
#kbRecentPagesDrawer .kb-recent-item > span:first-child { width: 100%; }
#kbRecentPagesDrawer .kb-recent-item .hint-inline { white-space: normal; }

/* Посилання "+ Створити" внизу дерева — приглушене, відділене пунктирною
   лінією, а не ще одна повноцінна кнопка (та вже є у шапці сторінки простору). */
.kb-tree-create-link {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px dashed var(--border);
    color: var(--text-muted);
    text-decoration: none;
    font-size: 13px;
}
.kb-tree-create-link:hover { color: var(--primary); }
.kb-tree-create-link svg { width: 14px; height: 14px; }
/* Панель "Простори" використовує цей клас на <button> (актив-тригер модалки),
   а не <a> як дерево сторінок — без скидання кнопкового хромування браузер
   малює поверх звичну сіру рамку/фон кнопки. */
button.kb-tree-create-link {
    border: none;
    border-top: 1px dashed var(--border);
    background: none;
    font: inherit;
    width: 100%;
    text-align: left;
    cursor: pointer;
    padding: 10px 0 0;
    margin-top: 10px;
}

/* Згортні панелі бічної колонки сторінки простору ("Розділи"/"Недавні") —
   нативні <details>/<summary>, кожна панель — окрема картка (на відміну від
   .accordion-item, розрахованого на список пунктів в одній картці). */
.kb-side-panel {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
}
.kb-side-panel summary {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 14px;
    cursor: pointer;
    list-style: none;
    font-weight: 600;
    font-size: 13.5px;
    color: var(--text);
    transition: background-color .15s ease;
}
.kb-side-panel summary::-webkit-details-marker { display: none; }
.kb-side-panel summary::marker { content: ""; }
.kb-side-panel summary:hover { background: var(--surface-hover); }
.kb-side-panel-chevron { width: 15px; height: 15px; color: var(--text-muted); margin-left: auto; flex-shrink: 0; transition: transform .2s var(--ease-out); }
.kb-side-panel[open] .kb-side-panel-chevron { transform: rotate(90deg); }
.kb-side-panel-body { padding: 0 12px 12px; }

/* Дії над сторінкою (редагувати/історія/видалити тощо) — приглушені
   текстові посилання замість суцільних кнопок, спокійніший вигляд шапки
   сторінки (v1.0.4). */
.kb-page-actions { display: flex; gap: 18px; flex-wrap: wrap; }
.kb-page-action-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: var(--text-muted);
    text-decoration: none;
    font-size: 13.5px;
    font-weight: 600;
    background: none;
    border: none;
    cursor: pointer;
    padding: 0;
    font-family: inherit;
    transition: color .15s ease;
}
.kb-page-action-link svg { width: 15px; height: 15px; }
.kb-page-action-link:hover { color: var(--primary); }
.kb-page-action-link.kb-page-action-danger:hover { color: #b91c1c; }

/* Типографіка санітизованого HTML з редактора — без цього <h1>/<table>/
   <blockquote>, вставлені через Quill, виглядали б голими (без стилю
   браузера за замовчуванням, який тут скрізь скинутий глобальним CSS). */
.kb-page-content { line-height: 1.65; font-size: 15px; }
.kb-page-content h1, .kb-page-content h2, .kb-page-content h3 {
    margin: 28px 0 10px;
    font-weight: 700;
    letter-spacing: -0.01em;
    scroll-margin-top: 84px;
}
.kb-page-content h1:first-child, .kb-page-content h2:first-child, .kb-page-content h3:first-child { margin-top: 0; }
.kb-page-content h1 { font-size: 26px; padding-bottom: 8px; border-bottom: 1px solid var(--border); }
.kb-page-content h2 { font-size: 20px; }
.kb-page-content h3 { font-size: 16.5px; }
.kb-page-content p { margin: 0 0 12px; }
.kb-page-content ul, .kb-page-content ol { margin: 0 0 12px; padding-left: 24px; }
.kb-page-content blockquote {
    margin: 0 0 12px;
    padding: 8px 14px;
    border-left: 3px solid var(--primary);
    background: var(--surface-sunken);
    color: var(--text-muted);
}
.kb-page-content pre {
    background: var(--surface-sunken);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 12px;
    overflow-x: auto;
}
.kb-page-content code { background: var(--surface-sunken); padding: 1px 5px; border-radius: 4px; font-size: .9em; }
.kb-page-content pre code { background: none; padding: 0; }
.kb-page-content table { border-collapse: collapse; width: 100%; margin: 0 0 12px; }
.kb-page-content th, .kb-page-content td { border: 1px solid var(--border); padding: 6px 10px; text-align: left; }
.kb-page-content img { max-width: 100%; border-radius: var(--radius-sm); }
.kb-page-content a { color: var(--primary); }

/* Вирівнювання/обтікання картинок (v1.0.10) — клас пишеться редактором
   (kb-image-tools у space.php/space_settings.php), сам розмір — атрибутом
   width на <img> (Quill і санітайзер kb_sanitize_attributes() вже дозволяють
   width/height нативно, а style на img — ні, тому вирівнювання саме класом,
   не inline-style). Ті самі правила діють і в редакторі (.ql-editor), і в
   перегляді/друку/публічному посиланні (.kb-page-content) — щоб WYSIWYG
   збігався з тим, що бачить читач.
*/
.kb-page-content img.kb-img-inline, .ql-editor img.kb-img-inline {
    display: inline; float: none; vertical-align: middle; margin: 0 4px;
}
.kb-page-content img.kb-img-left, .ql-editor img.kb-img-left {
    float: left; margin: 4px 16px 8px 0;
}
.kb-page-content img.kb-img-right, .ql-editor img.kb-img-right {
    float: right; margin: 4px 0 8px 16px;
}
.kb-page-content img.kb-img-center, .ql-editor img.kb-img-center {
    display: block; float: none; margin: 8px auto;
}
/* Clearfix -- без нього контейнер (.kb-page-content/.ql-editor) не
   "стримує" плаваючу картинку: якщо вона вища за весь текст, що мав би її
   обтікати, контейнер обривається раніше, ніж закінчується картинка, і
   виглядає так, ніби текст поруч не домальовується. */
.kb-page-content::after, .ql-editor::after {
    content: ""; display: table; clear: both;
}

/* ==================== Меню вставки об'єктів (kb-editor-extras, v1.0.10) ====================
   Інфопанелі, статус, дата, розділювач, зміст, таблиці, файл у тексті —
   спільні правила для редактора (.ql-editor) і перегляду (.kb-page-content),
   щоб WYSIWYG збігався з тим, що бачить читач. */

.kb-insert-menu-btn { display: flex !important; align-items: center; justify-content: center; }
.kb-insert-menu {
    position: fixed;
    z-index: 20;
    width: 300px;
    display: flex;
    flex-direction: column;
    background: var(--card-bg);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    box-shadow: 0 8px 24px rgba(0, 0, 0, .15);
    font-size: 13px;
}
.kb-insert-menu-search-wrap {
    display: flex; align-items: center; gap: 7px;
    padding: 9px 10px; border-bottom: 1px solid var(--border); flex-shrink: 0;
}
.kb-insert-menu-search-wrap svg { width: 15px; height: 15px; color: var(--text-muted); flex-shrink: 0; }
.kb-insert-menu-search { flex: 1; min-width: 0; border: none; outline: none; font-size: 13px; background: none; color: var(--text); }
.kb-insert-menu-search-hint { font-size: 10.5px; color: var(--text-muted); border: 1px solid var(--border); border-radius: 4px; padding: 1px 5px; flex-shrink: 0; white-space: nowrap; }
.kb-insert-menu-list { padding: 4px; }
.kb-insert-menu-item {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 6px 8px;
    border: none;
    border-radius: 6px;
    background: none;
    color: var(--text);
    cursor: pointer;
    text-align: left;
    position: relative;
}
.kb-insert-menu-item:hover { background: var(--surface-hover); }
.kb-insert-menu-item-extra { display: none; }
.kb-insert-menu.kb-expanded .kb-insert-menu-item.kb-insert-menu-item-extra { display: flex; }
.kb-insert-menu.kb-expanded .kb-insert-menu-sep.kb-insert-menu-item-extra { display: block; }
.kb-insert-menu-item.kb-insert-menu-item-hidden-search { display: none !important; }
.kb-insert-menu-icon {
    display: flex; align-items: center; justify-content: center;
    width: 32px; height: 32px; border-radius: 7px; flex-shrink: 0;
}
.kb-insert-menu-icon svg { width: 17px; height: 17px; }
.kb-insert-menu-icon-0 { background: #e6f0ff; color: #2563eb; }
.kb-insert-menu-icon-1 { background: #f5f3ff; color: #7c3aed; }
.kb-insert-menu-icon-2 { background: #fff7e6; color: #d97706; }
.kb-insert-menu-icon-3 { background: #e6fbf0; color: #16a34a; }
.kb-insert-menu-icon-4 { background: #e6fbf7; color: #0d9488; }
.kb-insert-menu-icon-5 { background: #f1f5f9; color: #475569; }
.kb-insert-menu-item-text { display: flex; flex-direction: column; gap: 1px; overflow: hidden; min-width: 0; }
.kb-insert-menu-item-title { font-weight: 600; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kb-insert-menu-item-desc { font-size: 11.5px; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kb-insert-menu-item-chevron { margin-left: auto; color: var(--text-muted); flex-shrink: 0; width: 14px; height: 14px; }
.kb-insert-menu-sep { height: 1px; background: var(--border); margin: 4px 10px; }
.kb-insert-menu-expand {
    display: flex; align-items: center; justify-content: center; gap: 4px;
    width: 100%; padding: 8px; border: none; border-top: 1px solid var(--border);
    background: none; color: var(--text-muted); font-size: 12px; cursor: pointer; flex-shrink: 0;
}
.kb-insert-menu-expand:hover { background: var(--surface-hover); color: var(--text); }
.kb-insert-menu-expand svg { width: 13px; height: 13px; }
.kb-insert-submenu {
    position: fixed;
    z-index: 21;
    min-width: 170px;
    padding: 4px;
    background: var(--card-bg);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    box-shadow: 0 8px 24px rgba(0, 0, 0, .15);
    display: none;
}
.kb-insert-submenu.open { display: block; }
.kb-insert-submenu button {
    display: flex; align-items: center; gap: 8px; width: 100%;
    padding: 6px 8px; border: none; border-radius: 5px; background: none;
    color: var(--text); cursor: pointer; text-align: left; font-size: 13px;
}
.kb-insert-submenu button:hover { background: var(--surface-hover); }

/* Інфопанелі (v1.0.10, друга ітерація) -- контейнер (kb-panel-container)
   лише групує рядки-абзаци, кожен <p data-kb-panel="тип"> сам несе колір
   (той самий патерн, що офіційний List Quill: <ol><li data-list="bullet">),
   тому кілька рядків усередині однієї панелі (Enter) виглядають одним
   суцільним кольоровим блоком, а не розірваними шматками. */
.kb-page-content .kb-panel-container, .ql-editor .kb-panel-container {
    margin: 10px 0;
    border-radius: var(--radius-sm);
    overflow: hidden;
}
.kb-page-content .kb-panel-container p[data-kb-panel], .ql-editor .kb-panel-container p[data-kb-panel] {
    position: relative;
    margin: 0;
    padding: 10px 12px 10px 40px;
    border-left: 4px solid var(--border-strong);
}
.kb-page-content .kb-panel-container p[data-kb-panel]:first-child::before,
.ql-editor .kb-panel-container p[data-kb-panel]:first-child::before {
    position: absolute; left: 12px; top: 10px; font-size: 15px; line-height: 1;
}
.kb-panel-container p[data-kb-panel="info"] { border-left-color: #2563eb; background: #eff6ff; }
.kb-panel-container p[data-kb-panel="info"]:first-child::before { content: "ℹ"; color: #2563eb; }
.kb-panel-container p[data-kb-panel="note"] { border-left-color: #7c3aed; background: #f5f3ff; }
.kb-panel-container p[data-kb-panel="note"]:first-child::before { content: "✎"; color: #7c3aed; }
.kb-panel-container p[data-kb-panel="warning"] { border-left-color: #d97706; background: #fffbeb; }
.kb-panel-container p[data-kb-panel="warning"]:first-child::before { content: "⚠"; color: #d97706; }
.kb-panel-container p[data-kb-panel="success"] { border-left-color: #16a34a; background: #f0fdf4; }
.kb-panel-container p[data-kb-panel="success"]:first-child::before { content: "✓"; color: #16a34a; }

/* Статус (лозенж) -- вставляється текстом і кольором одразу (prompt + вибір кольору в меню), редагується лише перевставленням. */
.kb-status {
    display: inline-block; padding: 1px 9px; border-radius: 999px;
    font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .02em;
    vertical-align: middle;
}
.kb-status-gray { background: #dfe1e6; color: #42526e; }
.kb-status-blue { background: #deebff; color: #0052cc; }
.kb-status-green { background: #e3fcef; color: #006644; }
.kb-status-red { background: #ffebe6; color: #bf2600; }
.kb-status-yellow { background: #fff0b3; color: #974f0c; }
.kb-status-purple { background: #eae6ff; color: #5243aa; }

/* Дата -- статичний чіп (не перераховується), просто стилізований текст. */
.kb-date {
    display: inline-flex; align-items: center; gap: 4px;
    padding: 1px 8px 1px 6px; border-radius: 5px;
    background: var(--surface-sunken); color: var(--text); font-size: 13px;
    vertical-align: middle;
}
.kb-date svg { width: 13px; height: 13px; color: var(--text-muted); }

/* Зміст -- у редакторі показує лише плейсхолдер (kb-toc-marker); реальний
   список заголовків підставляється на сервері при перегляді сторінки
   (kb_render_toc_markers()), бо в самому вмісті зберігати статичний список
   означає, що він застаріє при першій же зміні заголовків. */
.kb-toc-marker {
    padding: 8px 12px; border: 1px dashed var(--border-strong); border-radius: var(--radius-sm);
    color: var(--text-muted); font-size: 13px; background: var(--surface-sunken);
}
.kb-toc { margin: 10px 0; padding: 10px 14px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface-sunken); }
.kb-toc-title { font-weight: 700; font-size: 13px; margin: 0 0 6px; }
.kb-toc ul { list-style: none; margin: 0; padding: 0; }
.kb-toc li { margin: 3px 0; }
.kb-toc li a { color: var(--text); text-decoration: none; font-size: 13.5px; }
.kb-toc li a:hover { color: var(--primary); text-decoration: underline; }
.kb-toc .kb-toc-lvl-2 { padding-left: 16px; }
.kb-toc .kb-toc-lvl-3 { padding-left: 32px; }

/* Розділювач -- звичайний <hr>, уже дозволений санітайзером. */
.kb-page-content hr, .ql-editor hr { border: none; border-top: 2px solid var(--border); margin: 16px 0; }

/* Файл у тексті -- звичайне посилання Quill (kb-file-chip formats()/format()
   override зберігає клас/download, як kb-image-tools для картинок), просто
   стилізоване як кнопка-чіп; видаляється як будь-який текст (select+Delete). */
.kb-page-content a.kb-file-chip, .ql-editor a.kb-file-chip {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 4px 10px 4px 8px; margin: 0 2px;
    border: 1px solid var(--border-strong); border-radius: 999px;
    background: var(--surface-sunken); color: var(--text) !important;
    text-decoration: none !important; font-size: 13px; vertical-align: middle;
}
.kb-page-content a.kb-file-chip:hover, .ql-editor a.kb-file-chip:hover { background: var(--surface-hover); }
.kb-page-content a.kb-file-chip::before, .ql-editor a.kb-file-chip::before { content: "📎"; }

/* Таблиця -- редагується напряму (як у Confluence), без власного превʼю чи
   модального вікна: сторонній модуль quill-table-up (CDN, header_staff.php)
   з власним CSS (index.css/table-creator.css) відповідає за весь вигляд —
   жодних kb-* класів тут навмисно немає. Виняток -- вибір кольору фону
   комірки в контекстному меню: бібліотека сама показує колірпікер
   усередині "підказки" (.table-up-tooltip -- за задумом темна, як системна
   tooltip), а сам колірпікер усередині стає прозорим (:root { --color-
   picker-bg-color: transparent }) і зливається з цим темним тлом -- звідси
   чорний фон замість білого. Змушуємо і підказку, і колірпікер лишатись
   білими, як решта інтерфейсу застосунку. */
.table-up-tooltip:has(.table-up-color-picker) {
    background-color: #fff !important;
    box-shadow: 0 0 .5rem rgba(0, 0, 0, .25);
}
.table-up-tooltip .table-up-color-picker {
    --color-picker-bg-color: #ffffff !important;
}

/* Код -- Quill 2.x рендерить блок коду як <div class="ql-code-block-container">
   з окремим <div class="ql-code-block"> на кожен рядок (не єдиний <pre>, як
   у Quill 1.x) -- світло-сірий фон, чорний текст, номери рядків (CSS
   counter, без JS). Зміна розміру (resize+overflow) -- лише в перегляді/
   друку/публічному посиланні (.kb-page-content); у самому редакторі
   (.ql-editor) навмисно БЕЗ resize/overflow -- цей блок лишається звичайною
   редагованою частиною Delta-моделі Quill (на відміну від таблиці/зображень,
   тут немає окремого contenteditable-острівця), і resize/overflow на
   активно редагованому вмісті ламали введення тексту в деяких браузерах.
   Селектор у редакторі свідомо з .ql-snow попереду -- у власному CSS Quill
   (quill.snow.css) є правило ТОЧНО з таким самим префіксом і темним фоном
   (#23241f), тобто з вищою специфічністю за голий ".ql-editor ...", і
   раніше просто перемагало незалежно від порядку підключення стилів. */
.ql-snow .ql-editor .ql-code-block-container, .kb-page-content .ql-code-block-container {
    /* !important -- style.css підключається в head РАНІШЕ за quill.snow.css
       (header_staff.php), тож навіть однакова специфічність селектора
       програє власному темному правилу Quill за порядком підключення. */
    background: #f4f5f7 !important;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm) !important;
    padding: 10px 0 !important;
    margin: 10px 0 !important;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 13px;
    line-height: 1.6;
    counter-reset: kb-code-line;
}
.kb-page-content .ql-code-block-container {
    resize: vertical;
    overflow: auto;
    min-height: 60px;
    max-height: 70vh;
}
.ql-snow .ql-editor .ql-code-block, .kb-page-content .ql-code-block {
    position: relative;
    counter-increment: kb-code-line;
    padding: 0 14px 0 3em;
    color: #1e293b !important;
    background: none !important;
    white-space: pre-wrap;
    word-break: break-word;
}
.ql-snow .ql-editor .ql-code-block::before, .kb-page-content .ql-code-block::before {
    content: counter(kb-code-line);
    position: absolute;
    left: 0;
    width: 2.4em;
    text-align: right;
    color: var(--text-muted);
    user-select: none;
}

.kb-version-list { display: flex; flex-direction: column; gap: 6px; }
.kb-version-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    text-decoration: none;
    transition: background-color .15s ease, border-color .15s ease;
}
.kb-version-item:hover { background: var(--surface-hover); border-color: var(--border-strong); }

/* Вкладення сторінки (space.php) з v1.0.5 показуються таблицею (.table,
   спільний клас застосунку), не власним списком — тому власного класу тут
   більше немає.

   Керування шаблонами документів (modules/knowledge_base/settings.php) —
   рядковий патерн-картка. */
.kb-template-admin-list { display: flex; flex-direction: column; gap: 6px; }
.kb-template-admin-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 8px 10px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
}
.kb-template-admin-item > span:first-child { display: flex; align-items: center; gap: 6px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Редактор Quill — узгоджуємо радіуси/шрифт із рештою застосунку (сам
   Quill лишається світлою темою "snow" за замовчуванням — весь кабінет
   у цьому проєкті теж завжди світлий, лише колір акценту змінюється). */
.ql-toolbar.ql-snow { border-color: var(--border); border-radius: var(--radius-sm) var(--radius-sm) 0 0; font-family: inherit; }
.ql-container.ql-snow { border-color: var(--border); border-radius: 0 0 var(--radius-sm) var(--radius-sm); font-family: inherit; font-size: 14px; min-height: 320px; position: relative; }
.ql-editor { min-height: 320px; }
.ql-editor img { cursor: pointer; max-width: 100%; }

/* Плаваюча панель картинки (v1.0.10) — з'являється над обраною картинкою в
   редакторі: вирівнювання/обтікання (kb-image-tools у space.php/
   space_settings.php) і повзунок розміру. Позиціонується скриптом відносно
   .ql-container (position: relative вище), не сама картинка -- обгортати
   <img> в додатковий <span> не можна, бо тоді Quill-блот і санітайзер
   контенту (kb_sanitize_attributes()) більше не бачили б у ньому просту
   картинку. */
.kb-img-toolbar {
    position: absolute;
    z-index: 5;
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 4px 6px;
    background: var(--card-bg);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    box-shadow: 0 4px 14px rgba(0, 0, 0, .12);
}
.kb-img-toolbar button {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 26px;
    height: 26px;
    padding: 0;
    border: 1px solid transparent;
    border-radius: 5px;
    background: none;
    color: var(--text-muted);
    cursor: pointer;
}
.kb-img-toolbar button:hover { background: var(--surface-hover); color: var(--text); }
.kb-img-toolbar button.active { background: color-mix(in srgb, var(--primary) 14%, transparent); color: var(--primary); border-color: transparent; }
.kb-img-toolbar button svg { width: 15px; height: 15px; }
.kb-img-toolbar .kb-img-toolbar-sep { width: 1px; align-self: stretch; background: var(--border); margin: 0 2px; }
.kb-img-toolbar input[type="range"] { width: 90px; margin: 0 4px; }
.kb-img-toolbar-size-label { font-size: 11px; color: var(--text-muted); width: 32px; text-align: right; }
