/* ==========================================================================
   OTL CRM — единый интерфейс (дизайн-кит)
   assets/ui/ui.css
   Подключается на всех страницах через ui_page_start().
   Не редактировать страничным кодом: для частных случаев — assets/pages/*.css
   ========================================================================== */

:root {
    --otl-orange: #ff6b00;
    --otl-orange-600: #e85f00;
    --otl-orange-700: #c74f00;
    --otl-orange-050: #fff4ea;
    --otl-orange-100: #ffe4cd;

    --ink: #16181d;
    --ink-2: #3b4250;
    --muted: #667085;
    --muted-2: #98a2b3;

    --bg: #f3f5f8;
    --surface: #ffffff;
    --surface-2: #f8f9fb;
    --surface-3: #eef1f5;
    --line: #e4e8ef;
    --line-strong: #d0d7e2;

    --ok: #12805c;
    --ok-bg: #e7f6ef;
    --warn: #9a5b00;
    --warn-bg: #fff4e0;
    --danger: #c62828;
    --danger-bg: #fdecec;
    --info: #1d4ed8;
    --info-bg: #eaf0fe;
    --violet: #6d28d9;
    --violet-bg: #f1ebfd;

    --radius-sm: 7px;
    --radius: 10px;
    --radius-lg: 14px;

    --shadow-1: 0 1px 2px rgba(16, 24, 40, .05);
    --shadow-2: 0 4px 14px rgba(16, 24, 40, .08);
    --shadow-3: 0 18px 40px rgba(16, 24, 40, .18);

    --header-h: 56px;
    --sidebar-w: 240px;
    --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    --mono: ui-monospace, SFMono-Regular, "Cascadia Mono", Menlo, Consolas, monospace;
}

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

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

body.ui-body {
    margin: 0;
    background: var(--bg);
    color: var(--ink);
    font: 14px/1.45 var(--font);
    min-height: 100vh;
}

body.ui-body.ui-body--auth { display: flex; }

h1, h2, h3, h4 { color: var(--ink); margin: 0; line-height: 1.25; }
h1 { font-size: 22px; font-weight: 700; letter-spacing: -.01em; }
h2 { font-size: 17px; font-weight: 680; }
h3 { font-size: 15px; font-weight: 650; }
p { margin: 0 0 10px; }
a { color: var(--otl-orange-700); text-decoration: none; }
a:hover { text-decoration: underline; }
small { font-size: 12px; }
img { max-width: 100%; }

.ui-i { width: 18px; height: 18px; flex: none; stroke: currentColor; fill: none; }
.ui-i--sm { width: 15px; height: 15px; }
.ui-i--lg { width: 22px; height: 22px; }

.ui-skip {
    position: absolute; left: -9999px; top: 0; z-index: 200;
    background: var(--otl-orange); color: #fff; padding: 10px 16px; border-radius: 0 0 8px 0;
}
.ui-skip:focus { left: 0; }

/* ---------- шапка ---------- */

.ui-header {
    position: sticky; top: 0; z-index: 70;
    height: var(--header-h);
    display: flex; align-items: center; gap: 14px;
    padding: 0 16px 0 14px;
    background: #14161b;
    color: #fff;
    border-bottom: 1px solid #23262e;
}
.ui-brand {
    display: inline-flex; align-items: center; gap: 9px;
    height: 34px; padding: 0 7px; border-radius: 8px;
    background: #000; flex: none;
}
.ui-brand img { height: 22px; width: auto; display: block; }
.ui-brand:hover { text-decoration: none; }

