/* ============================================================================
   Market-KKM — дизайн-система.

   Слой поверх Bootstrap 4: переопределяет его компоненты через токены,
   поэтому разметка вьюх и все JS-хуки остаются нетронутыми.

   Две темы:
     :root         — светлая, рабочий кабинет (таблицы, отчёты, долгая работа)
     .theme-dark   — тёмная, входные экраны (логин, QR-терминал, страница пассажира)

   Подключается последним в assets/AppAsset.php.
   ========================================================================== */

@font-face {
    font-family: 'Inter';
    font-style: normal;
    font-weight: 100 900;
    font-display: swap;
    src: url('/fonts/inter/InterVariable.woff2') format('woff2');
}

:root {
    /* поверхности */
    --bg: #f5f6f8;
    --bg-subtle: #eef0f4;
    --surface: #ffffff;
    --surface-2: #fafbfc;
    --border: #e3e6ec;
    --border-strong: #d0d5dd;

    /* текст */
    --text: #101828;
    --text-2: #5c6a80;
    --text-3: #8a94a6;
    --text-inverse: #ffffff;

    /* бренд и статусы */
    --brand: #3b5bfd;
    --brand-600: #2f49d4;
    --brand-100: #e8ecff;
    --accent: #22d3ee;
    --success: #12b76a;
    --success-100: #e6f7ef;
    --danger: #f04438;
    --danger-100: #fdeceb;
    --warning: #f79009;
    --warning-100: #fef3e2;

    --gradient: linear-gradient(135deg, var(--brand) 0%, #6d5cf7 55%, var(--accent) 100%);

    /* геометрия */
    --r-sm: 8px;
    --r-md: 12px;
    --r-lg: 16px;
    --r-xl: 22px;
    --r-pill: 999px;

    /* тени */
    --shadow-xs: 0 1px 2px rgba(16, 24, 40, .05);
    --shadow-sm: 0 1px 3px rgba(16, 24, 40, .08), 0 1px 2px rgba(16, 24, 40, .04);
    --shadow-md: 0 4px 12px rgba(16, 24, 40, .08), 0 2px 4px rgba(16, 24, 40, .04);
    --shadow-lg: 0 16px 40px rgba(16, 24, 40, .12), 0 4px 10px rgba(16, 24, 40, .06);

    --header-bg: #ffffff;
    --header-text: #101828;
    --header-muted: #667085;
    --header-border: var(--border);
}

.theme-dark {
    --bg: #0b0e14;
    --bg-subtle: #0f131b;
    --surface: rgba(255, 255, 255, .045);
    --surface-2: rgba(255, 255, 255, .07);
    --border: rgba(255, 255, 255, .09);
    --border-strong: rgba(255, 255, 255, .16);

    --text: #e9ecf2;
    --text-2: #9aa4b8;
    --text-3: #6d7789;
    --text-inverse: #0b0e14;

    --brand: #6d8bff;
    --brand-600: #5570f5;
    --brand-100: rgba(109, 139, 255, .16);
    --accent: #3ddced;

    --success-100: rgba(18, 183, 106, .16);
    --danger-100: rgba(240, 68, 56, .16);
    --warning-100: rgba(247, 144, 9, .16);

    --shadow-sm: 0 1px 3px rgba(0, 0, 0, .5);
    --shadow-md: 0 8px 24px rgba(0, 0, 0, .45);
    --shadow-lg: 0 24px 60px rgba(0, 0, 0, .55);

    --header-bg: rgba(11, 14, 20, .72);
    --header-text: #e9ecf2;
    --header-muted: #9aa4b8;
    --header-border: rgba(255, 255, 255, .08);
}

/* ---------------------------------------------------------------- основа */

body {
    background: var(--bg);
    color: var(--text);
    font-family: 'Inter', -apple-system, 'Segoe UI', system-ui, sans-serif;
    font-size: 15px;
    line-height: 1.55;
    letter-spacing: -.006em;
    -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4, h5, h6,
.h1, .h2, .h3, .h4, .h5, .h6 {
    color: var(--text);
    font-weight: 650;
    letter-spacing: -.022em;
}

h1, .h1 { font-size: 1.9rem; }
h2, .h2 { font-size: 1.55rem; }
h3, .h3 { font-size: 1.3rem; }
h4, .h4 { font-size: 1.1rem; }

a {
    color: var(--brand);
    text-decoration: none;
    transition: color .15s ease;
}

a:hover {
    color: var(--brand-600);
    text-decoration: none;
}

hr {
    border-color: var(--border);
}

.text-muted {
    color: var(--text-2) !important;
}

/* Цифры одинаковой ширины — суммы в колонках не «прыгают» */
td, th, .tabular {
    font-variant-numeric: tabular-nums;
    font-feature-settings: 'tnum' 1;
}

/* ------------------------------------------------------------- заголовок */

.navbar {
    background: var(--header-bg) !important;
    border-bottom: 1px solid var(--header-border);
    padding: .55rem 1.25rem;
    backdrop-filter: saturate(180%) blur(14px);
}

.navbar .navbar-brand img {
    width: auto !important;
    height: 30px !important;
}

.theme-dark .navbar .navbar-brand img,
.navbar .navbar-brand img {
    filter: none;
}

.navbar .nav-link {
    color: var(--header-muted) !important;
    font-weight: 500;
    font-size: .93rem;
    padding: .45rem .85rem !important;
    border-radius: var(--r-sm);
    transition: background .15s ease, color .15s ease;
}

.navbar .nav-link:hover,
.navbar .nav-item.active .nav-link {
    color: var(--header-text) !important;
    background: var(--bg-subtle);
}

.theme-dark .navbar .nav-link:hover {
    background: rgba(255, 255, 255, .07);
}

/* Бренд: квадратная плитка + собственная типографика вместо картинки с текстом */
.app-brand {
    display: inline-flex;
    align-items: center;
    gap: .6rem;
    margin-right: 1.6rem;
    padding: 0;
}

.brand-mark {
    width: 30px;
    height: 30px;
    border-radius: 8px;
    box-shadow: var(--shadow-xs);
}

.brand-text {
    color: var(--header-text);
    font-size: 1.02rem;
    font-weight: 700;
    letter-spacing: -.02em;
}

.brand-dash {
    color: var(--brand);
}

.app-header {
    position: sticky;
    top: 0;
    z-index: 1030;
}

.lang-chip {
    background: var(--bg-subtle);
    border: 1px solid var(--border);
    border-radius: var(--r-pill);
    display: inline-block;
    font-size: .78rem;
    font-weight: 600;
    letter-spacing: .05em;
    padding: .12rem .6rem;
}

.theme-dark .lang-chip {
    background: rgba(255, 255, 255, .07);
    border-color: rgba(255, 255, 255, .12);
}

/* Переключатель светлой и тёмной темы */
.theme-toggle-item .nav-link {
    padding: 0 !important;
    background: transparent !important;
}

.theme-toggle {
    background: var(--bg-subtle);
    border: 1px solid var(--border);
    border-radius: var(--r-pill);
    color: var(--text-2);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    padding: 0;
    transition: background .15s ease, color .15s ease, transform .15s ease;
}

.theme-toggle:hover {
    background: var(--brand-100);
    color: var(--brand);
    transform: rotate(-12deg);
}

.theme-dark .theme-toggle {
    background: rgba(255, 255, 255, .07);
    border-color: rgba(255, 255, 255, .12);
}

/* Солнце в тёмной теме, луна в светлой — иконка показывает, куда переключишься */
.theme-icon { display: none; line-height: 1; }
.theme-icon-moon { display: inline-flex; }
.theme-dark .theme-icon-moon { display: none; }
.theme-dark .theme-icon-sun { display: inline-flex; }

/* Пока подгружается страница на другом языке */
.is-lang-switching {
    cursor: progress;
}

.is-lang-switching .app-main,
.is-lang-switching .hero-card {
    opacity: .55;
    transition: opacity .12s ease;
}

.nav-balance b {
    color: var(--success);
}

.nav-logout {
    display: inline-flex;
    align-items: center;
    gap: .35rem;
}

/* Кнопка-бургер: без navbar-light/navbar-dark Bootstrap не даёт иконке
   фона и кнопка невидима. Рисуем три полоски цветом текущей темы. */
.navbar-toggler {
    background: var(--bg-subtle);
    border: 1px solid var(--border);
    border-radius: var(--r-sm);
    padding: .5rem .65rem;
    cursor: pointer;
}

.theme-dark .navbar-toggler {
    background: rgba(255, 255, 255, .07);
    border-color: rgba(255, 255, 255, .12);
}

.navbar-toggler-icon {
    background-image: none !important;
    display: block;
    width: 20px;
    height: 2px;
    border-radius: 1px;
    background: var(--header-text);
    margin: 8px 0;
    box-shadow: 0 -6px 0 var(--header-text), 0 6px 0 var(--header-text);
}

/* Раскрытое меню на узком экране: пункты в столбик, с отступами и чертой */
@media (max-width: 991.98px) {
    .navbar-collapse {
        border-top: 1px solid var(--header-border);
        margin-top: .55rem;
        padding-top: .45rem;
    }

    .navbar .nav-link {
        padding: .55rem .6rem !important;
    }

    .app-nav-right {
        border-top: 1px solid var(--header-border);
        margin-top: .35rem;
        padding-top: .45rem;
    }

    /* Тема и язык в раскрытом меню встают в строку, а не в столбик */
    .theme-toggle-item .nav-link {
        display: inline-flex;
    }
}

/* Развёрнутая шапка: пунктов много, ужимаем подписи, чтобы весь набор
   администратора помещался в одну строку уже на ноутбучных ширинах */
@media (min-width: 992px) {
    .navbar .nav-link {
        font-size: .88rem;
        padding: .45rem .6rem !important;
    }

    .app-brand {
        margin-right: 1rem;
    }
}

@media (min-width: 992px) and (max-width: 1279.98px) {
    .navbar .nav-link {
        font-size: .82rem;
        padding: .4rem .45rem !important;
    }

    .brand-text {
        font-size: .95rem;
    }
}

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

main {
    padding-top: 1.75rem;
    padding-bottom: 3rem;
}

/* Содержимое не должно прилипать к краям окна: боковые поля растут вместе
   с шириной экрана, а на очень широких мониторах колонка центрируется. */
.container-fluid {
    max-width: 1560px;
    margin: 0 auto;
    padding-left: clamp(1rem, 3vw, 2.5rem);
    padding-right: clamp(1rem, 3vw, 2.5rem);
}

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

.card,
.well,
.surface {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    box-shadow: var(--shadow-sm);
    padding: 1.15rem 1.25rem;
}

.theme-dark .card,
.theme-dark .well,
.theme-dark .surface {
    backdrop-filter: blur(12px);
}

/* Панели в непеределанных вьюхах помечены инлайновым background —
   перебиваем, чтобы серый фон Bootstrap не спорил с темой.
   .row.summary сюда не входит: на сетке плиток рамка не нужна. */
.filter-panel,
.well {
    background: var(--surface) !important;
    border: 1px solid var(--border) !important;
    border-radius: var(--r-lg) !important;
    box-shadow: var(--shadow-sm);
}

/* Если в старой разметке остался .row.summary — гасим отрицательные поля
   бутстраповского .row, из-за которых содержимое вылезает за края страницы */
.row.summary {
    margin-left: 0;
    margin-right: 0;
}

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

.btn {
    font-weight: 550;
    font-size: .92rem;
    border-radius: var(--r-sm);
    padding: .48rem 1.05rem;
    border: 1px solid transparent;
    transition: transform .12s ease, box-shadow .15s ease, background .15s ease, border-color .15s ease;
}

.btn-sm,
.btn-group-sm > .btn {
    font-size: .8rem;
    padding: .3rem .6rem;
}

.btn:active {
    transform: translateY(1px);
}

.btn:focus,
.btn.focus {
    box-shadow: 0 0 0 3px var(--brand-100);
}

.btn-primary {
    background: var(--gradient);
    border: 0;
    color: #fff;
    box-shadow: 0 1px 2px rgba(16, 24, 40, .12);
}

.btn-primary:hover {
    filter: brightness(1.07);
    color: #fff;
    box-shadow: 0 6px 18px rgba(59, 91, 253, .32);
}

.btn-success {
    background: var(--success);
    border-color: var(--success);
}

.btn-success:hover {
    background: #0e9f5c;
    border-color: #0e9f5c;
}

.btn-danger {
    background: var(--danger);
    border-color: var(--danger);
}

.btn-danger:hover {
    background: #d92d20;
    border-color: #d92d20;
}

.btn-secondary,
.btn-outline-secondary {
    background: var(--surface);
    border-color: var(--border-strong);
    color: var(--text-2);
}

.btn-secondary:hover,
.btn-outline-secondary:hover {
    background: var(--bg-subtle);
    border-color: var(--text-3);
    color: var(--text);
}

.btn-outline-primary {
    background: transparent;
    border-color: var(--brand);
    color: var(--brand);
}

.btn-outline-primary:hover {
    background: var(--brand);
    color: #fff;
}

.btn-outline-danger {
    background: transparent;
    border-color: var(--danger);
    color: var(--danger);
}

.btn-outline-danger:hover {
    background: var(--danger);
    border-color: var(--danger);
    color: #fff;
}

.btn-sm {
    padding: .3rem .7rem;
    font-size: .84rem;
    border-radius: 7px;
}

.btn-block + .btn-block {
    margin-top: .5rem;
}

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

.form-control,
.custom-select,
select.form-control {
    background: var(--surface);
    border: 1px solid var(--border-strong);
    border-radius: var(--r-sm);
    color: var(--text);
    font-size: .93rem;
    padding: .5rem .8rem;
    height: auto;
    box-shadow: var(--shadow-xs);
    transition: border-color .15s ease, box-shadow .15s ease;
}

.form-control:focus {
    background: var(--surface);
    border-color: var(--brand);
    color: var(--text);
    box-shadow: 0 0 0 3px var(--brand-100);
}

.form-control::placeholder {
    color: var(--text-3);
}

.theme-dark .form-control,
.theme-dark .custom-select {
    background: rgba(255, 255, 255, .05);
}

/* Иконка календаря у input[type=date] рисуется браузером тёмной — на тёмном фоне её не видно */
.theme-dark input[type="date"]::-webkit-calendar-picker-indicator,
.theme-dark input[type="datetime-local"]::-webkit-calendar-picker-indicator {
    filter: invert(1);
    opacity: .65;
    cursor: pointer;
}

.theme-dark input[type="date"]::-webkit-calendar-picker-indicator:hover,
.theme-dark input[type="datetime-local"]::-webkit-calendar-picker-indicator:hover {
    opacity: 1;
}

/* Нативные выпадающие списки в тёмной теме: пункты рисует ОС, задаём явно */
.theme-dark select.form-control option {
    background: #141922;
    color: var(--text);
}

label,
.form-label,
.col-form-label {
    color: var(--text-2);
    font-size: .82rem;
    font-weight: 550;
    letter-spacing: .01em;
    margin-bottom: .3rem;
}

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

.table {
    background: var(--surface);
    border-radius: var(--r-lg);
    border-collapse: separate;
    border-spacing: 0;
    overflow: hidden;
    box-shadow: var(--shadow-sm);
    color: var(--text);
    margin-bottom: 1.5rem;
}

.table thead th {
    background: var(--surface-2);
    border-bottom: 1px solid var(--border) !important;
    border-top: 0 !important;
    color: var(--text-2);
    font-size: .74rem;
    font-weight: 600;
    letter-spacing: .05em;
    text-transform: uppercase;
    padding: .7rem .6rem;
    vertical-align: middle;
    /* Заголовок в две строки лучше, чем таблица, которую нужно листать вбок:
       без переноса самая длинная надпись задаёт минимальную ширину колонки */
    white-space: normal;
}

.table tbody td {
    border-top: 1px solid var(--border) !important;
    padding: .72rem .6rem;
    vertical-align: middle;
    font-size: .92rem;
}

.table tbody tr {
    transition: background .12s ease;
}

.table tbody tr:hover {
    background: var(--bg-subtle);
}

.theme-dark .table tbody tr:hover {
    background: rgba(255, 255, 255, .04);
}

.table-bordered,
.table-bordered td,
.table-bordered th {
    border-color: var(--border) !important;
}

.table-bordered {
    border: 1px solid var(--border) !important;
}

.table-striped tbody tr:nth-of-type(odd) {
    background: transparent;
}

/* --------------------------------------------------------------- модалки */

.modal-content {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    box-shadow: var(--shadow-lg);
    color: var(--text);
}

.theme-dark .modal-content {
    background: #141922;
}

.modal-header,
.modal-footer {
    border-color: var(--border);
    padding: 1rem 1.25rem;
}

.modal-body {
    padding: 1.25rem;
}

.dropdown-menu {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    box-shadow: var(--shadow-lg);
    padding: .35rem;
}

.theme-dark .dropdown-menu {
    background: #141922;
}

.dropdown-item {
    border-radius: var(--r-sm);
    color: var(--text);
    font-size: .9rem;
    padding: .45rem .7rem;
}

.dropdown-item:hover,
.dropdown-item:focus {
    background: var(--bg-subtle);
    color: var(--text);
}

.theme-dark .dropdown-item:hover {
    background: rgba(255, 255, 255, .07);
}

/* ------------------------------------------------------- бейджи и алерты */

.badge {
    border-radius: var(--r-pill);
    font-weight: 550;
    font-size: .76rem;
    padding: .3em .7em;
}

.alert {
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    box-shadow: var(--shadow-xs);
    font-size: .92rem;
    padding: .8rem 1rem;
}

.alert-success { background: var(--success-100); border-color: transparent; color: #05603a; }
.alert-danger  { background: var(--danger-100);  border-color: transparent; color: #912018; }
.alert-warning { background: var(--warning-100); border-color: transparent; color: #93370d; }
.alert-info    { background: var(--brand-100);   border-color: transparent; color: #24329b; }

/* ------------------------------------------------------ элементы страниц */

/* Шапка раздела: заголовок + подпись + действия справа */
.page-head {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
    margin-bottom: 1.4rem;
}

.page-head h1,
.page-head h2 {
    margin: 0;
}

.page-head .page-sub {
    color: var(--text-2);
    font-size: .92rem;
    margin-top: .15rem;
}

.page-actions {
    display: flex;
    align-items: center;
    gap: .55rem;
    flex-wrap: wrap;
}

/* Панель с полями ввода над таблицей */
.toolbar {
    padding: 1rem 1.15rem;
}

.toolbar-title {
    color: var(--text-2);
    font-size: .76rem;
    font-weight: 600;
    letter-spacing: .05em;
    text-transform: uppercase;
    margin-bottom: .7rem;
}

.toolbar-row {
    display: flex;
    align-items: flex-end;
    gap: .65rem;
    flex-wrap: wrap;
}

.toolbar-row .form-control,
.toolbar-row .field {
    flex: 1 1 190px;
    min-width: 160px;
    margin: 0;
}

.toolbar-row .field .form-control {
    width: 100%;
}

.toolbar-row .btn {
    flex: 0 0 auto;
}

/* Горизонтальная прокрутка широких таблиц — страница не должна ехать целиком */
.table-wrap {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    box-shadow: var(--shadow-sm);
    overflow-x: auto;
    margin-bottom: 1.5rem;
}

/* Сортировка по клику на заголовок (web/js/sortable-tables.js).
   Стрелка позиционируется абсолютно и почти не расширяет колонку:
   в широких таблицах каждый лишний пиксель на 15 колонок заметен. */
.table thead th.sortable {
    cursor: pointer;
    user-select: none;
    position: relative;
    padding-right: .85rem;
}

.table thead th.sortable:hover {
    color: var(--text);
}

.table thead th.sortable::after {
    content: '↕';
    position: absolute;
    right: .2rem;
    top: 50%;
    transform: translateY(-50%);
    opacity: 0;
    transition: opacity .12s ease;
}

.table thead th.sortable:hover::after {
    opacity: .45;
}

.table thead th.sorted-asc::after {
    content: '↑';
    opacity: 1 !important;
    color: var(--brand);
}

.table thead th.sorted-desc::after {
    content: '↓';
    opacity: 1 !important;
    color: var(--brand);
}

/* Карточный режим: класс ставит web/js/responsive-tables.js, когда таблица
   не помещается в обёртку по ширине. Строка превращается в карточку,
   ячейка — в пару «подпись колонки: значение» (подпись берётся из data-label).
   Помещается снова — класс снимается и возвращается обычная таблица. */
.table-wrap.table-stacked {
    overflow-x: visible;
}

.table-stacked .table {
    display: block;
    box-shadow: none;
    margin-bottom: 0;
}

.table-stacked .table thead {
    display: none;
}

.table-stacked .table tbody {
    display: block;
}

.table-stacked .table tbody tr {
    display: block;
    padding: .4rem 0;
    border-top: 1px solid var(--border);
}

.table-stacked .table tbody tr:first-child {
    border-top: 0;
}

.table-stacked .table tbody td {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    /* Ряд кнопок шире оставшегося места — переносим, а не выталкиваем за край */
    flex-wrap: wrap;
    gap: .35rem 1rem;
    border: 0 !important;
    padding: .34rem 1rem;
    text-align: right;
}

.table-stacked .table tbody td::before {
    content: attr(data-label);
    color: var(--text-2);
    font-size: .72rem;
    font-weight: 600;
    letter-spacing: .05em;
    text-transform: uppercase;
    text-align: left;
    flex: 0 0 44%;
}

/* Ячейка без подписи (нет заголовка колонки или colspan) — на всю ширину */
.table-stacked .table tbody td:not([data-label]),
.table-stacked .table tbody td[data-label=""] {
    justify-content: flex-start;
    text-align: left;
}

.table-stacked .table tbody td[data-label=""]::before,
.table-stacked .table tbody td:not([data-label])::before {
    content: none;
}

/* Кнопкам действий в карточке можно переноситься */
.table-stacked .table tbody td .btn {
    margin-bottom: .2rem;
}

/* Поля режима правки не должны распирать карточку */
.table-stacked .table tbody td .form-control,
.table-stacked .table tbody td select {
    max-width: 60%;
}

.table-wrap .table {
    border: 0;
    border-radius: 0;
    box-shadow: none;
    margin-bottom: 0;
    min-width: 100%;
}

/* Плитка с показателем */
.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
    gap: .85rem;
    margin-bottom: 1.4rem;
}

.stat {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    box-shadow: var(--shadow-sm);
    padding: .95rem 1.1rem;
    position: relative;
    overflow: hidden;
}

.stat::after {
    content: '';
    position: absolute;
    inset: 0 0 auto 0;
    height: 3px;
    background: var(--gradient);
    opacity: .85;
}

.stat-label {
    color: var(--text-2);
    font-size: .74rem;
    font-weight: 600;
    letter-spacing: .05em;
    text-transform: uppercase;
}

.stat-value {
    color: var(--text);
    font-size: 1.45rem;
    font-weight: 680;
    letter-spacing: -.02em;
    margin-top: .2rem;
    font-variant-numeric: tabular-nums;
}

.stat-note {
    color: var(--text-3);
    font-size: .8rem;
    margin-top: .1rem;
}

.stat-cash .stat-value { color: var(--success); }
.stat-qr .stat-value { color: var(--brand); }

/* Привязанные к кассе машины: компактные метки прямо в ячейке таблицы */
.chip-row {
    display: flex;
    flex-wrap: wrap;
    gap: .4rem;
}

.chip {
    align-items: center;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--r-sm);
    display: inline-flex;
    gap: .5rem;
    padding: .18rem .5rem;
}

.chip-text {
    font-size: .82rem;
    font-weight: 600;
}

.chip-remove {
    color: var(--danger);
    font-size: 1.05rem;
    line-height: 1;
    text-decoration: none;
}

.chip-remove:hover {
    color: var(--danger);
    opacity: .75;
    text-decoration: none;
}

/* Форма привязки внутри строки таблицы */
.link-form {
    align-items: center;
    display: flex;
    gap: .4rem;
    flex-wrap: nowrap;
}

.link-form .form-control {
    min-width: 150px;
    width: auto;
}

/* ------------------------------------------------ тёмные входные экраны */

.theme-dark body,
body.theme-dark {
    background: var(--bg);
    color: var(--text);
}

/* Фон с частицами и мягкими свечениями по углам */
.hero {
    position: relative;
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    background: var(--bg);
}

.hero::before,
.hero::after {
    content: '';
    position: absolute;
    width: 620px;
    height: 620px;
    border-radius: 50%;
    filter: blur(120px);
    opacity: .32;
    pointer-events: none;
}

.hero::before {
    background: #3b5bfd;
    top: -240px;
    left: -180px;
}

.hero::after {
    background: #22d3ee;
    bottom: -280px;
    right: -200px;
    opacity: .22;
}

/* Светлая тема входного экрана: чистый белый фон, а градиентные пятна
   заметнее — на белом они читаются как акцент, а не как грязь. */
:root:not(.theme-dark) .hero,
:root:not(.theme-dark) body.hero-page {
    background: #ffffff;
}

:root:not(.theme-dark) .hero::before {
    opacity: .3;
    filter: blur(110px);
}

:root:not(.theme-dark) .hero::after {
    opacity: .24;
    filter: blur(110px);
}

#particles-bg {
    position: absolute;
    inset: 0;
    z-index: 0;
}

.hero-card {
    position: relative;
    z-index: 2;
    width: 100%;
    max-width: 420px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-xl);
    box-shadow: var(--shadow-lg);
    backdrop-filter: blur(18px);
    padding: 2.2rem 2rem;
}

/* В светлой теме стекло не нужно — обычная белая карточка читается лучше */
:root:not(.theme-dark) .hero-card {
    background: #ffffff;
    backdrop-filter: none;
}

.hero-title {
    font-size: 1.85rem;
    font-weight: 700;
    letter-spacing: -.03em;
    line-height: 1.2;
    margin-bottom: .4rem;
}

.hero-title .grad {
    background: linear-gradient(100deg, #8fa6ff 0%, #c4b5fd 45%, #67e8f9 100%);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

:root:not(.theme-dark) .hero-title .grad {
    background: var(--gradient);
    -webkit-background-clip: text;
    background-clip: text;
}

.hero-sub {
    color: var(--text-2);
    font-size: .95rem;
    margin-bottom: 1.6rem;
}

.hero-badge {
    display: inline-flex;
    align-items: center;
    gap: .45rem;
    background: var(--bg-subtle);
    border: 1px solid var(--border);
    border-radius: var(--r-pill);
    color: var(--text-2);
    font-size: .78rem;
    padding: .3rem .8rem;
    margin-bottom: 1.1rem;
}

.theme-dark .hero-badge {
    background: rgba(255, 255, 255, .06);
    border-color: rgba(255, 255, 255, .1);
}

.hero-badge .dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--success);
    box-shadow: 0 0 0 3px rgba(18, 183, 106, .22);
}

.hero-content {
    position: relative;
    z-index: 2;
    width: 100%;
    display: flex;
    justify-content: center;
    padding: 1.5rem;
}

/* Переключатели темы и языка в углу входного экрана */
.hero-controls {
    position: absolute;
    top: 1.1rem;
    right: 1.3rem;
    z-index: 5;
    display: flex;
    align-items: center;
    gap: .5rem;
}

.hero-lang {
    position: relative;
}

.hero-lang-btn {
    background: var(--bg-subtle);
    border: 1px solid var(--border);
    border-radius: var(--r-pill);
    color: var(--text-2);
    cursor: pointer;
    font-family: inherit;
    font-size: .82rem;
    font-weight: 600;
    letter-spacing: .05em;
    padding: .38rem .9rem;
    transition: background .15s ease, color .15s ease;
}

.theme-dark .hero-lang-btn {
    background: rgba(255, 255, 255, .07);
    border-color: rgba(255, 255, 255, .12);
}

.hero-lang-btn:hover {
    color: var(--text);
    background: var(--brand-100);
}

.hero-lang-menu {
    position: absolute;
    top: calc(100% + .4rem);
    right: 0;
    min-width: 170px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    box-shadow: var(--shadow-lg);
    padding: .3rem;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-6px);
    transition: opacity .15s ease, transform .15s ease, visibility .15s;
}

.theme-dark .hero-lang-menu {
    background: #141922;
}

:root:not(.theme-dark) .hero-lang-menu {
    background: #ffffff;
}

.hero-lang-menu.is-open {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.hero-lang-item {
    display: block;
    border-radius: var(--r-sm);
    color: var(--text);
    font-size: .89rem;
    padding: .45rem .7rem;
    text-decoration: none;
}

.hero-lang-item:hover {
    background: var(--bg-subtle);
    color: var(--text);
}

.theme-dark .hero-lang-item:hover {
    background: rgba(255, 255, 255, .07);
}

.hero-lang-item.is-active {
    color: var(--brand);
    font-weight: 600;
}

.hero-logo {
    display: flex;
    align-items: center;
    gap: .6rem;
    margin-bottom: 1.4rem;
}

.hero-field {
    margin-bottom: 1rem;
}

.hero-label,
.hero-card label {
    color: var(--text-2);
    display: block;
    font-size: .78rem;
    font-weight: 550;
    letter-spacing: .04em;
    text-transform: uppercase;
    margin-bottom: .35rem;
}

.hero-card .form-control {
    background: var(--surface-2);
    border: 1px solid var(--border-strong);
    border-radius: var(--r-md);
    color: var(--text);
    font-size: .97rem;
    padding: .68rem .9rem;
    width: 100%;
}

.theme-dark .hero-card .form-control {
    background: rgba(255, 255, 255, .05);
    border-color: rgba(255, 255, 255, .12);
}

.hero-card .form-control:focus {
    border-color: var(--brand);
    box-shadow: 0 0 0 3px var(--brand-100);
}

.theme-dark .hero-card .form-control:focus {
    background: rgba(255, 255, 255, .08);
    box-shadow: 0 0 0 3px rgba(109, 139, 255, .18);
}

/* Иконка темы на входном экране — символ, а не шрифтовая иконка */
.hero-controls .theme-toggle {
    font-size: 1rem;
    line-height: 1;
}

/* Chrome подставляет свой светлый фон в автозаполненные поля и игнорирует
   background — перебиваем через внутреннюю тень, иначе в тёмной теме
   поля логина остаются белыми. */
input:-webkit-autofill,
input:-webkit-autofill:hover,
input:-webkit-autofill:focus {
    -webkit-text-fill-color: var(--text);
    -webkit-box-shadow: 0 0 0 1000px var(--surface-2) inset;
    caret-color: var(--text);
    transition: background-color 100000s ease-in-out 0s;
}

.theme-dark input:-webkit-autofill,
.theme-dark input:-webkit-autofill:hover,
.theme-dark input:-webkit-autofill:focus {
    -webkit-box-shadow: 0 0 0 1000px #1b212c inset;
}

.hero-error {
    color: #ff8a80;
    font-size: .82rem;
    margin-top: .3rem;
}

.hero-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin: .2rem 0 1.3rem;
}

.hero-row .form-group {
    margin-bottom: 0;
}

/* Сам чекбокс — это <label class="hero-check">, поэтому специфичность
   должна перебивать общий .hero-card label с uppercase */
label.hero-check {
    display: flex;
    align-items: center;
    gap: .5rem;
    cursor: pointer;
    margin-bottom: 0;
    text-transform: none;
}

label.hero-check span {
    color: var(--text-2);
    font-size: .87rem;
    font-weight: 450;
    letter-spacing: 0;
    text-transform: none;
}

.hero-check .custom-control-label,
.hero-check > label {
    color: var(--text-2);
    cursor: pointer;
    font-size: .87rem;
    font-weight: 450;
    letter-spacing: 0;
    text-transform: none;
    margin-bottom: 0;
}

.hero-check input[type="checkbox"] {
    accent-color: var(--brand);
    margin-right: .15rem;
    width: 15px;
    height: 15px;
}

.hero-submit {
    border-radius: var(--r-md);
    font-size: 1rem;
    font-weight: 600;
    padding: .72rem 1rem;
}

.hero-submit .arrow {
    display: inline-block;
    transition: transform .18s ease;
}

.hero-submit:hover .arrow {
    transform: translateX(4px);
}

.hero-foot {
    color: var(--text-3);
    font-size: .78rem;
    margin-top: 1.5rem;
    text-align: center;
}

/* ------------------------------------------------------------ мобильные */

@media (max-width: 767px) {
    body { font-size: 14px; }

    h1, .h1 { font-size: 1.45rem; }

    main { padding-top: 1.1rem; }

    .table thead th { font-size: .68rem; padding: .55rem .5rem; }
    .table tbody td { padding: .58rem .5rem; font-size: .87rem; }

    .stat-grid { grid-template-columns: repeat(2, 1fr); gap: .6rem; }
    .stat-value { font-size: 1.2rem; }

    .hero-card { padding: 1.6rem 1.25rem; }
}

/* ------------------------------------------------- селект с поиском (ss) */
/* web/js/searchable-select.js: <select data-searchable> прячется, вместо
   него кнопка с текущим значением и панель «поиск + список» */

.ss-wrap { position: relative; }

.ss-wrap > select { display: none; }

.ss-toggle {
    display: block;
    width: 100%;
    min-width: 180px;
    padding: .45rem 2rem .45rem .75rem;
    text-align: left;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    background: var(--surface);
    color: var(--text);
    border: 1px solid var(--border-strong);
    border-radius: var(--r-sm);
    font-size: .9rem;
    cursor: pointer;
    position: relative;
    transition: border-color .15s ease, box-shadow .15s ease;
}

.ss-toggle::after {
    content: '';
    position: absolute;
    right: .8rem;
    top: 50%;
    width: 7px;
    height: 7px;
    border-right: 1.6px solid var(--text-3);
    border-bottom: 1.6px solid var(--text-3);
    transform: translateY(-70%) rotate(45deg);
    transition: transform .15s ease;
}

.ss-toggle.is-open::after { transform: translateY(-30%) rotate(225deg); }

.ss-toggle:focus,
.ss-toggle.is-open {
    outline: none;
    border-color: var(--brand);
    box-shadow: 0 0 0 3px var(--brand-100);
}

.ss-menu {
    position: absolute;
    z-index: 1050;
    top: calc(100% + 6px);
    left: 0;
    min-width: 100%;
    max-width: 340px;
    background: var(--bg);
    border: 1px solid var(--border-strong);
    border-radius: var(--r-md);
    box-shadow: var(--shadow-lg);
    padding: .5rem;
}

.ss-search {
    width: 100%;
    padding: .4rem .65rem;
    margin-bottom: .45rem;
    background: var(--surface);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: var(--r-sm);
    font-size: .88rem;
}

.ss-search:focus {
    outline: none;
    border-color: var(--brand);
    box-shadow: 0 0 0 3px var(--brand-100);
}

.ss-list {
    max-height: 260px;
    overflow-y: auto;
}

.ss-option {
    display: block;
    width: 100%;
    padding: .42rem .65rem;
    text-align: left;
    background: none;
    border: none;
    border-radius: var(--r-sm);
    color: var(--text);
    font-size: .88rem;
    cursor: pointer;
}

.ss-option:hover,
.ss-option.is-highlighted {
    background: var(--brand-100);
}

.ss-option.is-current {
    color: var(--brand);
    font-weight: 600;
}

.ss-empty {
    padding: .5rem .65rem;
    color: var(--text-3);
    font-size: .85rem;
}

/* ------------------------------------------------- кнопки действий строки */
/* Единый ряд компактных иконок-кнопок в последней колонке таблиц */

.row-actions {
    display: flex;
    gap: .35rem;
    flex-wrap: nowrap;
    align-items: center;
}

.row-actions .btn {
    width: 34px;
    height: 31px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

/* Пока открыт селект с поиском: предок с backdrop-filter поднимается над
   соседними блоками, иначе выпадающая панель рисуется под ними */
.ss-elevated {
    position: relative;
    z-index: 1050;
}