.ui-burger {
    display: none; width: 36px; height: 36px; padding: 0;
    align-items: center; justify-content: center;
    background: transparent; color: #fff; border: 1px solid #333845; border-radius: 8px; cursor: pointer;
}
.ui-burger:hover { background: #23262e; }

.ui-header__titles { min-width: 0; display: flex; flex-direction: column; justify-content: center; gap: 1px; }
.ui-header__title {
    font-size: 15px; font-weight: 650; color: #fff; margin: 0;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.ui-header__crumb { font-size: 11.5px; color: #9ba3b4; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ui-header__crumb a { color: #c8cdd8; }
.ui-header__spacer { flex: 1 1 auto; }

.ui-header__meta { display: flex; align-items: center; gap: 10px; flex: none; }
.ui-chip {
    display: inline-flex; align-items: center; gap: 6px;
    height: 28px; padding: 0 10px; border-radius: 999px;
    background: #1f232b; border: 1px solid #2c313c; color: #c8cdd8;
    font-size: 12px; white-space: nowrap;
}
.ui-chip b { color: #fff; font-weight: 700; font-variant-numeric: tabular-nums; }
.ui-clock {
    font-size: 12.5px; color: #c8cdd8; white-space: nowrap;
    font-variant-numeric: tabular-nums;
}
.ui-clock b { color: #fff; font-weight: 600; }

.ui-user { position: relative; flex: none; }
.ui-user__btn {
    display: inline-flex; align-items: center; gap: 8px;
    height: 38px; padding: 0 10px 0 6px;
    background: #1f232b; color: #fff; border: 1px solid #2c313c; border-radius: 999px;
    cursor: pointer; font: inherit;
}
.ui-user__btn:hover, .ui-user__btn[aria-expanded="true"] { background: #262b35; }
.ui-avatar {
    width: 26px; height: 26px; border-radius: 50%;
    display: inline-flex; align-items: center; justify-content: center;
    background: var(--otl-orange); color: #fff;
    font-size: 11.5px; font-weight: 700; flex: none; letter-spacing: .02em;
}
.ui-avatar--lg { width: 40px; height: 40px; font-size: 15px; }
.ui-user__name { font-size: 13px; font-weight: 600; max-width: 150px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ui-user__caret { color: #9ba3b4; display: inline-flex; }

.ui-menu {
    position: absolute; right: 0; top: calc(100% + 8px); z-index: 90;
    min-width: 230px; padding: 6px;
    background: #fff; color: var(--ink);
    border: 1px solid var(--line); border-radius: var(--radius);
    box-shadow: var(--shadow-3);
}
.ui-menu[hidden] { display: none; }
.ui-menu__head { padding: 9px 10px 10px; border-bottom: 1px solid var(--line); margin-bottom: 6px; }
.ui-menu__head strong { display: block; font-size: 13.5px; }
.ui-menu__head span { display: block; font-size: 12px; color: var(--muted); margin-top: 2px; }
.ui-menu a, .ui-menu button {
    display: flex; align-items: center; gap: 9px; width: 100%;
    padding: 8px 10px; border: 0; border-radius: var(--radius-sm);
    background: none; color: var(--ink-2); font: inherit; text-align: left; cursor: pointer;
}
.ui-menu a:hover, .ui-menu button:hover { background: var(--surface-2); color: var(--ink); text-decoration: none; }
.ui-menu .ui-menu__danger { color: var(--danger); }
.ui-menu .ui-menu__sep { height: 1px; background: var(--line); margin: 6px 4px; }

/* ---------- боковое меню ---------- */

.ui-sidebar {
    position: fixed; z-index: 60; top: var(--header-h); bottom: 0; left: 0;
    width: var(--sidebar-w);
    padding: 12px 10px 18px;
    background: var(--surface); border-right: 1px solid var(--line);
    overflow-y: auto; overscroll-behavior: contain;
}
.ui-nav-group { margin-bottom: 14px; }
.ui-nav-group__label {
    display: block; padding: 6px 10px 6px;
    font-size: 10.5px; font-weight: 700; letter-spacing: .09em; text-transform: uppercase;
    color: var(--muted-2);
}
.ui-nav a {
    position: relative; display: flex; align-items: center; gap: 10px;
    min-height: 36px; padding: 7px 10px; margin-bottom: 1px;
    border-radius: var(--radius-sm);
    color: var(--ink-2); font-size: 13.5px; font-weight: 500;
    text-decoration: none;
}
.ui-nav a .ui-i { color: var(--muted); }
.ui-nav a:hover { background: var(--surface-2); color: var(--ink); text-decoration: none; }
.ui-nav a:hover .ui-i { color: var(--ink-2); }
.ui-nav a[aria-current="page"] {
    background: var(--otl-orange-050); color: var(--otl-orange-700); font-weight: 650;
}
.ui-nav a[aria-current="page"] .ui-i { color: var(--otl-orange); }
.ui-nav a[aria-current="page"]::before {
    content: ""; position: absolute; left: 0; top: 8px; bottom: 8px;
    width: 3px; border-radius: 0 3px 3px 0; background: var(--otl-orange);
}
.ui-nav__count {
    margin-left: auto; min-width: 20px; padding: 1px 6px;
    background: var(--surface-3); color: var(--muted);
    border-radius: 999px; font-size: 11px; font-weight: 700; text-align: center;
}
.ui-nav a[aria-current="page"] .ui-nav__count { background: #fff; color: var(--otl-orange-700); }
.ui-nav__note {
    margin: 8px 10px 0; padding: 9px 10px;
    background: var(--surface-2); border: 1px dashed var(--line-strong); border-radius: var(--radius-sm);
    color: var(--muted); font-size: 11.5px; line-height: 1.4;
}
.ui-sidebar__foot {
    margin-top: 18px; padding: 10px 10px 0; border-top: 1px solid var(--line);
    color: var(--muted-2); font-size: 11px; line-height: 1.5;
}

/* ---------- контент ---------- */

.ui-main {
    margin-left: var(--sidebar-w);
    padding: 20px 24px 48px;
    min-width: 0;
}
.ui-page { max-width: 1480px; margin: 0 auto; }

.ui-page-head {
    display: flex; align-items: flex-start; justify-content: space-between; gap: 16px;
    flex-wrap: wrap; margin-bottom: 18px;
}
.ui-page-head__text { min-width: 0; }
.ui-page-head h1 { margin-bottom: 4px; }
.ui-page-head__sub { color: var(--muted); font-size: 13px; max-width: 78ch; }
.ui-page-head__actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.ui-breadcrumbs { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-bottom: 8px; color: var(--muted-2); font-size: 12px; }
.ui-breadcrumbs a { color: var(--muted); }
.ui-breadcrumbs span[aria-hidden] { color: var(--line-strong); }

.ui-stack { display: flex; flex-direction: column; gap: 16px; }
.ui-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.ui-row--between { justify-content: space-between; }
.ui-grid { display: grid; gap: 16px; align-items: start; }
.ui-grid--2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.ui-grid--3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.ui-muted { color: var(--muted); }
.ui-small { font-size: 12px; }
.ui-nowrap { white-space: nowrap; }
.ui-num { font-variant-numeric: tabular-nums; }
.ui-right { text-align: right; }
.ui-center { text-align: center; }
.ui-mt-0 { margin-top: 0; } .ui-mb-0 { margin-bottom: 0; }
.ui-mt-8 { margin-top: 8px; } .ui-mt-12 { margin-top: 12px; } .ui-mt-16 { margin-top: 16px; }
.ui-mb-8 { margin-bottom: 8px; } .ui-mb-12 { margin-bottom: 12px; } .ui-mb-16 { margin-bottom: 16px; }
.ui-hidden { display: none !important; }

/* ---------- карточки ---------- */

.ui-card {
    background: var(--surface); border: 1px solid var(--line);
    border-radius: var(--radius); box-shadow: var(--shadow-1);
    min-width: 0;
}
.ui-card__head {
    display: flex; align-items: center; justify-content: space-between; gap: 12px;
    padding: 13px 16px; border-bottom: 1px solid var(--line);
}
.ui-card__head h2, .ui-card__head h3 { margin: 0; }
.ui-card__head .ui-muted { font-weight: 400; }
.ui-card__body { padding: 16px; }
.ui-card__body--tight { padding: 12px 16px; }
.ui-card__body--flush { padding: 0; }
.ui-card__foot {
    padding: 11px 16px; border-top: 1px solid var(--line);
    background: var(--surface-2); border-radius: 0 0 var(--radius) var(--radius);
    display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap;
}
.ui-card--accent { border-top: 3px solid var(--otl-orange); }
.ui-card--danger { border-color: #f3c6c6; }

/* ---------- кнопки ---------- */

.ui-btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 7px;
    height: 34px; padding: 0 13px;
    border: 1px solid transparent; border-radius: 8px;
    background: var(--surface-2); color: var(--ink-2);
    font: 600 13px/1 var(--font); white-space: nowrap;
    cursor: pointer; text-decoration: none;
    transition: background .14s, border-color .14s, color .14s, box-shadow .14s;
}
.ui-btn:hover { text-decoration: none; }
.ui-btn:focus-visible { outline: 2px solid var(--otl-orange); outline-offset: 2px; }
.ui-btn:disabled, .ui-btn[aria-disabled="true"] { opacity: .55; cursor: not-allowed; }
.ui-btn .ui-i { width: 16px; height: 16px; }

.ui-btn--primary { background: var(--otl-orange); color: #fff; box-shadow: 0 1px 2px rgba(255, 107, 0, .3); }
.ui-btn--primary:hover { background: var(--otl-orange-600); color: #fff; }
.ui-btn--secondary { background: #fff; border-color: var(--line-strong); color: var(--ink-2); }
.ui-btn--secondary:hover { background: var(--surface-2); border-color: #b9c2d0; color: var(--ink); }
.ui-btn--ghost { background: transparent; color: var(--ink-2); }
.ui-btn--ghost:hover { background: var(--surface-3); color: var(--ink); }
.ui-btn--danger { background: var(--danger-bg); color: var(--danger); border-color: #f3c6c6; }
.ui-btn--danger:hover { background: #fbdcdc; color: #a51f1f; }
.ui-btn--ok { background: var(--ok-bg); color: var(--ok); border-color: #bfe6d4; }
.ui-btn--ok:hover { background: #d8f0e3; }

.ui-btn--sm { height: 28px; padding: 0 10px; font-size: 12px; border-radius: 7px; gap: 5px; }
.ui-btn--sm .ui-i { width: 14px; height: 14px; }
.ui-btn--lg { height: 40px; padding: 0 18px; font-size: 14px; border-radius: 9px; }
.ui-btn--icon { width: 32px; padding: 0; }
.ui-btn--icon.ui-btn--sm { width: 28px; }
.ui-btn--block { width: 100%; }

.ui-btn-group { display: inline-flex; gap: 6px; flex-wrap: wrap; }

/* ---------- бейджи и статусы ---------- */

.ui-badge {
    display: inline-flex; align-items: center; gap: 5px;
    padding: 2px 8px; border-radius: 999px;
    font-size: 11.5px; font-weight: 650; line-height: 1.6; white-space: nowrap;
    background: var(--surface-3); color: var(--ink-2);
}
.ui-badge--ok { background: var(--ok-bg); color: var(--ok); }
.ui-badge--warn { background: var(--warn-bg); color: var(--warn); }
.ui-badge--danger { background: var(--danger-bg); color: var(--danger); }
.ui-badge--info { background: var(--info-bg); color: var(--info); }
.ui-badge--violet { background: var(--violet-bg); color: var(--violet); }
.ui-badge--orange { background: var(--otl-orange-050); color: var(--otl-orange-700); }
.ui-badge--dot::before {
    content: ""; width: 6px; height: 6px; border-radius: 50%;
    background: currentColor; flex: none;
}
.ui-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--muted-2); display: inline-block; flex: none; }
.ui-dot--ok { background: var(--ok); }
.ui-dot--warn { background: #d98e00; }
.ui-dot--danger { background: var(--danger); }

/* ---------- таблицы ---------- */

.ui-table-wrap {
    border: 1px solid var(--line); border-radius: var(--radius);
    background: var(--surface); overflow: auto;
    max-width: 100%;
    scrollbar-width: thin;
    scrollbar-color: var(--line-strong) transparent;
}
.ui-table-wrap::-webkit-scrollbar { height: 9px; width: 9px; }
.ui-table-wrap::-webkit-scrollbar-thumb { background: var(--line-strong); border-radius: 999px; }
.ui-table-wrap--flush { border: 0; border-radius: 0; }
.ui-table {
    width: 100%; border-collapse: separate; border-spacing: 0;
    font-size: 13px; min-width: 640px;
}
.ui-table th {
    position: sticky; top: 0; z-index: 2;
    padding: 9px 12px;
    background: var(--surface-2);
    border-bottom: 1px solid var(--line);
    color: var(--muted); font-size: 10.5px; font-weight: 700;
    letter-spacing: .07em; text-transform: uppercase; text-align: left;
    white-space: nowrap;
}
.ui-table td {
    padding: 10px 12px; border-bottom: 1px solid var(--line);
    vertical-align: middle;
    overflow-wrap: anywhere;
}
.ui-table tbody tr:last-child td { border-bottom: 0; }
.ui-table tbody tr:hover td { background: #fafbfd; }
.ui-table tbody tr.is-selected td { background: var(--otl-orange-050); }
.ui-table .ui-num, .ui-table th.ui-num { text-align: right; }
.ui-table .ui-actions { white-space: nowrap; text-align: right; }
.ui-table .ui-actions .ui-btn + .ui-btn { margin-left: 4px; }
/* Кнопки действий всегда на виду при горизонтальной прокрутке */
.ui-table th.ui-actions, .ui-table td.ui-actions {
    position: sticky; right: 0; z-index: 3;
    background: var(--surface);
    box-shadow: -8px 0 8px -8px rgba(16, 24, 40, .22);
}
.ui-table thead th.ui-actions { z-index: 4; background: var(--surface-2); }
.ui-table tbody tr:hover td.ui-actions { background: #fafbfd; }
.ui-table tbody tr.is-selected td.ui-actions { background: var(--otl-orange-050); }
.ui-table--compact td { padding: 7px 10px; }
.ui-table--fixed td { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 320px; }
.ui-table td.ui-strong { font-weight: 600; color: var(--ink); }
.ui-table td.ui-mono { font-family: var(--mono); font-size: 12px; }
.ui-table .ui-sub { display: block; color: var(--muted); font-size: 11.5px; margin-top: 2px; }

.ui-table-toolbar {
    display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
    padding: 10px 12px; border-bottom: 1px solid var(--line);
    background: var(--surface);
}
.ui-table-toolbar__spacer { flex: 1 1 auto; }
.ui-search { position: relative; }
.ui-search .ui-i { position: absolute; left: 9px; top: 50%; transform: translateY(-50%); color: var(--muted-2); width: 15px; height: 15px; }
.ui-search input { padding-left: 30px; min-width: 200px; }

/* ---------- формы ---------- */

.ui-field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.ui-field > label, .ui-label {
    font-size: 12px; font-weight: 650; color: var(--ink-2);
}
.ui-field .ui-help { font-size: 11.5px; color: var(--muted); line-height: 1.4; }
.ui-field .ui-error { font-size: 11.5px; color: var(--danger); }
.ui-input, .ui-select, .ui-textarea,
.ui-field input[type="text"], .ui-field input[type="password"], .ui-field input[type="number"],
.ui-field input[type="date"], .ui-field input[type="datetime-local"], .ui-field input[type="search"],
.ui-field input[type="email"], .ui-field input[type="tel"], .ui-field select, .ui-field textarea {
    width: 100%; height: 36px; padding: 0 10px;
    border: 1px solid var(--line-strong); border-radius: 8px;
    background: #fff; color: var(--ink);
    font: 14px/1.3 var(--font);
    transition: border-color .14s, box-shadow .14s;
}
.ui-textarea, .ui-field textarea { height: auto; padding: 8px 10px; resize: vertical; min-height: 80px; }
.ui-field select, .ui-select { padding-right: 28px; }
.ui-input:focus, .ui-select:focus, .ui-textarea:focus,
.ui-field input:focus, .ui-field select:focus, .ui-field textarea:focus {
    outline: 0; border-color: var(--otl-orange); box-shadow: 0 0 0 3px rgba(255, 107, 0, .14);
}
.ui-input:disabled, .ui-field input:disabled, .ui-field select:disabled, .ui-field textarea:disabled {
    background: var(--surface-2); color: var(--muted); cursor: not-allowed;
}
.ui-input--sm { height: 30px; font-size: 12.5px; }
.ui-form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 14px; }
.ui-form-grid .ui-col-2 { grid-column: span 2; }
.ui-form-grid .ui-col-full { grid-column: 1 / -1; }
@media (max-width: 700px) { .ui-form-grid { grid-template-columns: 1fr; } .ui-form-grid .ui-col-2 { grid-column: auto; } }

.ui-check { display: flex; align-items: flex-start; gap: 8px; font-size: 13px; color: var(--ink-2); cursor: pointer; }
.ui-check input[type="checkbox"], .ui-check input[type="radio"] { width: 16px; height: 16px; margin: 1px 0 0; accent-color: var(--otl-orange); flex: none; }
.ui-check span { line-height: 1.4; }

.ui-form-actions {
    display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
    padding-top: 14px; margin-top: 14px; border-top: 1px solid var(--line);
}
.ui-form-actions--end { justify-content: flex-end; }

/* ---------- табы ---------- */

.ui-tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); margin-bottom: 16px; overflow-x: auto; }
.ui-tab {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 9px 12px; border: 0; border-bottom: 2px solid transparent; margin-bottom: -1px;
    background: none; color: var(--muted); font: 600 13px var(--font);
    cursor: pointer; white-space: nowrap; text-decoration: none;
}
.ui-tab:hover { color: var(--ink); text-decoration: none; }
.ui-tab[aria-selected="true"], .ui-tab.is-active, .ui-tab[aria-current="page"] {
    color: var(--otl-orange-700); border-bottom-color: var(--otl-orange);
}
.ui-tab__count {
    margin-left: 4px; padding: 0 6px; border-radius: 999px;
    background: var(--surface-3); color: var(--muted); font-size: 11px; font-weight: 700;
}
.ui-tabs--pills { border-bottom: 0; gap: 6px; }
.ui-tabs--pills .ui-tab {
    border: 1px solid var(--line); border-radius: 999px; padding: 6px 12px; margin: 0;
    background: #fff;
}
.ui-tabs--pills .ui-tab.is-active, .ui-tabs--pills .ui-tab[aria-selected="true"] {
    background: var(--otl-orange-050); border-color: var(--otl-orange-100); color: var(--otl-orange-700);
}

/* ---------- алерты и пустые состояния ---------- */

.ui-alert {
    display: flex; align-items: flex-start; gap: 10px;
    padding: 11px 13px; border-radius: var(--radius-sm);
    border: 1px solid var(--line); background: var(--surface-2); color: var(--ink-2);
    font-size: 13px;
}
.ui-alert .ui-i { margin-top: 1px; }
.ui-alert__body { min-width: 0; }
.ui-alert__body strong { display: block; margin-bottom: 2px; }
.ui-alert--info { background: var(--info-bg); border-color: #cfdcfb; color: #1e3a8a; }
.ui-alert--warn { background: var(--warn-bg); border-color: #f4dcb5; color: #7a4700; }
.ui-alert--danger { background: var(--danger-bg); border-color: #f3c6c6; color: #8e1e1e; }
.ui-alert--ok { background: var(--ok-bg); border-color: #bfe6d4; color: #0f5f46; }

.ui-empty { padding: 34px 20px; text-align: center; color: var(--muted); }
.ui-empty .ui-i { width: 34px; height: 34px; color: var(--muted-2); margin-bottom: 10px; }
.ui-empty h3 { color: var(--ink-2); margin-bottom: 4px; font-size: 14px; }
.ui-empty p { margin: 0 auto; max-width: 46ch; font-size: 12.5px; }

/* ---------- статистика ---------- */

.ui-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(168px, 1fr)); gap: 12px; }
.ui-stat {
    padding: 13px 15px; background: var(--surface);
    border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-1);
    min-width: 0;
}
.ui-stat__label { display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: 11.5px; font-weight: 600; letter-spacing: .01em; }
.ui-stat__value { margin-top: 6px; font-size: 24px; font-weight: 720; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.ui-stat__value small { font-size: 13px; font-weight: 600; color: var(--muted); letter-spacing: 0; }
.ui-stat__hint { margin-top: 3px; font-size: 11.5px; color: var(--muted-2); }
.ui-stat--ok .ui-stat__value { color: var(--ok); }
.ui-stat--warn .ui-stat__value { color: var(--warn); }
.ui-stat--danger .ui-stat__value { color: var(--danger); }
.ui-stat--orange .ui-stat__value { color: var(--otl-orange-700); }

.ui-kv { display: grid; grid-template-columns: minmax(140px, max-content) 1fr; gap: 8px 18px; font-size: 13px; }
.ui-kv dt { color: var(--muted); }
.ui-kv dd { margin: 0; color: var(--ink); overflow-wrap: anywhere; }

/* ---------- модальные окна ---------- */

.ui-modal {
    position: fixed; inset: 0; z-index: 120;
    display: flex; align-items: flex-start; justify-content: center;
    padding: 5vh 16px 24px;
    background: rgba(12, 15, 20, .55);
    overflow-y: auto;
}
.ui-modal[hidden] { display: none; }
.ui-modal__box {
    width: 100%; max-width: 560px;
    background: #fff; border-radius: var(--radius-lg); box-shadow: var(--shadow-3);
    overflow: hidden;
}
.ui-modal__box--lg { max-width: 900px; }
.ui-modal__box--xl { max-width: 1180px; }
.ui-modal__head {
    display: flex; align-items: center; justify-content: space-between; gap: 12px;
    padding: 15px 18px; border-bottom: 1px solid var(--line);
}
.ui-modal__head h2 { font-size: 16px; }
.ui-modal__close {
    width: 30px; height: 30px; display: inline-flex; align-items: center; justify-content: center;
    border: 0; border-radius: 7px; background: transparent; color: var(--muted); cursor: pointer;
}
.ui-modal__close:hover { background: var(--surface-3); color: var(--ink); }
.ui-modal__body { padding: 18px; }
.ui-modal__foot {
    display: flex; justify-content: flex-end; gap: 8px; flex-wrap: wrap;
    padding: 13px 18px; border-top: 1px solid var(--line); background: var(--surface-2);
}

/* ---------- уведомления ---------- */

.ui-toasts {
    position: fixed; right: 18px; bottom: 18px; z-index: 200;
    display: flex; flex-direction: column; gap: 8px; max-width: min(380px, calc(100vw - 36px));
}
.ui-toast {
    padding: 11px 14px; border-radius: var(--radius);
    background: #1c2027; color: #fff; box-shadow: var(--shadow-3);
    font-size: 13px; animation: ui-toast-in .16s ease-out;
}
.ui-toast--ok { background: #0f6b4a; }
.ui-toast--danger { background: #a51f1f; }
.ui-toast--warn { background: #8a5200; }
@keyframes ui-toast-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* ---------- прочее ---------- */

.ui-divider { height: 1px; background: var(--line); border: 0; margin: 16px 0; }
.ui-scroll-x { overflow-x: auto; max-width: 100%; }
.ui-mono { font-family: var(--mono); }
.ui-code { font-family: var(--mono); font-size: 12px; background: var(--surface-3); padding: 1px 5px; border-radius: 4px; }
.ui-loading { display: inline-flex; align-items: center; gap: 8px; color: var(--muted); font-size: 12.5px; }
.ui-spinner {
    width: 16px; height: 16px; border-radius: 50%;
    border: 2px solid var(--line-strong); border-top-color: var(--otl-orange);
    animation: ui-spin .7s linear infinite;
}
@keyframes ui-spin { to { transform: rotate(360deg); } }
.ui-scrim { display: none; }

.ui-pagination { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.ui-pagination a, .ui-pagination span {
    display: inline-flex; align-items: center; justify-content: center;
    min-width: 30px; height: 30px; padding: 0 8px;
    border: 1px solid var(--line); border-radius: 7px;
    color: var(--ink-2); font-size: 12.5px; text-decoration: none; background: #fff;
}
.ui-pagination a:hover { border-color: var(--line-strong); background: var(--surface-2); text-decoration: none; }
.ui-pagination .is-current { background: var(--otl-orange); border-color: var(--otl-orange); color: #fff; font-weight: 700; }
.ui-pagination .is-disabled { opacity: .45; pointer-events: none; }

.ui-dropdown { position: relative; }
.ui-dropdown__menu {
    position: absolute; right: 0; top: calc(100% + 6px); z-index: 80;
    min-width: 200px; padding: 6px;
    background: #fff; border: 1px solid var(--line); border-radius: var(--radius);
    box-shadow: var(--shadow-3);
}
.ui-dropdown__menu[hidden] { display: none; }
.ui-dropdown__menu button, .ui-dropdown__menu a {
    display: flex; align-items: center; gap: 8px; width: 100%;
    padding: 8px 10px; border: 0; border-radius: var(--radius-sm);
    background: none; color: var(--ink-2); font: inherit; text-align: left; cursor: pointer;
}
.ui-dropdown__menu button:hover, .ui-dropdown__menu a:hover { background: var(--surface-2); text-decoration: none; }

/* ---------- адаптивность ---------- */

@media (max-width: 1180px) {
    .ui-header__crumb { display: none; }
    .ui-user__name { max-width: 110px; }
}

@media (max-width: 980px) {
    :root { --sidebar-w: 232px; }
    .ui-burger { display: inline-flex; }
    .ui-sidebar {
        transform: translateX(-102%);
        transition: transform .18s ease-out;
        box-shadow: var(--shadow-3);
        z-index: 80;
    }
    body.ui-nav-open .ui-sidebar { transform: none; }
    body.ui-nav-open .ui-scrim {
        display: block; position: fixed; inset: var(--header-h) 0 0 0; z-index: 75;
        background: rgba(12, 15, 20, .4);
    }
    .ui-main { margin-left: 0; padding: 16px 14px 40px; }
    .ui-header { padding: 0 12px; gap: 10px; }
    .ui-header__meta .ui-chip { display: none; }
    .ui-user__name { display: none; }
    .ui-page-head { margin-bottom: 14px; }
    h1 { font-size: 19px; }
}

@media (max-width: 640px) {
    .ui-clock { display: none; }
    .ui-header__title { font-size: 14px; }
    .ui-page-head__actions { width: 100%; }
    .ui-page-head__actions .ui-btn { flex: 1 1 auto; }
    .ui-grid--2, .ui-grid--3 { grid-template-columns: 1fr; }
    .ui-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .ui-stat__value { font-size: 20px; }
    .ui-modal { padding: 0; align-items: stretch; }
    .ui-modal__box { max-width: none; border-radius: 0; min-height: 100%; }
    .ui-table { min-width: 560px; }
    .ui-kv { grid-template-columns: 1fr; gap: 3px 0; }
    .ui-kv dt { margin-top: 8px; }
}

@media print {
    .ui-header, .ui-sidebar, .ui-page-head__actions, .ui-table-toolbar { display: none !important; }
    .ui-main { margin: 0; padding: 0; }
    body.ui-body { background: #fff; }
}

/* ---------- вход ---------- */

.ui-auth {
    min-height: 100vh; width: 100%;
    display: flex; align-items: center; justify-content: center;
    padding: 28px 16px;
    background:
        radial-gradient(900px 420px at 50% -10%, #fff2e6 0%, rgba(255, 242, 230, 0) 70%),
        var(--bg);
}
.ui-auth__wrap { width: 100%; max-width: 380px; display: flex; flex-direction: column; gap: 14px; }
.ui-auth__brand {
    align-self: center; display: inline-flex; align-items: center; justify-content: center;
    height: 54px; padding: 0 14px; background: #0c0d10; border-radius: 12px;
    box-shadow: var(--shadow-2);
}
.ui-auth__brand img { height: 30px; width: auto; }
.ui-auth__card {
    background: #fff; border: 1px solid var(--line); border-radius: var(--radius-lg);
    box-shadow: var(--shadow-2); padding: 24px 22px 20px;
}
.ui-auth__card h1 { font-size: 19px; text-align: center; margin-bottom: 4px; }
.ui-auth__card .ui-muted { text-align: center; margin-bottom: 18px; font-size: 12.5px; }
.ui-auth__card .ui-field { margin-bottom: 12px; }
.ui-auth__card .ui-btn { width: 100%; margin-top: 2px; }
.ui-auth__error {
    margin-bottom: 12px; padding: 9px 11px; border-radius: 8px;
    background: var(--danger-bg); color: var(--danger); font-size: 12.5px; font-weight: 600;
}
.ui-auth__quote {
    display: flex; gap: 12px; align-items: center;
    background: #fff; border: 1px solid var(--line); border-radius: var(--radius);
    padding: 12px 14px; box-shadow: var(--shadow-1);
}
.ui-auth__quote img { width: 46px; height: 46px; border-radius: 50%; object-fit: cover; flex: none; border: 2px solid var(--otl-orange-100); }
.ui-auth__quote p { margin: 0; font-size: 12.5px; line-height: 1.5; color: var(--muted); font-style: italic; }
.ui-auth__foot { text-align: center; color: var(--muted-2); font-size: 11.5px; }

/* ---------- служебные варианты ---------- */

.ui-main--plain { margin-left: 0; padding-top: 8vh; }
.ui-main--plain .ui-page { max-width: 640px; }

.ui-user__btn--light {
    background: #fff; border-color: var(--line-strong); color: var(--ink);
}
.ui-user__btn--light:hover { background: var(--surface-2); }
.ui-user__btn--light .ui-user__caret { color: var(--muted); }

/* Рабочая панель подбора ЖК/ЦИАН (внутри существующего .panel-transfers) */
.ui-workbar {
    display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
    min-height: 40px;
}
.ui-workbar__brand {
    display: inline-flex; align-items: center; height: 32px; padding: 0 6px;
    background: #000; border-radius: 7px; flex: none;
}
.ui-workbar__brand img { height: 20px; width: auto; }
.ui-workbar__links { display: flex; align-items: center; gap: 2px; flex-wrap: wrap; }
.ui-workbar__right { display: flex; align-items: center; gap: 6px; margin-left: auto; flex-wrap: wrap; }
.ui-workbar .ui-user__name { max-width: 140px; }
@media (max-width: 900px) {
    .ui-workbar__links { display: none; }
    .ui-workbar__right { width: 100%; margin-left: 0; }
}

/* Верхняя панель на рабочей странице подбора (index.php): остаётся внутри panel-transfers */
.otl-top-bar.otl-top-bar-inline {
    display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
    margin: 0; padding: 0; background: none; border: 0;
}

/* ---------- глобальная панель звонилки в шапке ---------- */
.ui-phone {
    display: inline-flex; align-items: center; gap: 7px;
    height: 32px; padding: 0 11px; margin-right: 2px;
    border-radius: 999px; cursor: pointer;
    background: #1f232b; border: 1px solid #2c313c; color: #c8cdd8;
    font: 600 12px var(--font); white-space: nowrap; position: relative;
}
.ui-phone[hidden] { display: none; }
.ui-phone:hover { background: #262b35; color: #fff; }
.ui-phone .ui-i { width: 16px; height: 16px; color: #9ba3b4; }
.ui-phone__dot {
    width: 7px; height: 7px; border-radius: 50%; background: #b0b7c3; flex: none;
    box-shadow: 0 0 0 2px #14161b;
}
.ui-phone.is-ok { border-color: #2f6b4b; color: #c9ead9; }
.ui-phone.is-ok .ui-phone__dot { background: #27ae60; }
.ui-phone.is-call { border-color: #7a2c28; color: #ffd9d6; background: #2a1b1a; }
.ui-phone.is-call .ui-phone__dot { background: #e53935; animation: ui-phone-blink 1s infinite; }
.ui-phone.is-err .ui-phone__dot { background: #ff5a4f; }
@keyframes ui-phone-blink { 50% { opacity: .35; } }
@media (max-width: 640px) {
    .ui-phone { padding: 0 9px; }
    .ui-phone__label { display: none; }
}

/* ---------- колокольчик задач: «светофор» ---------- */
/*
   Три лампы (красная/жёлтая/зелёная) + счётчик открытых задач.
   Красная горит — есть просроченные, жёлтая — задачи на сегодня,
   зелёная — просрочки и задачи на сегодня отсутствуют.
   В шапке (тёмный фон) и в рабочей панели (.ui-workbar, светлый фон).
*/

.ui-bell {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    height: 34px;
    padding: 0 10px 0 9px;
    border-radius: 999px;
    border: 1px solid #2c313c;
    background: #1f232b;
    color: #e7eaf1;
    font: 600 12px/1 var(--font);
    white-space: nowrap;
    cursor: pointer;
    flex: none;
    text-decoration: none;
    vertical-align: middle;
    transition: background .15s ease, border-color .15s ease, box-shadow .15s ease;
}

.ui-bell:hover {
    background: #262b35;
    border-color: #3c4350;
    color: #fff;
    text-decoration: none;
}

.ui-bell:focus-visible {
    outline: 2px solid var(--otl-orange);
    outline-offset: 2px;
}

.ui-bell__icon {
    display: inline-flex;
    align-items: center;
    color: #c8cdd8;
}

.ui-bell__icon .ui-i {
    width: 16px;
    height: 16px;
}

.ui-bell__lamps {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    padding: 0 1px;
}

.ui-bell__lamp {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #3c4350;
    opacity: .6;
    flex: none;
}

.ui-bell__lamp.is-on {
    opacity: 1;
}

.ui-bell__count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 22px;
    height: 20px;
    padding: 0 6px;
    border-radius: 999px;
    background: var(--otl-orange);
    color: #fff;
    font: 800 11.5px/1 var(--font);
    font-variant-numeric: tabular-nums;
    letter-spacing: 0;
}

.ui-bell__label {
    color: #c8cdd8;
    font-weight: 600;
    letter-spacing: .01em;
}

/* состояния: цвет лампы и пилюли-счётчика */

.ui-bell--red {
    background: #2a1b1a;
    border-color: #7a2c28;
}

.ui-bell--red:hover {
    background: #33201e;
    border-color: #9c3a34;
}

.ui-bell--red .ui-bell__lamp--red.is-on {
    background: #ff4d43;
    box-shadow: 0 0 0 2px rgba(255, 77, 67, .2), 0 0 7px rgba(255, 77, 67, .7);
    animation: ui-bell-pulse 2.6s ease-in-out infinite;
}

.ui-bell--red .ui-bell__count {
    background: #d92d20;
}

.ui-bell--amber {
    background: #2a2317;
    border-color: #7a5a1a;
}

.ui-bell--amber:hover {
    background: #332a1a;
    border-color: #9c741f;
}

.ui-bell--amber .ui-bell__lamp--amber.is-on {
    background: #ffb020;
    box-shadow: 0 0 0 2px rgba(255, 176, 32, .18), 0 0 7px rgba(255, 176, 32, .6);
}

.ui-bell--amber .ui-bell__count {
    background: #a97000;
}

.ui-bell--green {
    background: #18251f;
    border-color: #2f6b4b;
}

.ui-bell--green:hover {
    background: #1d2d25;
    border-color: #3b8560;
}

.ui-bell--green .ui-bell__lamp--green.is-on {
    background: #35d07f;
    box-shadow: 0 0 0 2px rgba(53, 208, 127, .16), 0 0 7px rgba(53, 208, 127, .55);
}

.ui-bell--green .ui-bell__count {
    background: #1f7a4d;
}

@keyframes ui-bell-pulse {
    0%, 100% { box-shadow: 0 0 0 2px rgba(255, 77, 67, .2), 0 0 7px rgba(255, 77, 67, .7); }
    50%      { box-shadow: 0 0 0 3px rgba(255, 77, 67, .08), 0 0 11px rgba(255, 77, 67, .9); }
}

/* светлая рабочая панель (index.php): тот же колокольчик на белом фоне */

.ui-workbar .ui-bell,
.otl-top-bar .ui-bell {
    height: 32px;
    background: #fff;
    border-color: var(--line-strong);
    color: var(--ink);
    box-shadow: var(--shadow-1);
}

.ui-workbar .ui-bell:hover,
.otl-top-bar .ui-bell:hover {
    background: var(--surface-2);
    border-color: #b9c1cd;
    color: var(--ink);
}

.ui-workbar .ui-bell__icon,
.otl-top-bar .ui-bell__icon {
    color: var(--muted);
}

.ui-workbar .ui-bell__lamp,
.otl-top-bar .ui-bell__lamp {
    background: #cfd6e0;
    opacity: 1;
}

.ui-workbar .ui-bell__label,
.otl-top-bar .ui-bell__label {
    color: var(--muted);
}

.ui-workbar .ui-bell--red,
.otl-top-bar .ui-bell--red {
    background: #fff7f6;
    border-color: #f0b8b3;
}

.ui-workbar .ui-bell--red:hover,
.otl-top-bar .ui-bell--red:hover {
    background: #fff1ef;
    border-color: #e39a94;
}

.ui-workbar .ui-bell--amber,
.otl-top-bar .ui-bell--amber {
    background: #fffaf0;
    border-color: #ecd39b;
}

.ui-workbar .ui-bell--amber:hover,
.otl-top-bar .ui-bell--amber:hover {
    background: #fff5e3;
    border-color: #ddbb6e;
}

.ui-workbar .ui-bell--green,
.otl-top-bar .ui-bell--green {
    background: #f5fbf8;
    border-color: #b6dfc9;
}

.ui-workbar .ui-bell--green:hover,
.otl-top-bar .ui-bell--green:hover {
    background: #edf8f2;
    border-color: #96cfb1;
}

/* мобильный: подпись скрывается, лампы и счётчик остаются */

@media (max-width: 900px) {
    .ui-bell__label { display: none; }
}

@media (max-width: 640px) {
    /* на узком экране часы и чипы скрыты: пустой блок не должен отнимать место у колокольчика */
    .ui-header__meta:empty { display: none; }
    .ui-bell {
        gap: 5px;
        height: 30px;
        padding: 0 8px 0 7px;
    }
    .ui-bell__icon .ui-i { width: 15px; height: 15px; }
    .ui-bell__lamps { gap: 2px; }
    .ui-bell__lamp { width: 6px; height: 6px; }
    .ui-bell__count { min-width: 20px; height: 18px; padding: 0 5px; font-size: 11px; }
}

@media (max-width: 420px) {
    .ui-header .ui-bell { padding: 0 7px; gap: 4px; }
}

@media (prefers-reduced-motion: reduce) {
    .ui-bell--red .ui-bell__lamp--red.is-on { animation: none; }
}

@media print {
    .ui-bell { display: none !important; }
}
