/* ==========================================================================
   Ordium CRM — базовые стили
   Принцип: интерфейс спокойный и нейтральный, чтобы главным сигналом
   на экране был цвет стадии заказа, который задаёт сама компания.
   ========================================================================== */

@font-face {
    font-family: "Golos Text";
    src: url("../fonts/GolosText-VariableFont_wght.bf5a52ead2c4.ttf") format("truetype");
    font-weight: 400 900;
    font-display: swap;
}

/* --- Токены ------------------------------------------------------------ */

:root {
    color-scheme: light;

    --bg: #FAF8F5;
    --surface: #FFFFFF;
    --surface-hover: #F7F3EE;
    --sidebar-bg: #F3EEE8;
    --sidebar-muted: #6B645D;
    --select-arrow: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12'%3E%3Cpath d='M3 4.5 6 7.5l3-3' fill='none' stroke='%236B645D' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
    --ink: #1F1B17;
    --muted: #6B645D;
    --line: #ECE5DD;
    --line-strong: #D9CEC2;
    --muted-bg: #F2EDE7;
    --field: #F0EAE3;
    --tint: rgba(60, 40, 20, 0.055);
    --ring: rgba(60, 40, 20, 0.12);
    --shadow-sm: 0 1px 2px rgba(60, 40, 20, 0.06);
    --shadow-card: 0 1px 3px rgba(60, 40, 20, 0.05), 0 4px 14px rgba(60, 40, 20, 0.035);
    --overlay: rgba(29, 38, 36, 0.35);

    --accent: #2E5E52;
    --accent-hi: #3A7262;
    --accent-hover: #244A41;
    --accent-soft: #E3EFEA;
    --accent-ink: #245046;
    --on-accent: #FFFFFF;
    --danger: #B3261E;
    --danger-hover: #8C2925;
    --danger-soft: #F9E7E5;
    --danger-line: #F0C4C0;
    --on-danger: #FFFFFF;
    --success: #1D7A3A;
    --warn-soft: #FFF4E0;
    --warn-line: #F0D58A;
    --warn-ink: #8A5300;
    --focus: #86BDAE;

    --stage-default: #C9D1CE;

    /* Имена, которыми пользуются стили отдельных страниц */
    --border: var(--line);
    --border-strong: var(--line-strong);
    --hover: var(--surface-hover);
    --surface-2: var(--muted-bg);

    --font: "Golos Text", -apple-system, BlinkMacSystemFont, system-ui, "Segoe UI", Roboto, sans-serif;
    --text: 15px;
    --small: 13px;

    --r-control: 8px;
    --r-panel: 12px;
    --sidebar: 240px;
    --sidebar-collapsed: 68px;
    --topbar: 60px;
}

/* Тёмная тема: выбрана вручную или так настроена система (если сотрудник не выбрал светлую).
   Значения одинаковые в обоих блоках — CSS не умеет объединить селектор с @media. */
:root[data-theme="dark"] {
    color-scheme: dark;

    --bg: #161412;
    --surface: #211E1B;
    --surface-hover: #2A2622;
    --sidebar-bg: #1C1A17;
    --sidebar-muted: #A69E95;
    --select-arrow: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12'%3E%3Cpath d='M3 4.5 6 7.5l3-3' fill='none' stroke='%23A69E95' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
    --ink: #EEE9E3;
    --muted: #A69E95;
    --line: #312C27;
    --line-strong: #4A443E;
    --muted-bg: #2A2622;
    --field: #2A2622;
    --tint: rgba(255, 255, 255, 0.06);
    --ring: rgba(255, 255, 255, 0.09);
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
    --shadow-card: 0 1px 3px rgba(0, 0, 0, 0.3);
    --overlay: rgba(0, 0, 0, 0.55);

    --accent: #6DB9A2;
    --accent-hi: #84C9B4;
    --accent-hover: #84C9B4;
    --accent-soft: #1E3832;
    --accent-ink: #9ED7C4;
    --on-accent: #0D1F1A;
    --danger: #F08A80;
    --danger-hover: #F5A49C;
    --danger-soft: #3A201D;
    --danger-line: #6B322C;
    --on-danger: #2A0E0B;
    --success: #6FCF8F;
    --warn-soft: #3A2E14;
    --warn-line: #6B5523;
    --warn-ink: #F0C674;
    --focus: #4F9C86;

    --stage-default: #5A625F;
}

@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        color-scheme: dark;

        --bg: #161412;
        --surface: #211E1B;
        --surface-hover: #2A2622;
        --sidebar-bg: #1C1A17;
        --sidebar-muted: #A69E95;
        --select-arrow: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12'%3E%3Cpath d='M3 4.5 6 7.5l3-3' fill='none' stroke='%23A69E95' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
        --ink: #EEE9E3;
        --muted: #A69E95;
        --line: #312C27;
        --line-strong: #4A443E;
        --muted-bg: #2A2622;
        --field: #2A2622;
        --tint: rgba(255, 255, 255, 0.06);
        --ring: rgba(255, 255, 255, 0.09);
        --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
        --shadow-card: 0 1px 3px rgba(0, 0, 0, 0.3);
        --overlay: rgba(0, 0, 0, 0.55);

        --accent: #6DB9A2;
        --accent-hi: #84C9B4;
        --accent-hover: #84C9B4;
        --accent-soft: #1E3832;
        --accent-ink: #9ED7C4;
        --on-accent: #0D1F1A;
        --danger: #F08A80;
        --danger-hover: #F5A49C;
        --danger-soft: #3A201D;
        --danger-line: #6B322C;
        --on-danger: #2A0E0B;
        --success: #6FCF8F;
        --warn-soft: #3A2E14;
        --warn-line: #6B5523;
        --warn-ink: #F0C674;
        --focus: #4F9C86;

        --stage-default: #5A625F;
    }
}

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

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

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

body {
    margin: 0;
    font-family: var(--font);
    font-size: var(--text);
    line-height: 1.5;
    color: var(--ink);
    background: var(--bg);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

h1 {
    margin: 0;
    font-size: 24px;
    line-height: 1.25;
    font-weight: 650;
    letter-spacing: -0.01em;
}

h2 {
    margin: 0 0 12px;
    font-size: 17px;
    line-height: 1.3;
    font-weight: 600;
}

p {
    margin: 0 0 12px;
}

a {
    color: var(--accent);
    text-decoration-thickness: 1px;
    text-underline-offset: 2px;
}

a:hover {
    color: var(--accent-hover);
}

:focus-visible {
    outline: 2px solid var(--focus);
    outline-offset: 2px;
}

.muted {
    color: var(--muted);
}

.nowrap {
    white-space: nowrap;
}

/* --- Каркас: боковое меню + верхняя панель + содержимое ---------------- */

.app {
    display: grid;
    grid-template-columns: var(--sidebar) minmax(0, 1fr);
    min-height: 100vh;
}

.sidebar {
    position: sticky;
    top: 0;
    display: flex;
    flex-direction: column;
    gap: 10px;
    height: 100vh;
    overflow-y: auto;
    padding: 12px 10px 12px;
    background: var(--sidebar-bg);
    border-right: 1px solid var(--line);
}

.sidebar svg,
.topbar svg {
    flex: none;
    width: 18px;
    height: 18px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.8;
    stroke-linecap: round;
    stroke-linejoin: round;
}

/* Кнопка-значок без рамки: свернуть меню, тема, дела, выход */
.icon-btn {
    position: relative;
    display: inline-flex;
    flex: none;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    min-height: 0;
    padding: 0;
    color: var(--muted);
    text-decoration: none;
    background: transparent;
    border: 0;
    border-radius: var(--r-control);
    box-shadow: none;
    cursor: pointer;
}

.icon-btn:hover {
    color: var(--ink);
    background: var(--tint);
}

.sidebar-head {
    display: flex;
    align-items: center;
    gap: 8px;
    min-height: 40px;
    padding: 0 0 0 6px;
}

.brand {
    display: flex;
    flex: 1;
    align-items: center;
    gap: 10px;
    min-width: 0;
    font-size: 17px;
    font-weight: 700;
    letter-spacing: -0.01em;
    color: var(--ink);
    text-decoration: none;
}

.brand:hover {
    color: var(--ink);
}

.brand-mark {
    display: flex;
    flex: none;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    font-size: 15px;
    font-weight: 700;
    color: var(--on-accent);
    background: linear-gradient(180deg, var(--accent-hi), var(--accent));
    border-radius: 8px;
    box-shadow: inset 0 0 0 0.5px rgba(0, 0, 0, 0.12), 0 1px 2px rgba(0, 0, 0, 0.12);
}

.tenant-card {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 7px 9px;
    background: var(--surface);
    border-radius: 9px;
    box-shadow: 0 0 0 0.5px var(--ring), var(--shadow-sm);
}

.tenant-mark {
    display: flex;
    flex: none;
    align-items: center;
    justify-content: center;
    width: 26px;
    height: 26px;
    font-size: 12px;
    font-weight: 600;
    background: var(--muted-bg);
    border-radius: 7px;
}

.tenant-text,
.user-text {
    display: flex;
    flex: 1;
    flex-direction: column;
    min-width: 0;
    line-height: 1.25;
}

.tenant-name,
.tenant-role,
.user-name,
.user-tenant,
.nav-label {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.tenant-name,
.user-name {
    font-size: 13px;
    font-weight: 600;
}

.tenant-role,
.user-tenant {
    font-size: 12px;
    color: var(--sidebar-muted);
}

.nav {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.nav-group {
    display: flex;
    flex-direction: column;
    gap: 1px;
}

.nav-title {
    padding: 0 10px 4px;
    font-size: 12px;
    font-weight: 600;
    color: var(--sidebar-muted);
}

/* Разделы меню сворачиваются: заголовок — кнопка со стрелкой */
button.nav-title {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    min-height: 0;
    margin: 0;
    padding: 2px 10px 4px;
    font: inherit;
    font-size: 12px;
    font-weight: 600;
    text-align: left;
    color: var(--sidebar-muted);
    background: transparent;
    border: 0;
    border-radius: 6px;
    cursor: pointer;
}

button.nav-title:hover {
    color: var(--ink);
    background: transparent;
    border-color: transparent;
}

.nav-fold-icon {
    width: 14px;
    height: 14px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
    opacity: 0;
    transition: transform .15s, opacity .15s;
}

.nav-group:hover .nav-fold-icon,
button.nav-title:focus-visible .nav-fold-icon,
.nav-group.is-closed .nav-fold-icon {
    opacity: 1;
}

.nav-group.is-closed .nav-fold-icon {
    transform: rotate(-90deg);
}

/* Свёрнутый раздел прячет пункты, кроме открытой сейчас страницы */
.nav-group.is-closed > a:not(.is-active) {
    display: none;
}

.nav a {
    position: relative;
    display: flex;
    align-items: center;
    gap: 10px;
    height: 34px;
    padding: 0 10px;
    font-size: 14px;
    font-weight: 450;
    color: var(--ink);
    text-decoration: none;
    border-radius: 8px;
}

.nav a svg {
    color: var(--accent);
}

.nav a:hover {
    color: var(--ink);
    background: var(--tint);
}

.nav a.is-active {
    font-weight: 600;
    background: var(--surface);
    box-shadow: 0 0 0 0.5px var(--ring), var(--shadow-sm);
}

.nav-label {
    flex: 1;
    min-width: 0;
}

.sidebar-footer {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: auto;
}

.sidebar-footer .nav a svg {
    color: var(--sidebar-muted);
}

.user {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 0 0 6px;
    border-top: 1px solid var(--line);
}

.user-avatar {
    display: flex;
    flex: none;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    font-size: 13px;
    font-weight: 600;
    color: #FFFFFF;
    background: linear-gradient(180deg, #D8917A, #B96A4E);
    border-radius: 50%;
}

.user-logout {
    margin: 0;
}

/* Свёрнутое меню — полоса иконок (только на широком экране) */
@media (min-width: 901px) {
    .app.is-collapsed {
        grid-template-columns: var(--sidebar-collapsed) minmax(0, 1fr);
    }

    .app.is-collapsed .sidebar {
        align-items: center;
        overflow: visible;
    }

    .app.is-collapsed .brand-name,
    .app.is-collapsed .tenant-card,
    .app.is-collapsed .nav-title,
    .app.is-collapsed .nav-label,
    .app.is-collapsed .user-avatar,
    .app.is-collapsed .user-text {
        display: none;
    }

    .app.is-collapsed .sidebar-head {
        flex-direction: column;
        padding: 0;
    }

    .app.is-collapsed .brand {
        flex: none;
    }

    /* Полоса иконок: разделы не сворачиваются — видны все иконки */
    .app.is-collapsed .nav-group.is-closed > a {
        display: flex;
    }

    .app.is-collapsed .nav a {
        justify-content: center;
        width: 44px;
        padding: 0;
    }

    .app.is-collapsed .nav-badge {
        position: absolute;
        top: 5px;
        right: 7px;
        width: 8px;
        min-width: 0;
        height: 8px;
        padding: 0;
        font-size: 0;
        background: var(--accent);
        border: 2px solid var(--sidebar-bg);
    }

    .app.is-collapsed .user {
        justify-content: center;
        padding: 10px 0 0;
    }

    /* Подпись раздела при наведении */
    .app.is-collapsed .nav a:hover::after {
        content: attr(data-label);
        position: absolute;
        top: 50%;
        left: calc(100% + 10px);
        z-index: 70;
        padding: 4px 9px;
        font-size: 12px;
        font-weight: 500;
        white-space: nowrap;
        color: var(--bg);
        background: var(--ink);
        border-radius: 6px;
        transform: translateY(-50%);
        pointer-events: none;
    }
}

.workspace {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.topbar {
    display: flex;
    align-items: center;
    gap: 6px;
    min-height: var(--topbar);
    padding: 10px 32px;
    border-bottom: 1px solid var(--line);
}

.topbar-menu {
    display: none;
}

.topbar-search {
    display: flex;
    flex: 1 1 280px;
    align-items: center;
    gap: 8px;
    max-width: 460px;
    height: 36px;
    margin: 0;
    padding: 0 8px 0 11px;
    color: var(--muted);
    background: var(--field);
    border-radius: 9px;
}

.topbar-search svg {
    width: 15px;
    height: 15px;
    stroke-width: 2;
}

.topbar-search input {
    flex: 1;
    min-width: 0;
    min-height: 0;
    height: 100%;
    padding: 0;
    color: var(--ink);
    background: transparent;
    border: 0;
    border-radius: 0;
}

.topbar-search input:focus {
    outline: none;
    box-shadow: none;
}

.topbar-search input::placeholder {
    color: var(--muted);
}

.topbar-search:focus-within {
    box-shadow: 0 0 0 1px var(--accent), 0 0 0 4px var(--accent-soft);
}

.topbar-search kbd {
    flex: none;
    padding: 1px 6px;
    font: inherit;
    font-size: 11px;
    color: var(--muted);
    background: var(--surface);
    border-radius: 5px;
    box-shadow: 0 0 0 0.5px var(--ring);
}

.topbar-spacer {
    flex: 1;
}

.topbar-dot {
    position: absolute;
    top: 7px;
    right: 8px;
    width: 8px;
    height: 8px;
    background: var(--danger);
    border: 2px solid var(--bg);
    border-radius: 50%;
}

.topbar-new {
    margin-left: 4px;
}

.topbar-new svg {
    width: 16px;
    height: 16px;
    stroke-width: 2.2;
}

.theme-sun {
    display: none;
}

:root[data-theme="dark"] .theme-moon {
    display: none;
}

:root[data-theme="dark"] .theme-sun {
    display: block;
}

@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) .theme-moon {
        display: none;
    }

    :root:not([data-theme="light"]) .theme-sun {
        display: block;
    }
}

.main {
    min-width: 0;
    padding: 24px 32px 48px;
}

.page-header {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 20px;
}

.page-sub {
    margin: 4px 0 0;
    font-size: var(--small);
    color: var(--muted);
}

.back {
    display: inline-block;
    margin-bottom: 8px;
    font-size: var(--small);
}

.toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 12px;
    margin-bottom: 14px;
}

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

button, .btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    min-height: 36px;
    padding: 8px 14px;
    font: inherit;
    font-size: 14px;
    font-weight: 550;
    color: var(--ink);
    text-decoration: none;
    background: var(--surface);
    border: 1px solid var(--line-strong);
    border-radius: var(--r-control);
    cursor: pointer;
}

button:hover, .btn:hover {
    color: var(--ink);
    border-color: var(--muted);
}

.btn {
    box-shadow: var(--shadow-sm);
}

.btn-primary {
    color: var(--on-accent);
    background: linear-gradient(180deg, var(--accent-hi), var(--accent));
    border-color: var(--accent);
    box-shadow: inset 0 0.5px 0 rgba(255, 255, 255, 0.2), 0 1px 2px rgba(0, 0, 0, 0.15);
}

.btn-primary:hover {
    color: var(--on-accent);
    background: var(--accent-hover);
    border-color: var(--accent-hover);
}

.btn-quiet {
    justify-content: flex-start;
    padding-left: 0;
    padding-right: 0;
    color: var(--muted);
    background: transparent;
    border-color: transparent;
    box-shadow: none;
}

.btn-quiet:hover {
    color: var(--ink);
    border-color: transparent;
}

/* --- Поля ввода -------------------------------------------------------- */

input, select, textarea {
    max-width: 100%;
    min-height: 36px;
    padding: 7px 10px;
    font: inherit;
    font-size: 14px;
    color: var(--ink);
    background-color: var(--surface);
    border: 1px solid var(--line-strong);
    border-radius: var(--r-control);
}

/* Свой треугольник у выпадающих списков. Системный в Windows при наведении и фокусе
   рисует вторую стрелку и рамку вокруг всего поля, а в тёмной теме — светлую кнопку. */
select:not([multiple]):not([size]) {
    appearance: none;
    -webkit-appearance: none;
    padding-right: 30px;
    background-image: var(--select-arrow);
    background-position: right 9px center;
    background-size: 12px 12px;
    background-repeat: no-repeat;
    cursor: pointer;
}

select:not([multiple]):not([size]):hover {
    border-color: var(--muted);
}

select::-ms-expand {
    display: none;
}

input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-soft);
}

input[type="checkbox"] {
    width: 16px;
    height: 16px;
    min-height: 0;
    accent-color: var(--accent);
}

/* Формы, выведенные через {{ form.as_p }}: подпись над полем */
.form-stack p {
    display: flex;
    flex-direction: column;
    gap: 6px;
    max-width: 440px;
    margin: 0 0 16px;
}

.form-stack label {
    font-size: var(--small);
    font-weight: 600;
    color: var(--muted);
}

.form-stack .helptext {
    font-size: var(--small);
    color: var(--muted);
}

.field-inline {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: var(--small);
    color: var(--muted);
}

.errorlist {
    margin: 4px 0 0;
    padding: 0;
    list-style: none;
    font-size: var(--small);
    color: var(--danger);
}

.hint {
    font-size: var(--small);
    color: var(--muted);
}

/* --- Панели ------------------------------------------------------------ */

.panel, .card {
    margin-bottom: 20px;
    padding: 20px 22px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--r-panel);
    box-shadow: var(--shadow-card);
}

.grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 20px;
    margin-bottom: 20px;
}

.grid > .panel, .grid > .card {
    margin-bottom: 0;
}

dl {
    display: grid;
    grid-template-columns: minmax(120px, 170px) 1fr;
    gap: 8px 16px;
    margin: 0;
}

dt {
    padding-top: 1px;
    font-size: var(--small);
    color: var(--muted);
}

dd {
    margin: 0;
}

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

.table-wrap {
    overflow-x: auto;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--r-panel);
    box-shadow: var(--shadow-card);
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

th {
    padding: 10px 14px;
    font-size: var(--small);
    font-weight: 600;
    color: var(--muted);
    text-align: left;
    white-space: nowrap;
    border-bottom: 1px solid var(--line);
}

td {
    padding: 11px 14px;
    vertical-align: top;
    border-bottom: 1px solid var(--line);
}

tbody tr:last-child td {
    border-bottom: 0;
}

tbody tr:hover {
    background: var(--surface-hover);
}

tfoot th, tfoot td {
    font-size: 14px;
    color: var(--ink);
    border-top: 1px solid var(--line-strong);
    border-bottom: 0;
}

.num {
    text-align: right;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.id {
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.cell-main {
    display: block;
}

.cell-sub {
    display: block;
    font-size: var(--small);
    color: var(--muted);
    font-variant-numeric: tabular-nums;
}

/* Полоса цвета стадии у левого края строки */
.stage-edge {
    box-shadow: inset 3px 0 0 var(--stage, transparent);
}

.empty {
    padding: 36px 14px;
    text-align: center;
    color: var(--muted);
}

.empty p {
    margin: 0 0 12px;
}

/* Перетаскивание строк таблицы */
.col-handle {
    width: 36px;
    color: var(--muted);
    text-align: center;
    cursor: grab;
    user-select: none;
}

tr[draggable="true"].is-dragging {
    opacity: 0.4;
}

/* --- Стадия заказа ----------------------------------------------------- */

/* Цвет задаётся через переменную: style="--stage: #2E86DE".
   Фон — светлый оттенок этого цвета, поэтому текст читается
   при любом цвете, который выберет компания. */
.stage-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 2px 10px 2px 8px;
    font-size: var(--small);
    font-weight: 550;
    color: var(--ink);
    white-space: nowrap;
    background: color-mix(in srgb, var(--stage, var(--stage-default)) 16%, var(--surface));
    border-radius: 999px;
}

.stage-badge::before {
    content: "";
    width: 8px;
    height: 8px;
    background: var(--stage, var(--stage-default));
    border-radius: 50%;
}

/* --- Сообщения --------------------------------------------------------- */

.message {
    margin-bottom: 16px;
    padding: 10px 14px;
    font-size: 14px;
    color: var(--accent-hover);
    background: var(--accent-soft);
    border-radius: var(--r-control);
}

.message-error {
    color: var(--danger);
    background: var(--danger-soft);
}

/* --- Страница входа ---------------------------------------------------- */

body.is-auth .main {
    display: grid;
    place-items: center;
    min-height: 100vh;
    padding: 24px;
}

.auth-box {
    width: 100%;
    max-width: 360px;
    padding: 28px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--r-panel);
}

.auth-box .brand {
    padding: 0;
    margin-bottom: 20px;
}

.auth-box h1 {
    margin-bottom: 20px;
}

.auth-box .btn {
    width: 100%;
}

/* --- Узкие экраны ------------------------------------------------------ */

@media (max-width: 900px) {
    .app {
        grid-template-columns: minmax(0, 1fr);
    }

    /* Меню выезжает слева поверх страницы */
    .sidebar {
        position: fixed;
        top: 0;
        bottom: 0;
        left: 0;
        z-index: 65;
        width: min(280px, 86vw);
        height: auto;
        transform: translateX(-105%);
        transition: transform 0.2s ease;
    }

    .app.is-nav-open .sidebar {
        transform: none;
        box-shadow: 0 0 40px rgba(0, 0, 0, 0.25);
    }

    .sidebar-backdrop {
        position: fixed;
        inset: 0;
        z-index: 64;
        background: var(--overlay);
    }

    .sidebar-toggle {
        display: none;
    }

    .topbar {
        gap: 4px;
        padding: 8px 12px;
    }

    .topbar-menu {
        display: inline-flex;
    }

    .topbar-search kbd {
        display: none;
    }

    .topbar-new {
        flex: none;
        width: 36px;
        height: 36px;
        padding: 0;
    }

    .topbar-new span {
        display: none;
    }

    /* Поиск сжимается сам, иначе на ширине 390 px кнопка «+» вылезала за край на 3 px */
    .topbar-search {
        min-width: 0;
    }

    .main {
        padding: 20px 16px 40px;
    }

    .page-header {
        flex-direction: column;
        align-items: flex-start;
    }
}

@media (prefers-reduced-motion: reduce) {
    .sidebar {
        transition: none;
    }
}

/* ==========================================================================
   Карточка и форма заказа
   ========================================================================== */

/* --- Дорожка стадий: вся воронка, текущая стадия выделена -------------- */

.stage-track {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.stage-step {
    display: inline-flex;
    align-items: center;
    min-height: 34px;
    padding: 6px 14px;
    font-size: var(--small);
    font-weight: 550;
    color: var(--muted);
    background: var(--surface);
    border: 1px solid var(--line-strong);
    border-radius: 999px;
}

button.stage-step:hover {
    color: var(--ink);
    border-color: var(--stage, var(--stage-default));
}

.stage-step.is-done {
    color: var(--ink);
    background: color-mix(in srgb, var(--stage, var(--stage-default)) 10%, var(--surface));
    border-color: color-mix(in srgb, var(--stage, var(--stage-default)) 30%, var(--surface));
}

.stage-step.is-current {
    padding: 5px 13px;
    font-weight: 650;
    color: var(--ink);
    background: color-mix(in srgb, var(--stage, var(--stage-default)) 24%, var(--surface));
    border: 2px solid var(--stage, var(--stage-default));
}

.stage-step:disabled {
    cursor: default;
    opacity: 1;
}

/* --- Раскладка карточки ------------------------------------------------ */

.detail-grid {
    display: grid;
    grid-template-columns: minmax(0, 2fr) minmax(280px, 1fr);
    gap: 20px;
    align-items: start;
    margin-bottom: 20px;
}

.detail-grid > .panel {
    margin-bottom: 0;
}

/* Панель, внутри которой таблица идёт от края до края */
.panel.is-flush {
    padding: 0;
    overflow-x: auto;
}

.panel-title {
    margin: 0;
    padding: 16px 20px 6px;
}

.panel.is-flush th:first-child, .panel.is-flush td:first-child {
    padding-left: 20px;
}

.panel.is-flush th:last-child, .panel.is-flush td:last-child {
    padding-right: 20px;
}

.panel-foot {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 12px;
    padding: 14px 20px;
    border-top: 1px solid var(--line);
}

.panel-errors {
    padding: 0 20px;
}

.client-name {
    margin: 0;
    font-size: 17px;
    font-weight: 600;
}

.client-phone {
    margin: 2px 0 16px;
    font-variant-numeric: tabular-nums;
}

.transition {
    margin: 0 6px;
    color: var(--muted);
}

/* --- Поля формы -------------------------------------------------------- */

.fields {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 16px 20px;
}

.field {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.field label {
    font-size: var(--small);
    font-weight: 600;
    color: var(--muted);
}

.field input, .field select, .field textarea {
    width: 100%;
}

.field.has-error input, .field.has-error select {
    border-color: var(--danger);
}

.field-check {
    justify-content: flex-end;
}

.field-check label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    font-weight: 500;
    color: var(--ink);
    cursor: pointer;
}

/* --- Таблица позиций в форме ------------------------------------------ */

.items-table td {
    vertical-align: middle;
}

.items-table select,
.items-table input:not([type="checkbox"]) {
    width: 100%;
}

.items-table .col-qty {
    width: 110px;
}

.items-table .col-price {
    width: 150px;
}

.items-table .col-kind {
    width: 170px;
}

.items-table .col-color {
    width: 90px;
}

.items-table .col-del {
    width: 110px;
    white-space: nowrap;
}

.items-table input[type="color"] {
    width: 100%;
    height: 34px;
    padding: 2px;
    cursor: pointer;
}

.del-toggle {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: var(--small);
    color: var(--muted);
    cursor: pointer;
}

.form-actions {
    display: flex;
    align-items: center;
    gap: 16px;
}

@media (max-width: 900px) {
    .detail-grid {
        grid-template-columns: 1fr;
    }
}

/* ==========================================================================
   Канбан и выдвижная панель
   ========================================================================== */

.view-switch {
    display: inline-flex;
    overflow: hidden;
    border: 1px solid var(--line-strong);
    border-radius: var(--r-control);
}

.view-switch a {
    padding: 6px 12px;
    font-size: var(--small);
    color: var(--muted);
    text-decoration: none;
    background: var(--surface);
}

.view-switch a + a {
    border-left: 1px solid var(--line-strong);
}

.view-switch a:hover {
    color: var(--ink);
}

.view-switch a.is-active {
    font-weight: 600;
    color: var(--accent);
    background: var(--accent-soft);
}

/* --- Доска ------------------------------------------------------------- */

.kanban {
    display: flex;
    align-items: stretch;
    gap: 12px;
    height: calc(100dvh - 210px - var(--topbar));
    min-height: 420px;
    overflow-x: auto;
    padding-bottom: 12px;
}

/* Колонка — спокойный фон, цвет стадии только в полоске сверху и точке у названия */
.kanban-column {
    position: relative;
    display: flex;
    flex: 0 0 292px;
    flex-direction: column;
    min-width: 0;
    background: var(--tint);
    border-radius: var(--r-panel);
}

.kanban-column::before {
    content: "";
    position: absolute;
    top: 0;
    right: 12px;
    left: 12px;
    height: 3px;
    background: var(--stage, var(--stage-default));
    border-radius: 0 0 3px 3px;
}

.kanban-head {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 14px 14px 10px;
}

.kanban-title {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
    font-size: 14px;
    font-weight: 600;
}

.kanban-dot {
    flex: none;
    width: 9px;
    height: 9px;
    background: var(--stage, var(--stage-default));
    border-radius: 50%;
}

.kanban-name {
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
}

.kanban-count {
    flex: none;
    min-width: 22px;
    padding: 1px 7px;
    margin-left: auto;
    font-size: 12px;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    text-align: center;
    color: var(--muted);
    background: var(--surface);
    border-radius: 999px;
    box-shadow: 0 0 0 0.5px var(--ring);
}

.kanban-meta {
    padding-left: 17px;
    font-size: var(--small);
    font-variant-numeric: tabular-nums;
    color: var(--muted);
}

.kanban-title:has(.kanban-check) + .kanban-meta {
    padding-left: 43px;
}

.kanban-cards {
    display: flex;
    flex: 1;
    flex-direction: column;
    gap: 8px;
    min-height: 64px;
    padding: 2px 10px 12px;
    overflow-y: auto;
    scrollbar-width: thin;
    border-radius: 0 0 var(--r-panel) var(--r-panel);
}

.kanban-cards.is-over {
    background: color-mix(in srgb, var(--stage, var(--accent)) 10%, transparent);
    outline: 2px dashed var(--stage, var(--stage-default));
    outline-offset: -6px;
}

.kanban-empty {
    margin: 0;
    padding: 18px 0;
    font-size: var(--small);
    color: var(--muted);
    text-align: center;
    border: 1px dashed var(--line-strong);
    border-radius: var(--r-control);
}

.kanban-empty[hidden] {
    display: none;
}

.kanban-loader {
    display: flex;
    justify-content: center;
    padding: 4px 0 2px;
}

.kanban-load {
    min-height: 32px;
    padding: 0 14px;
    font: inherit;
    font-size: var(--small);
    color: var(--muted);
    background: transparent;
    border: 0;
    border-radius: var(--r-control);
    cursor: pointer;
}

.kanban-load:hover {
    color: var(--ink);
    background: var(--tint);
}

.kanban-load:disabled {
    cursor: default;
}

@media (max-width: 900px) {
    .kanban-column {
        flex-basis: min(292px, 84vw);
    }
}

/* --- Выдвижная панель ------------------------------------------------- */

dialog.drawer {
    position: fixed;
    inset: 0 0 0 auto;
    display: flex;
    flex-direction: column;
    width: min(1600px, calc(100vw - 56px));
    max-width: none;
    height: 100vh;
    max-height: none;
    margin: 0;
    padding: 0;
    overflow: visible;
    background: var(--bg);
    border: 0;
    box-shadow: -12px 0 40px rgba(29, 38, 36, 0.18);
    animation: drawer-in 180ms ease-out;
}

.drawer-close {
    position: absolute;
    top: 0;
    left: -44px;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    padding: 0;
    font-size: 26px;
    line-height: 1;
    color: var(--on-accent);
    background: var(--accent);
    border: 0;
    border-radius: var(--r-control) 0 0 var(--r-control);
    cursor: pointer;
}

.drawer-close:hover {
    background: var(--accent-hover);
}

.drawer-close:focus-visible {
    outline: 2px solid var(--focus);
    outline-offset: 2px;
}

dialog.drawer:not([open]) {
    display: none;
}

dialog.drawer::backdrop {
    background: rgba(29, 38, 36, 0.35);
}


.drawer iframe {
    flex: 1;
    width: 100%;
    border: 0;
}

@keyframes drawer-in {
    from {
        transform: translateX(32px);
        opacity: 0.6;
    }
}

@media (prefers-reduced-motion: reduce) {
    dialog.drawer {
        animation: none;
    }
}

/* --- Страница внутри панели ------------------------------------------- */

body.is-embedded .main {
    padding: 20px 24px 32px;
}

body.is-embedded .back {
    display: none;
}

/* ==========================================================================
   Поиск и фильтр заказов
   ========================================================================== */

.search-filter {
    position: relative;
}

.search-box {
    display: flex;
    align-items: center;
    background: var(--surface);
    border: 1px solid var(--line-strong);
    border-radius: var(--r-control);
}

.search-box:focus-within {
    border-color: var(--accent);
}

.search-box input[type="search"] {
    min-width: 320px;
    border: 0;
    background: transparent;
}

.search-box input[type="search"]:focus {
    outline: none;
}

.filter-count {
    margin-right: 10px;
    padding: 1px 8px;
    font-size: var(--small);
    font-weight: 600;
    color: var(--accent);
    background: var(--accent-soft);
    border-radius: 999px;
}

.filter-body {
    position: absolute;
    z-index: 20;
    top: calc(100% + 6px);
    left: 0;
    width: min(620px, 90vw);
    padding: 18px 20px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--r-panel);
    box-shadow: 0 12px 32px rgba(29, 38, 36, 0.14);
}

.filter-actions {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-top: 16px;
}

/* --- Подбор товаров ---------------------------------------------------- */

.picker {
    position: relative;
}

.picker-control {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
    padding: 6px 8px;
    background: var(--surface);
    border: 1px solid var(--line-strong);
    border-radius: var(--r-control);
}

.picker-control:focus-within {
    border-color: var(--accent);
}

.picker .picker-input {
    flex: 1;
    min-width: 160px;
    min-height: 26px;
    padding: 2px 4px;
    border: 0;
    background: transparent;
}

.picker .picker-input:focus {
    outline: none;
}

.picker-chips {
    display: contents;
}

.picker-values {
    display: none;
}

.picker-list {
    position: absolute;
    z-index: 30;
    top: calc(100% + 4px);
    left: 0;
    right: 0;
    max-height: 280px;
    margin: 0;
    padding: 4px;
    overflow-y: auto;
    list-style: none;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--r-control);
    box-shadow: 0 10px 28px rgba(29, 38, 36, 0.16);
}

.picker-option {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 8px;
    font-size: 14px;
    border-radius: var(--r-control);
    cursor: pointer;
}

.picker-option:hover,
.picker-option.is-active {
    background: var(--accent-soft);
}

.picker-thumb {
    flex: 0 0 32px;
    width: 32px;
    height: 32px;
    overflow: hidden;
    background: var(--bg);
    border: 1px solid var(--line);
    border-radius: 4px;
}

.picker-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.picker-name {
    flex: 1;
    min-width: 0;
}

.picker-price {
    color: var(--muted);
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 3px 6px 3px 10px;
    font-size: var(--small);
    background: var(--accent-soft);
    border-radius: 999px;
}

.chip button {
    min-height: 0;
    padding: 0 4px;
    font-size: 15px;
    line-height: 1;
    color: var(--muted);
    background: transparent;
    border: 0;
}

.chip button:hover {
    color: var(--danger);
    border: 0;
}

/* ==========================================================================
   Настройки
   ========================================================================== */

.settings-nav {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-bottom: 20px;
    border-bottom: 1px solid var(--line);
}

.settings-nav a {
    margin-bottom: -1px;
    padding: 8px 14px;
    font-size: 14px;
    font-weight: 500;
    color: var(--muted);
    text-decoration: none;
    border-bottom: 2px solid transparent;
}

.settings-nav a:hover {
    color: var(--ink);
}

.settings-nav a.is-active {
    color: var(--accent);
    border-bottom-color: var(--accent);
}

.settings-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 16px;
}

.settings-card {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 18px 20px;
    color: var(--ink);
    text-decoration: none;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--r-panel);
}

.settings-card:hover {
    color: var(--ink);
    border-color: var(--line-strong);
}

.settings-card-title {
    font-size: 16px;
    font-weight: 600;
}

.settings-card-text {
    font-size: var(--small);
    color: var(--muted);
}

.picker-archived {
    padding: 1px 6px;
    font-size: 11px;
    color: var(--muted);
    background: var(--bg);
    border-radius: 999px;
}

.filter-group {
    display: contents;
}

.filter-group[hidden] {
    display: none;
}

.setup-item {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--ink);
    cursor: pointer;
}

dialog.modal {
    width: min(460px, 92vw);
    max-width: none;
    padding: 0;
    color: var(--ink);
    background: var(--surface);
    border: 0;
    border-radius: var(--r-panel);
    box-shadow: 0 24px 60px rgba(29, 38, 36, 0.24);
}

dialog.modal::backdrop {
    background: rgba(29, 38, 36, 0.35);
}

.modal-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 16px 20px 12px;
    border-bottom: 1px solid var(--line);
}

.modal-head h2 {
    margin: 0;
}

.modal-body {
    padding: 16px 20px;
}

.modal-foot {
    display: flex;
    justify-content: flex-end;
    padding: 12px 20px 16px;
    border-top: 1px solid var(--line);
}

.setup-list {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
    gap: 8px 16px;
    margin-top: 12px;
}

/* --- Карточка: данные слева, лента справа ----------------------------- */

.record-grid {
    display: grid;
    grid-template-columns: 320px minmax(0, 1fr);
    gap: 20px;
    align-items: start;
}

.record-side {
    margin-bottom: 0;
}

.record-side-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 14px;
}

.record-side-head h2 {
    margin: 0;
}

.record-edit {
    font-size: var(--small);
}

.record-fields {
    display: block;
}

.record-fields dt {
    margin-top: 12px;
    font-size: var(--small);
    color: var(--muted);
}

.record-fields dt:first-child {
    margin-top: 0;
}

.record-fields dd {
    margin: 2px 0 0;
}

.stat-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 12px;
    margin-bottom: 16px;
}

.stat {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 12px 16px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--r-panel);
}

.stat-label {
    font-size: var(--small);
    color: var(--muted);
}

.stat-value {
    font-size: 18px;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}

.tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-bottom: 16px;
    border-bottom: 1px solid var(--line);
}

.tab {
    margin-bottom: -1px;
    padding: 8px 14px;
    font-size: 14px;
    font-weight: 500;
    color: var(--muted);
    background: transparent;
    border: 0;
    border-bottom: 2px solid transparent;
    border-radius: 0;
}

.tab:hover {
    color: var(--ink);
    border-color: transparent;
    border-bottom-color: var(--line-strong);
}

.tab.is-active {
    color: var(--accent);
    border-bottom-color: var(--accent);
}

.event {
    display: flex;
    gap: 16px;
    padding: 10px 0;
    border-bottom: 1px solid var(--line);
}

.event:last-child {
    border-bottom: 0;
    padding-bottom: 0;
}

.event-time {
    flex: 0 0 120px;
    font-size: var(--small);
    color: var(--muted);
    font-variant-numeric: tabular-nums;
}

.event-body {
    min-width: 0;
}

@media (max-width: 900px) {
    .record-grid {
        grid-template-columns: 1fr;
    }

    .event {
        flex-direction: column;
        gap: 4px;
    }
}

.field-row {
    padding: 8px 0;
    border-bottom: 1px solid var(--line);
}

.field-row:last-child {
    border-bottom: 0;
}

.field-label {
    display: block;
    font-size: var(--small);
    color: var(--muted);
}

.field-view {
    margin-top: 2px;
    padding: 2px 6px;
    margin-left: -6px;
    border-radius: var(--r-control);
    cursor: text;
}

.field-row:not(.field-row-static) .field-view:hover {
    background: var(--bg);
}

.field-row-static .field-view {
    cursor: default;
}

.field-edit {
    margin-top: 4px;
}

.field-edit input,
.field-edit select,
.field-edit textarea {
    width: 100%;
}

.record-actions {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-top: 16px;
    padding-top: 14px;
    border-top: 1px solid var(--line);
}

.record-actions .btn-quiet {
    padding-left: 8px;
    padding-right: 8px;
}

.title-block .field-view {
    margin: 0 0 0 -6px;
}

.title-block h1 {
    display: inline-block;
}

.title-input {
    min-width: 320px;
    font-size: 22px;
    font-weight: 650;
}

.chip-plain {
    background: var(--bg);
    border: 1px solid var(--line);
}

/* Список галочек: пары «галочка + подпись» в строку */
.field input[type="checkbox"] {
    width: 16px;
    flex: 0 0 16px;
    vertical-align: middle;
}

.field input[type="checkbox"] + label {
    display: inline;
    margin-left: 8px;
    font-size: 14px;
    font-weight: 400;
    color: var(--ink);
    cursor: pointer;
}

.field > div,
.field > ul,
.field > ul > li {
    list-style: none;
    margin: 0;
    padding: 0;
}

/* ==========================================================================
   Товары: карточка, миниатюры, вариации
   ========================================================================== */

.page-actions {
    display: flex;
    align-items: center;
    gap: 10px;
}

.product-form {
    display: grid;
    grid-template-columns: 220px 1fr;
    gap: 24px;
    align-items: start;
}

.product-photo {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.product-photo-frame {
    display: flex;
    align-items: center;
    justify-content: center;
    aspect-ratio: 1 / 1;
    overflow: hidden;
    background: var(--surface-hover);
    border: 1px solid var(--line);
    border-radius: var(--r-panel);
}

.product-photo-frame img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.product-photo-empty {
    font-size: var(--small);
    color: var(--muted);
}

.product-photo input[type="file"] {
    width: 100%;
    font-size: var(--small);
}

.col-thumb {
    width: 56px;
}

.thumb {
    display: block;
    width: 40px;
    height: 40px;
    object-fit: cover;
    background: var(--surface-hover);
    border: 1px solid var(--line);
    border-radius: var(--r-control);
}

.thumb-empty {
    background: repeating-linear-gradient(
            45deg,
            var(--surface-hover),
            var(--surface-hover) 6px,
            var(--bg) 6px,
            var(--bg) 12px
    );
}

tr.variant td:nth-child(2) {
    padding-left: 28px;
}

tr.variant .cell-main {
    font-weight: 400;
}

tr.variant td {
    background: var(--surface-hover);
}

.items-table .col-discount {
    width: 110px;
}

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

    .product-photo {
        max-width: 220px;
    }
}

[hidden] {
    display: none !important;
}

.hint-warn {
    color: var(--danger);
}

/* --- Товар в строке заказа -------------------------------------------- */

.item-picker {
    position: relative;
}

.item-picker[data-ready] select {
    display: none;
}

.item-picker-button {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 5px 10px;
    font: inherit;
    text-align: left;
    color: var(--ink);
    background: var(--surface);
    border: 1px solid var(--line-strong);
    border-radius: var(--r-control);
    cursor: pointer;
}

.item-picker-button:hover {
    border-color: var(--focus);
}

.item-thumb {
    flex: none;
    display: block;
    width: 32px;
    height: 32px;
    overflow: hidden;
    background: var(--surface-hover);
    border: 1px solid var(--line);
    border-radius: 4px;
}

.item-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.item-picker-label {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.item-picker-label.is-empty {
    color: var(--muted);
}

.item-picker-panel {
    position: absolute;
    z-index: 20;
    top: calc(100% + 4px);
    left: 0;
    width: min(420px, 90vw);
    padding: 8px;
    background: var(--surface);
    border: 1px solid var(--line-strong);
    border-radius: var(--r-panel);
    box-shadow: 0 10px 28px rgba(29, 38, 36, 0.16);
}

.item-picker-search {
    width: 100%;
    margin-bottom: 6px;
}

.item-picker-list {
    max-height: 320px;
    margin: 0;
    padding: 0;
    overflow-y: auto;
    list-style: none;
}

.item-picker-option {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 8px;
    border-radius: var(--r-control);
    cursor: pointer;
}

.item-picker-option:hover,
.item-picker-option.is-chosen {
    background: var(--surface-hover);
}

.item-picker-price {
    flex: none;
    font-size: var(--small);
    color: var(--muted);
}

.item-picker-empty {
    padding: 10px 8px;
    font-size: var(--small);
    color: var(--muted);
}

.discount-input {
    display: flex;
    gap: 4px;
}

.discount-input input {
    min-width: 0;
    flex: 1;
}

.discount-input select {
    flex: none;
    width: 66px;
    padding-right: 4px;
}

.items-table .col-discount {
    width: 160px;
}

.items-table .col-discount {
    width: 180px;
}

.items-table .col-sum {
    width: 120px;
    font-variant-numeric: tabular-nums;
}

.items-table .col-del {
    width: 52px;
}

.discount-input {
    display: flex;
    gap: 4px;
}

.discount-input input {
    flex: 1;
    min-width: 0;
}

.discount-input select {
    flex: none;
    width: 70px;
}

/* --- Крестик удаления ------------------------------------------------- */

.row-del {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    padding: 0;
    font-size: 20px;
    line-height: 1;
    color: var(--muted);
    background: none;
    border: 1px solid transparent;
    border-radius: var(--r-control);
    cursor: pointer;
}

.row-del:hover {
    color: var(--danger);
    background: var(--danger-soft);
}

.row-del input {
    position: absolute;
    width: 1px;
    height: 1px;
    opacity: 0;
    pointer-events: none;
}

.row-del:has(input:checked) {
    color: var(--danger);
    background: var(--danger-soft);
}

tr:has(.row-del input:checked) td:not(.col-del) {
    opacity: 0.4;
    text-decoration: line-through;
}

/* --- Товары занимают всю высоту правой колонки ------------------------ */

.record-grid {
    align-items: stretch;
}

.record-main {
    display: flex;
    flex-direction: column;
    min-height: 60vh;
}

.record-main .tab-panel[data-panel="items"] {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.record-main .tab-panel[data-panel="items"] > form {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.record-main .tab-panel[data-panel="items"] .panel.is-flush {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.record-main .tab-panel[data-panel="items"] .panel-foot {
    margin-top: 0;          /* сразу под «Итого», а не внизу высокой колонки */
    border-bottom: 1px solid var(--line);
}

.items-table .errorlist {
    margin: 4px 0 0;
    padding: 0;
    font-size: 12px;
    line-height: 1.3;
    color: var(--danger);
    list-style: none;
}

/* --- Постраничность --------------------------------------------------- */

.pager {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: 16px;
}

.pager-step {
    padding: 6px 12px;
    font-size: var(--small);
    color: var(--ink);
    text-decoration: none;
    background: var(--surface);
    border: 1px solid var(--line-strong);
    border-radius: var(--r-control);
}

.pager-step:hover {
    border-color: var(--focus);
}

.pager-step.is-off {
    color: var(--muted);
    background: transparent;
    border-color: var(--line);
    pointer-events: none;
}

.pager-state {
    margin-left: auto;
    font-size: var(--small);
    color: var(--muted);
}

.item-stock {
    display: block;
    margin-top: 4px;
    font-size: 12px;
    color: var(--muted);
}

.item-picker-stock {
    flex: none;
    font-size: var(--small);
    color: var(--muted);
}

.item-stock.is-short,
.item-picker-stock.is-short {
    color: var(--danger);
    font-weight: 500;
}

.ship-form {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-top: 16px;
}

/* --- Лента заказа: комментарии, дела, история ------------------------------
   Добавить в конец ordium.css. Цвета — через ваши переменные, если они
   называются иначе, поменяйте имена; значения после запятой — запасные. */

.tab-count {
    display: inline-block;
    min-width: 18px;
    padding: 0 6px;
    margin-left: 4px;
    border-radius: 9px;
    font-size: 12px;
    line-height: 18px;
    text-align: center;
    background: var(--muted-bg, #ece7e1);
}

.tab-count.is-overdue {
    background: var(--danger, #c0392b);
    color: var(--on-danger);
}

/* Поле ввода над лентой */
.composer {
    border: 1px solid var(--border, #e5ded6);
    border-radius: 10px;
    padding: 12px;
    margin-bottom: 20px;
}

.composer-modes {
    display: flex;
    gap: 4px;
    margin-bottom: 10px;
}

.composer-mode {
    border: 0;
    background: none;
    padding: 4px 10px;
    border-radius: 6px;
    cursor: pointer;
    color: var(--muted, #7a7068);
    font: inherit;
}

.composer-mode.is-active {
    background: var(--muted-bg, #ece7e1);
    color: inherit;
    font-weight: 600;
}

.composer-form textarea {
    width: 100%;
    resize: vertical;
}

.composer-grid {
    display: grid;
    grid-template-columns: 140px 1fr;
    gap: 10px 12px;
}

.composer-grid label {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.composer-wide {
    grid-column: span 1;
}

.composer-actions {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-top: 10px;
}

/* Запланированные дела */
.planned {
    margin-bottom: 20px;
}

.planned-title {
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: var(--muted, #7a7068);
    margin: 0 0 8px;
}

.activity {
    display: flex;
    gap: 12px;
    align-items: flex-start;
    padding: 10px 12px;
    border: 1px solid var(--border, #e5ded6);
    border-radius: 8px;
    margin-bottom: 6px;
}

.activity.is-overdue {
    border-color: var(--danger, #c0392b);
    background: color-mix(in srgb, var(--danger, #c0392b) 6%, transparent);
}

.activity-check {
    flex: none;
    width: 20px;
    height: 20px;
    min-height: 0; /* общий стиль кнопок не должен растягивать кружок */
    margin-top: 1px;
    padding: 0;
    background: var(--surface) center / 12px 12px no-repeat;
    border: 1.5px solid var(--line-strong);
    border-radius: 50%;
    cursor: pointer;
    transition: background-color .12s, border-color .12s;
}

/* При наведении — подсказка галочкой: нажмёшь, и дело выполнено */
.activity-check:hover {
    border-color: var(--accent);
    background-color: var(--accent-soft);
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12'%3E%3Cpath d='M2.5 6.2 5 8.6l4.5-5' fill='none' stroke='%232E5E52' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
}

.activity-check:focus-visible {
    outline: none;
    box-shadow: 0 0 0 3px var(--accent-soft), 0 0 0 4px var(--focus);
}

.activity-check:hover::after {
    opacity: 1;
}

.badge-overdue {
    color: var(--danger, #c0392b);
    font-weight: 600;
}

/* Сама лента */
.event-who {
    font-weight: 600;
    margin-bottom: 2px;
}

.comment-text {
    white-space: normal;
    overflow-wrap: anywhere;
}

.changes {
    margin: 2px 0 0;
    padding-left: 18px;
}

.changes li {
    margin: 2px 0;
}

.change-old {
    color: var(--muted, #7a7068);
    text-decoration: line-through;
}

@media (max-width: 700px) {
    .composer-grid {
        grid-template-columns: 1fr;
    }
}

/* --- Лента заказа: комментарии, дела, история ------------------------------
   Добавить в конец ordium.css. Цвета — через ваши переменные, если они
   называются иначе, поменяйте имена; значения после запятой — запасные. */

.tab-count {
    display: inline-block;
    min-width: 18px;
    padding: 0 6px;
    margin-left: 4px;
    border-radius: 9px;
    font-size: 12px;
    line-height: 18px;
    text-align: center;
    background: var(--muted-bg, #ece7e1);
}

.tab-count.is-overdue {
    background: var(--danger, #c0392b);
    color: var(--on-danger);
}

/* Поле ввода над лентой */
.composer {
    border: 1px solid var(--border, #e5ded6);
    border-radius: 10px;
    padding: 12px;
    margin-bottom: 20px;
}

.composer-modes {
    display: flex;
    gap: 4px;
    margin-bottom: 10px;
}

.composer-mode {
    border: 0;
    background: none;
    padding: 4px 10px;
    border-radius: 6px;
    cursor: pointer;
    color: var(--muted, #7a7068);
    font: inherit;
}

.composer-mode.is-active {
    background: var(--muted-bg, #ece7e1);
    color: inherit;
    font-weight: 600;
}

.composer-form textarea {
    width: 100%;
    resize: vertical;
}

.composer-grid {
    display: grid;
    grid-template-columns: 140px 1fr;
    gap: 10px 12px;
}

.composer-grid label {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.composer-wide {
    grid-column: span 1;
}

.composer-actions {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-top: 10px;
}

/* Запланированные дела */
.planned {
    margin-bottom: 20px;
}

.planned-title {
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: var(--muted, #7a7068);
    margin: 0 0 8px;
}

.activity {
    display: flex;
    gap: 12px;
    align-items: flex-start;
    padding: 10px 12px;
    border: 1px solid var(--border, #e5ded6);
    border-radius: 8px;
    margin-bottom: 6px;
}

.activity.is-overdue {
    border-color: var(--danger, #c0392b);
    background: color-mix(in srgb, var(--danger, #c0392b) 6%, transparent);
}


.badge-overdue {
    color: var(--danger, #c0392b);
    font-weight: 600;
}

/* Сама лента */
.event-who {
    font-weight: 600;
    margin-bottom: 2px;
}

.comment-text {
    white-space: normal;
    overflow-wrap: anywhere;
}

.changes {
    margin: 2px 0 0;
    padding-left: 18px;
}

.changes li {
    margin: 2px 0;
}

.change-old {
    color: var(--muted, #7a7068);
    text-decoration: line-through;
}

@media (max-width: 700px) {
    .composer-grid {
        grid-template-columns: 1fr;
    }
}

/* Вкладки карточки заказа перетаскиваются */
.tabs [draggable="true"] {
    cursor: grab;
}

.tabs .is-dragging {
    opacity: .4;
}


/* Звонки в ленте и кнопка «Позвонить» */
.call-missed {
    color: var(--danger, #c0392b);
}

.call-record {
    display: block;
    width: 100%;
    max-width: 360px;
    height: 32px;
    margin-top: 6px;
}

.call-button {
    margin-left: 8px;
    padding: 2px 10px;
    border: 1px solid var(--border, #e5ded6);
    border-radius: 6px;
    background: none;
    font: inherit;
    font-size: 13px;
    cursor: pointer;
}

.call-button:hover {
    background: var(--muted-bg, #ece7e1);
}

.call-button:disabled {
    opacity: .5;
    cursor: default;
}


/* --- Массовые действия в списке заказов ----------------------------------- */

.check-cell {
    width: 1%;
    padding: 11px 6px 11px 18px;
}

th.check-cell {
    padding-top: 10px;
    padding-bottom: 10px;
}

/* Своя галочка вместо системной: под цвета Ordium и одинаковая во всех браузерах. */
.check-cell input[type="checkbox"],
.kanban-check {
    appearance: none;
    -webkit-appearance: none;
    display: block;
    width: 18px;
    height: 18px;
    min-height: 0;
    margin: 1px 0 0;
    padding: 0;
    background: var(--surface) center / 12px 12px no-repeat;
    border: 1.5px solid var(--line-strong);
    border-radius: 5px;
    cursor: pointer;
    transition: background-color .12s, border-color .12s, box-shadow .12s;
}

.check-cell input[type="checkbox"]:hover,
.kanban-check:hover {
    border-color: var(--accent);
}

.check-cell input[type="checkbox"]:focus-visible,
.kanban-check:focus-visible {
    outline: none;
    box-shadow: 0 0 0 3px var(--accent-soft), 0 0 0 4px var(--focus);
}

.check-cell input[type="checkbox"]:checked,
.kanban-check:checked {
    background-color: var(--accent);
    border-color: var(--accent);
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12'%3E%3Cpath d='M2.5 6.2 5 8.6l4.5-5' fill='none' stroke='white' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
}

/* «Отмечена часть страницы» в шапке — чёрточка */
.check-cell input[type="checkbox"]:indeterminate,
.kanban-check:indeterminate {
    background-color: var(--accent);
    border-color: var(--accent);
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12'%3E%3Cpath d='M3 6h6' stroke='white' stroke-width='1.8' stroke-linecap='round'/%3E%3C/svg%3E");
}

tbody tr.is-selected {
    background: var(--accent-soft);
}

.bulk-all {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px 12px;
    margin-bottom: 10px;
    padding: 8px 14px;
    font-size: 14px;
    background: var(--accent-soft);
    border-radius: var(--r-panel);
}

.bulk-link {
    min-height: 0;
    padding: 0;
    color: var(--accent);
    text-decoration: underline;
}

/* Панель висит внизу экрана: и под длинным списком, и над канбаном, у которого свой скролл. */
.bulk-bar {
    position: fixed;
    left: 50%;
    bottom: 16px;
    transform: translateX(-50%);
    width: max-content;
    max-width: calc(100vw - 32px);
    z-index: 50;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px 16px;
    padding: 12px 16px;
    background: var(--surface);
    border: 1px solid var(--line-strong);
    border-radius: var(--r-panel);
    box-shadow: 0 8px 24px rgba(36, 32, 29, .12);
}

.bulk-bar[hidden],
.bulk-all[hidden],
.bulk-all [hidden] {
    display: none;
}

.bulk-count {
    font-weight: 600;
}

.bulk-group {
    display: inline-flex;
    gap: 6px;
}

.bulk-group select {
    max-width: 220px;
    border: 1px solid var(--line-strong);
    border-radius: var(--r-control);
}

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

.bulk-bar .btn-danger:hover {
    color: var(--on-danger);
    background: var(--danger-hover);
    border-color: var(--danger-hover);
}

.bulk-bar button:disabled {
    opacity: .5;
    cursor: default;
}


@media (max-width: 700px) {
    .bulk-bar {
        bottom: 8px;
        width: calc(100vw - 16px);
    }

    .bulk-group {
        flex: 1 1 100%;
    }

    .bulk-group select {
        flex: 1;
        max-width: none;
    }
}

/* Отправка частями: вместо кнопок — ход работы */
.bulk-bar.is-running .bulk-group,
.bulk-bar.is-running > button {
    display: none;
}

.bulk-progress {
    display: inline-flex;
    flex: 1;
    align-items: center;
    gap: 10px;
    min-width: 220px;
}

.bulk-progress[hidden] {
    display: none;
}

.bulk-progress progress {
    flex: 1;
    height: 8px;
    accent-color: var(--accent);
}


/* --- Дела: страница «Дела», счётчик в меню, точки просрочки ---------------- */

.activity-who {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.activity-who select {
    border: 1px solid var(--line-strong);
    border-radius: var(--r-control);
}

.activity-empty p {
    margin: 0;
    color: var(--muted);
}

.activity-section {
    margin-bottom: 24px;
}

.activity-section-title {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 0 0 8px;
    font-size: 13px;
    font-weight: 600;
    letter-spacing: .04em;
    text-transform: uppercase;
    color: var(--muted);
}

.activity-section-title span {
    padding: 0 7px;
    font-size: 12px;
    line-height: 20px;
    letter-spacing: 0;
    color: var(--ink);
    background: var(--line);
    border-radius: 999px;
}

.activity-section.is-overdue .activity-section-title,
.activity-section.is-overdue .activity-section-title span {
    color: var(--danger);
}

.activity-section.is-overdue .activity-section-title span {
    background: var(--danger-soft);
}

.todo {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 12px 14px;
    margin-bottom: 6px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--r-panel);
    box-shadow: inset 3px 0 0 var(--stage, transparent);
}

.todo.is-overdue {
    border-color: color-mix(in srgb, var(--danger) 35%, var(--line));
}

.todo-done {
    margin: 0;
}

.todo .activity-check {
    min-height: 0;
    padding: 0;
}

.todo-body {
    flex: 1;
    min-width: 0;
}

.todo-what {
    font-weight: 550;
    overflow-wrap: anywhere;
}

.todo-kind {
    display: inline-block;
    width: 18px;
    color: var(--muted);
}

.todo-meta {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 4px 10px;
    margin-top: 4px;
    font-size: var(--small);
}

.todo-when {
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}

.todo.is-overdue .todo-when {
    color: var(--danger);
}

.todo-order {
    font-weight: 600;
}

.todo-later form {
    display: flex;
    gap: 2px;
}

.todo-later .btn-quiet {
    min-height: 28px;
    padding: 2px 8px;
    font-size: var(--small);
}

.todo-later .btn-quiet:hover {
    background: var(--surface-hover);
}

/* Счётчик в меню: сколько дел пора сделать */
.nav-badge {
    display: inline-block;
    flex: none;
    min-width: 20px;
    padding: 0 6px;
    font-size: 11px;
    font-weight: 600;
    line-height: 18px;
    text-align: center;
    font-variant-numeric: tabular-nums;
    color: var(--muted);
    background: var(--tint);
    border-radius: 999px;
}

/* Красная точка: у заказа есть просроченное дело */
.overdue-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    margin-left: 6px;
    vertical-align: middle;
    background: var(--danger);
    border-radius: 50%;
    box-shadow: 0 0 0 2px var(--danger-soft);
}

@media (max-width: 700px) {
    .todo {
        flex-wrap: wrap;
    }

    .todo-later {
        width: 100%;
        padding-left: 32px;
    }
}

/* --- Карточка канбана: номер, время, сумма; название; клиент, дела, звонок ---------- */

.kanban-card {
    position: relative;
    display: flex;
    flex: none;
    flex-direction: column;
    gap: 6px;
    padding: 10px 12px 10px;
    color: var(--ink);
    text-decoration: none;
    background: var(--surface);
    border: 0;
    border-radius: 10px;
    box-shadow: 0 0 0 0.5px var(--ring), var(--shadow-sm);
    transition: box-shadow .12s, transform .12s;
}

.kanban-card:hover {
    color: var(--ink);
    box-shadow: 0 0 0 0.5px var(--ring), 0 4px 14px rgba(0, 0, 0, .08);
}

/* Просроченное дело — красная полоска слева */
.kanban-card.is-overdue {
    box-shadow: inset 3px 0 0 var(--danger), 0 0 0 0.5px var(--ring), var(--shadow-sm);
}

.kanban-card.is-selected {
    background: var(--accent-soft);
    box-shadow: 0 0 0 1.5px var(--accent);
}

.kanban-card[draggable="true"] {
    cursor: grab;
}

.kanban-card.is-dragging {
    opacity: 0.45;
    transform: rotate(1.5deg);
}

.kanban-card-top,
.kanban-card-foot {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
}

.kanban-card-id {
    flex: none;
    font-size: 12px;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    color: var(--muted);
}

.kanban-card-age {
    overflow: hidden;
    font-size: 12px;
    color: var(--muted);
    white-space: nowrap;
    text-overflow: ellipsis;
}

.kanban-card-sum {
    flex: none;
    margin-left: auto;
    font-size: 13px;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.kanban-card-title {
    display: -webkit-box;
    overflow: hidden;
    font-size: 14px;
    font-weight: 600;
    line-height: 1.3;
    color: var(--ink);
    text-decoration: none;
    overflow-wrap: anywhere;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

/* Ссылка на заказ растянута на всю карточку: клик в любое пустое место открывает заказ.
   Всё, что должно нажиматься само по себе, лежит выше (z-index: 1). */
.kanban-card-link::after {
    content: "";
    position: absolute;
    inset: 0;
    border-radius: inherit;
}

.kanban-card-link:focus-visible {
    outline: none;
}

.kanban-card-link:focus-visible::after {
    box-shadow: 0 0 0 2px var(--focus);
}

.kanban-check,
.kanban-card-customer,
.kanban-call {
    position: relative;
    z-index: 1;
}

.kanban-card-customer {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    font-size: var(--small);
    color: var(--muted);
    text-overflow: ellipsis;
    white-space: nowrap;
}

a.kanban-card-customer {
    text-decoration: none;
}

a.kanban-card-customer:hover {
    color: var(--accent);
    text-decoration: underline;
}

/* Счётчик дел: серый 0, зелёный — есть дела, красный — что-то просрочено */
.todo-count {
    display: inline-flex;
    flex: none;
    align-items: center;
    justify-content: center;
    min-width: 22px;
    height: 22px;
    padding: 0 6px;
    font-size: 12px;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    border-radius: 999px;
}

.todo-count.is-none {
    color: var(--muted);
    background: var(--tint);
}

.todo-count.is-open {
    color: var(--on-accent);
    background: var(--accent);
}

.todo-count.is-overdue {
    color: var(--on-danger);
    background: var(--danger);
}

.kanban-call {
    display: inline-flex;
    flex: none;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    min-height: 0;
    padding: 0;
    color: var(--accent-ink);
    background: var(--accent-soft);
    border: 0;
    border-radius: 50%;
    cursor: pointer;
}

.kanban-call:hover {
    color: var(--on-accent);
    background: var(--accent);
}

.kanban-call:disabled {
    opacity: .5;
    cursor: default;
}

.kanban-card .kanban-check {
    flex: none;
    margin: 0;
}

.items-locked {
    margin: 0 0 10px;
    padding: 10px 14px;
    font-size: var(--small);
    color: var(--muted);
    background: var(--surface);
    border: 1px dashed var(--line-strong);
    border-radius: var(--r-panel);
}

/* Перенос в другую воронку — под полосой стадий в карточке заказа */
.pipeline-move {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px dashed var(--line);
    font-size: var(--small);
}

.pipeline-move label {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.pipeline-move select {
    border: 1px solid var(--line-strong);
    border-radius: var(--r-control);
}

.col-next select {
    max-width: 200px;
}

/* === Товары в заказе: колонки фиксированной ширины, вариация второй строкой ===
   Дописать в конец static/css/ordium.css. */

/* Таблица не сжимается: у каждой колонки своя ширина. Не помещается —
   листается вбок, как в Битриксе. */
.items-scroll {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.items-scroll > .items-table {
    table-layout: fixed;
    width: 100%;
    min-width: 1180px;
}

.items-scroll > .items-table.is-readonly {
    min-width: 900px;
}

/* Приход и списание: колонок мало, прокрутка не нужна, но ширины тоже свои */
.items-table.is-fixed {
    table-layout: fixed;
    width: 100%;
}

.items-table col.w-product {
    width: auto;
}

/* всё, что осталось, — названию */
.items-table col.w-stock {
    width: 96px;
}

.items-table col.w-qty {
    width: 84px;
}

.items-table col.w-state {
    width: 84px;
}

.items-table col.w-shipped {
    width: 104px;
}

.items-table col.w-price {
    width: 128px;
}

.items-table col.w-discount {
    width: 204px;
}

/* «1 500,00» + «лей» */
.items-table col.w-sum {
    width: 120px;
}

.items-table col.w-del {
    width: 44px;
}

.items-table col.w-qty-wide {
    width: 140px;
}

.items-table col.w-cost {
    width: 170px;
}

.items-table th,
.items-table td {
    vertical-align: middle;
}

.items-table td input,
.items-table td select {
    width: 100%;
    min-width: 0;
    box-sizing: border-box;
}

.items-table .col-sum,
.items-table .num,
.items-table tfoot th {
    white-space: nowrap;
    overflow: hidden; /* огромное число не залезет на соседнюю колонку */
    text-overflow: ellipsis;
}

.items-table .discount-input {
    display: flex;
    gap: 6px;
}

.items-table .discount-input input {
    flex: 0 0 104px;
    width: 104px;
}

.items-table .discount-input select {
    flex: 1 1 auto;
    min-width: 64px;
}

.items-table .col-price input,
.items-table .col-qty input,
.items-table .discount-input input {
    padding-left: 8px;
    padding-right: 8px;
    text-align: right;
}

/* --- Название: товар и под ним вариация ------------------------------------ */
.product-name {
    display: flex;
    flex-direction: column;
    min-width: 0;
    line-height: 1.25;
    text-align: left;
}

.product-name-main,
.product-name-variant {
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
}

.product-name-variant {
    font-size: var(--small, 12px);
    color: var(--muted, #8b8178);
    margin-top: 2px;
}

/* --- Подборщик товара в строке ---------------------------------------------- */
.items-table .item-picker {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
}

.item-picker .item-picker-button {
    flex: 1 1 auto;
    min-width: 0;
    display: flex;
    align-items: center;
    min-height: 44px;
    justify-content: flex-start; /* общий стиль кнопок центрирует — название должно быть слева */
    text-align: left;
    overflow: hidden;
}

.item-picker .item-picker-button .product-name {
    flex: 1 1 auto;
}

.item-picker .item-picker-label.is-empty {
    color: var(--muted, #8b8178);
}

/* Фото — отдельная кнопка: открывает снимок крупно */
.item-thumb-button {
    flex: 0 0 auto;
    padding: 0;
    min-height: 0;
    border: 0;
    background: none;
    line-height: 0;
    cursor: pointer;
    border-radius: var(--r-control, 6px);
}

.item-thumb-button.has-photo {
    cursor: zoom-in;
}

.item-thumb-button.has-photo:hover .item-thumb {
    box-shadow: 0 0 0 2px var(--accent, #2f5d50);
}

.item-thumb-button:focus-visible {
    outline: 2px solid var(--focus, var(--accent, #2f5d50));
    outline-offset: 2px;
}

.item-line {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
}

/* Список товаров висит поверх страницы, а не внутри прокручиваемой таблицы */
.item-picker .item-picker-panel {
    position: fixed;
    z-index: 60;
    max-height: 360px;
    display: flex;
    flex-direction: column;
}

.item-picker .item-picker-panel[hidden] {
    display: none;
}

/* display:flex перебил бы hidden */
.item-picker .item-picker-list {
    overflow-y: auto;
    min-height: 0;
}

.item-picker-option {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) 90px 90px;
    align-items: center;
    gap: 10px;
}

.item-picker-option .item-picker-stock,
.item-picker-option .item-picker-price {
    text-align: right;
    white-space: nowrap;
}

/* --- Фото крупно ------------------------------------------------------------- */
.lightbox {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background: rgba(20, 16, 12, .78);
    cursor: zoom-out;
}

.lightbox img {
    max-width: min(90vw, 1000px);
    max-height: 90vh;
    object-fit: contain;
    border-radius: 8px;
    background: #fff;
    box-shadow: 0 12px 40px rgba(0, 0, 0, .35);
}

.lightbox-close {
    position: absolute;
    top: 16px;
    right: 20px;
    min-height: 0;
    width: 40px;
    height: 40px;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, .15);
    color: #fff;
    font-size: 26px;
    line-height: 40px;
    cursor: pointer;
}

.lightbox-close:hover {
    background: rgba(255, 255, 255, .28);
}

/* --- Фильтр заказов: товар и вариация в подсказках и выбранных ------------- */
.picker-name .product-name {
    display: inline-flex;
    vertical-align: middle;
    max-width: 100%;
}

.chip .product-name {
    display: inline-flex;
    max-width: 260px;
}

.chip .product-name-variant {
    font-size: 11px;
    margin-top: 0;
}

/* --- Артикул: перед названием, моноширинно, чтобы номера стояли ровно ------- */
.product-code {
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: .9em;
    font-weight: 600;
    color: var(--muted, #8b8178);
    font-variant-numeric: tabular-nums;
}

/* Список товаров в фильтре заказов шире самого поля: названия длинные */
.picker .picker-list {
    min-width: min(520px, 90vw);
}

/* === Источники заявок и метки в карточке заказа ===
   Дописать в конец static/css/ordium.css. */

.lead-howto .copy-row {
    display: flex;
    gap: 8px;
    margin: 8px 0;
}

.lead-howto .copy-field {
    flex: 1 1 auto;
    min-width: 0;
    font-family: ui-monospace, Menlo, Consolas, monospace;
}

.lead-howto .code-field {
    display: block;
    width: 100%;
    box-sizing: border-box;
    margin: 8px 0;
    padding: 12px;
    font: 12px/1.5 ui-monospace, Menlo, Consolas, monospace;
    background: var(--muted-bg, #f6efe9);
    border: 1px solid var(--line, #eadfd6);
    border-radius: var(--r-control, 6px);
    white-space: pre;
    overflow: auto;
    resize: vertical;
}

.lead-howto code {
    font-family: ui-monospace, Menlo, Consolas, monospace;
    font-size: .92em;
}

.lead-howto .inline-form {
    margin: 0;
}

.lead-howto .btn-link {
    padding: 0;
    min-height: 0;
    border: 0;
    background: none;
    color: var(--danger, #b3261e);
    text-decoration: underline;
    cursor: pointer;
}

.order-source .cell-sub {
    display: block;
}

.order-marks {
    margin-top: 4px;
    font-size: var(--small, 12px);
    color: var(--muted, #8b8178);
}

.order-marks summary {
    cursor: pointer;
}

.order-marks dl {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    gap: 2px 10px;
    margin: 6px 0 0;
}

.order-marks dt {
    font-family: ui-monospace, Menlo, Consolas, monospace;
}

.order-marks dd {
    margin: 0;
    overflow-wrap: anywhere;
    color: var(--ink, #2b2622);
}

/* === Статистика рекламы ===
   Дописать в конец static/css/ordium.css. */

.report-filter {
    display: flex;
    flex-wrap: wrap;
    gap: 12px 24px;
    align-items: center;
    justify-content: space-between;
}

.report-periods {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.report-periods a {
    padding: 6px 12px;
    border: 1px solid var(--line, #eadfd6);
    border-radius: 999px;
    color: inherit;
    text-decoration: none;
    font-size: var(--small, 13px);
}

.report-periods a.is-active {
    background: var(--accent, #2f5d50);
    border-color: var(--accent, #2f5d50);
    color: var(--on-accent);
}

.report-controls {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: flex-end;
}

.report-controls label {
    display: flex;
    flex-direction: column;
    gap: 4px;
    font-size: var(--small, 13px);
    color: var(--muted, #8b8178);
}

.report-crumbs {
    margin: 4px 0 12px;
    font-size: var(--small, 13px);
}

.report-kpis {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 12px;
    margin: 16px 0;
}

.kpi {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 14px 16px;
    background: var(--surface, #fff);
    border: 1px solid var(--line, #eadfd6);
    border-radius: var(--r-panel, 10px);
}

.kpi-label {
    font-size: var(--small, 13px);
    color: var(--muted, #8b8178);
}

.kpi-value {
    font-size: 26px;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}

.kpi-sub {
    font-size: var(--small, 13px);
    color: var(--muted, #8b8178);
}

.is-negative {
    color: var(--danger, #b3261e);
}

.report-table {
    width: 100%;
    min-width: 1100px;
    font-variant-numeric: tabular-nums;
}

.report-table th, .report-table td {
    white-space: nowrap;
}

.report-table .report-key {
    max-width: 320px;
    overflow: hidden;
    text-overflow: ellipsis;
}

.report-table .report-key .cell-sub {
    display: block;
    font-family: ui-monospace, Menlo, Consolas, monospace;
}

.report-table tfoot th {
    border-top: 2px solid var(--line-strong, #d9cfc6);
}

/* --- Лендинги --- */
.code-field {
    width: 100%;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 12.5px;
    line-height: 1.45;
    tab-size: 4;
    white-space: pre;
    overflow: auto;
}

.lead-howto ol.hint {
    padding-left: 20px;
    display: grid;
    gap: 6px;
}

.lead-howto code {
    white-space: nowrap;
}

tr.is-archived td {
    opacity: .55;
}

/* --- Сортировка по колонкам ---------------------------------------------- */

th.sortable { padding: 0; }
th.sortable .sort-link {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 10px 14px;
    color: inherit;
    text-decoration: none;
}
th.sortable.num .sort-link { justify-content: flex-end; }
th.sortable .sort-link:hover { color: var(--ink); }
th.sortable.is-asc .sort-link, th.sortable.is-desc .sort-link { color: var(--ink); }
.sort-arrow { font-size: 11px; opacity: .35; }
th.sortable:hover .sort-arrow { opacity: .7; }
th.is-asc .sort-arrow, th.is-desc .sort-arrow { opacity: 1; color: var(--accent); }
/* --- Телефон в браузере: панель у пользователя и кнопки под телефоном ------ */

.phone-dock {
    display: flex;
    flex-direction: column;
    gap: 10px;
    font-size: 13px;
}

.phone-dock[hidden],
.phone-dock-back[hidden],
.call-controls[hidden] {
    display: none;
}

.phone-dot {
    flex: none;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--line-strong);
}

.phone-dock[data-status="ready"] .phone-dot { background: var(--success); }
.phone-dock[data-status="connecting"] .phone-dot,
.phone-dock[data-status="starting"] .phone-dot { background: var(--warn-line); }
.phone-dock[data-status="talking"] .phone-dot,
.phone-dock[data-status="dialing"] .phone-dot { background: var(--accent); animation: phone-pulse 1.4s infinite; }
.phone-dock[data-status="ringing"] .phone-dot { background: var(--warn-ink); animation: phone-pulse .8s infinite; }

.phone-dock-line {
    display: flex;
    align-items: center;
    gap: 9px;
    width: 100%;
    min-height: 30px;
    padding: 0 10px;
    font: inherit;
    color: var(--sidebar-muted);
    text-align: left;
    background: none;
    border: 0;
    border-radius: var(--r-control);
}

.phone-dock-line:not(:disabled) {
    cursor: pointer;
}

.phone-dock-line:not(:disabled):hover {
    color: var(--ink);
    background: var(--tint);
}

.phone-dock-line:disabled {
    opacity: 1;
    cursor: default;
}

/* Идёт звонок — карточка над пользователем */
.phone-dock[data-status="dialing"],
.phone-dock[data-status="ringing"],
.phone-dock[data-status="talking"] {
    padding: 14px 12px 12px;
    background: var(--surface);
    border-radius: var(--r-panel);
    box-shadow: 0 0 0 0.5px var(--ring), var(--shadow-sm);
}

.phone-dock-call {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
    padding: 0 2px;
}

.phone-dock-who {
    display: flex;
    flex: 1;
    flex-direction: column;
    min-width: 0;
    line-height: 1.3;
}

.phone-dock-name {
    overflow: hidden;
    font-size: 14px;
    font-weight: 600;
    color: var(--ink);
    white-space: nowrap;
    text-overflow: ellipsis;
}

.phone-dock-sub {
    font-size: 12px;
    color: var(--muted);
}

.phone-timer {
    flex: none;
    font-size: 15px;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    color: var(--ink);
}

/* В панели кнопки друг под другом, на всю ширину */
.phone-dock-actions {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.phone-dock-actions .phone-btn {
    flex: none;
    justify-content: flex-start;
    width: 100%;
    padding: 0 12px;
}

.phone-dock .phone-dock-back {
    justify-content: flex-start;
    padding: 0 12px;
}

/* Кнопки звонка — в одном формате с «К заказу»: значок и подпись */
.phone-btn,
.phone-dock-back {
    display: inline-flex;
    flex: 1;
    align-items: center;
    justify-content: center;
    gap: 6px;
    min-width: 0;
    height: 36px;
    padding: 0 10px;
    font: inherit;
    font-size: 13px;
    font-weight: 500;
    white-space: nowrap;
    border: 0;
    border-radius: var(--r-control);
    cursor: pointer;
}

.phone-btn {
    color: var(--ink);
    background: var(--tint);
}

.phone-btn svg,
.phone-dock-back svg {
    flex: none;
    width: 16px;
    height: 16px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.9;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.phone-btn-label {
    overflow: hidden;
    text-overflow: ellipsis;
}

.phone-btn:hover,
.phone-dock-back:hover {
    filter: brightness(0.96);
}

:root[data-theme="dark"] .phone-btn:hover,
:root[data-theme="dark"] .phone-dock-back:hover {
    filter: brightness(1.15);
}

@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) .phone-btn:hover,
    :root:not([data-theme="light"]) .phone-dock-back:hover {
        filter: brightness(1.15);
    }
}

.phone-btn:disabled {
    opacity: .5;
    filter: none;
    cursor: default;
}

.phone-btn.is-on {
    color: var(--warn-ink);
    background: var(--warn-soft);
}

.phone-btn.is-hangup {
    color: var(--danger);
    background: var(--danger-soft);
}

.phone-btn.is-answer {
    color: var(--accent-ink);
    background: var(--accent-soft);
}

.phone-dock-back {
    width: 100%;
    color: var(--accent-ink);
    background: var(--accent-soft);
}

/* Под телефоном в карточке: таймер и те же кнопки, по размеру подписи */
.call-controls {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    margin: 8px 0 2px;
}

.call-controls .phone-timer {
    min-width: 40px;
}

.call-controls .phone-btn {
    flex: none;
    height: 32px;
    padding: 0 8px;
}

@keyframes phone-pulse { 50% { opacity: .35; } }

/* Клавиатура: «Телефон в сети» → набрать номер вручную */
.phone-dock-icon {
    flex: none;
    width: 16px;
    height: 16px;
    margin-left: auto;
    fill: none;
    stroke: currentColor;
    stroke-width: 2.4;
    stroke-linecap: round;
    stroke-linejoin: round;
    opacity: .7;
}

.phone-keypad {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 12px;
    background: var(--surface);
    border-radius: var(--r-panel);
    box-shadow: 0 0 0 0.5px var(--ring), var(--shadow-sm);
}

.phone-keypad-input {
    width: 100%;
    height: 42px;
    padding: 0 10px;
    font: inherit;
    font-size: 19px;
    font-weight: 500;
    font-variant-numeric: tabular-nums;
    letter-spacing: .03em;
    text-align: center;
    color: var(--ink);
    background: var(--field);
    border: 0;
    border-radius: var(--r-control);
}

.phone-keypad-input::placeholder {
    font-weight: 400;
    color: var(--muted);
}

.phone-keypad-input:focus {
    outline: 2px solid var(--focus);
    outline-offset: 0;
}

.phone-keys {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 6px;
}

.phone-key {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 40px;
    padding: 0;
    font: inherit;
    font-size: 17px;
    font-weight: 500;
    color: var(--ink);
    background: var(--tint);
    border: 0;
    border-radius: var(--r-control);
    cursor: pointer;
}

.phone-key:hover {
    background: var(--surface-hover);
}

.phone-key:active {
    filter: brightness(0.92);
}

.phone-key svg {
    width: 20px;
    height: 20px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.8;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.phone-keypad-call {
    flex: none;
    width: 100%;
    height: 40px;
}

/* Свёрнутое меню: точка, таймер и кнопки-значки столбиком */
@media (min-width: 901px) {
    .app.is-collapsed .sidebar .phone-dock {
        position: relative;
    }

    .app.is-collapsed .sidebar .phone-dock-icon {
        display: none;
    }

    /* Клавиатура в свёрнутом меню — всплывает справа от полосы */
    .app.is-collapsed .sidebar .phone-keypad {
        position: absolute;
        bottom: 0;
        left: calc(100% + 14px);
        z-index: 80;
        width: 232px;
    }

    .app.is-collapsed .sidebar .phone-keypad .phone-btn-label {
        display: inline;
    }

    .app.is-collapsed .sidebar .phone-keypad .phone-keypad-call {
        width: 100%;
    }

    .app.is-collapsed .sidebar .phone-dock-text,
    .app.is-collapsed .sidebar .phone-dock-who,
    .app.is-collapsed .sidebar .phone-btn-label,
    .app.is-collapsed .sidebar .phone-dock-back span {
        display: none;
    }

    .app.is-collapsed .sidebar .phone-dock-line {
        justify-content: center;
        width: 44px;
        padding: 0;
    }

    .app.is-collapsed .sidebar .phone-dock[data-status="dialing"],
    .app.is-collapsed .sidebar .phone-dock[data-status="ringing"],
    .app.is-collapsed .sidebar .phone-dock[data-status="talking"] {
        align-items: center;
        width: 52px;
        padding: 8px 4px;
    }

    .app.is-collapsed .sidebar .phone-dock-call {
        flex-direction: column;
        gap: 6px;
        padding: 0;
    }

    .app.is-collapsed .sidebar .phone-dock-actions {
        flex-direction: column;
    }

    .app.is-collapsed .sidebar .phone-timer {
        font-size: 11px;
    }

    .app.is-collapsed .sidebar .phone-btn,
    .app.is-collapsed .sidebar .phone-dock-back {
        flex: none;
        justify-content: center;
        width: 36px;
        padding: 0;
    }
}
/* --- Аватары, команда, профиль ------------------------------------------------ */

.avatar {
    display: inline-flex;
    flex: none;
    align-items: center;
    justify-content: center;
    width: var(--avatar-size, 32px);
    height: var(--avatar-size, 32px);
    overflow: hidden;
    font-size: calc(var(--avatar-size, 32px) * 0.4);
    font-weight: 600;
    line-height: 1;
    color: #FFFFFF;
    object-fit: cover;
    border-radius: 50%;
}

.avatar-initials {
    background: hsl(var(--avatar-hue, 200) 42% 46%);
}

.avatar-initials.is-group {
    border-radius: 30%;
}

.user-link {
    display: flex;
    flex: 1;
    align-items: center;
    gap: 10px;
    min-width: 0;
    color: inherit;
    text-decoration: none;
    border-radius: var(--r-control);
}

.user-link:hover .user-name {
    color: var(--accent);
}

.nav-badge.is-chat {
    color: var(--on-accent);
    background: var(--accent);
}

.nav-badge[hidden] {
    display: none;
}

.team-search {
    width: min(360px, 100%);
}

.team-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 12px;
}

.person-card {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 14px;
    background: var(--surface);
    border-radius: var(--r-panel);
    box-shadow: 0 0 0 0.5px var(--ring), var(--shadow-sm);
}

.person-card[hidden] {
    display: none;
}

.person-card.is-inactive {
    opacity: .6;
}

.person-card-link {
    display: flex;
    flex: 1;
    align-items: center;
    gap: 12px;
    min-width: 0;
    color: inherit;
    text-decoration: none;
}

.person-card-text {
    display: flex;
    flex-direction: column;
    min-width: 0;
    line-height: 1.3;
}

.person-card-name {
    overflow: hidden;
    font-weight: 600;
    white-space: nowrap;
    text-overflow: ellipsis;
}

.person-card-link:hover .person-card-name {
    color: var(--accent);
}

.person-card-position,
.person-card-dept {
    overflow: hidden;
    font-size: var(--small);
    color: var(--muted);
    white-space: nowrap;
    text-overflow: ellipsis;
}

.person-me {
    font-size: 11px;
    font-weight: 500;
    color: var(--muted);
}

.person-card-chat {
    margin: 0;
}

.profile-head {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 20px;
}

.profile-head-text {
    flex: 1 1 260px;
    min-width: 0;
}

.profile-head-text h1 {
    margin: 0;
}

.profile-position {
    margin: 2px 0 0;
    font-size: 16px;
}

.profile-meta {
    margin: 4px 0 0;
    font-size: var(--small);
    color: var(--muted);
}

.profile-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.profile-actions form {
    margin: 0;
}

.profile-body {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 16px;
    margin-top: 16px;
}

.profile-section-title {
    margin: 0 0 10px;
    font-size: 16px;
    font-weight: 600;
}

.profile-about {
    margin: 0;
    white-space: normal;
    overflow-wrap: anywhere;
}

.profile-facts {
    display: grid;
    gap: 10px;
    margin: 0;
}

.profile-facts div {
    display: grid;
    grid-template-columns: 140px minmax(0, 1fr);
    gap: 10px;
}

.profile-facts dt {
    font-size: var(--small);
    color: var(--muted);
}

.profile-facts dd {
    margin: 0;
    overflow-wrap: anywhere;
}

.profile-photo {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 20px;
    margin-bottom: 12px;
}

/* --- Чат ------------------------------------------------------------------------ */

.chat {
    display: grid;
    grid-template-columns: 320px minmax(0, 1fr);
    height: calc(100dvh - var(--topbar) - 56px);
    min-height: 460px;
    overflow: hidden;
    background: var(--surface);
    border-radius: var(--r-panel);
    box-shadow: 0 0 0 0.5px var(--ring), var(--shadow-sm);
}

.chat-side {
    display: flex;
    flex-direction: column;
    min-height: 0;
    border-right: 1px solid var(--line);
}

.chat-side-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 14px 10px;
}

.chat-side-head h1 {
    margin: 0;
    font-size: 20px;
}

.chat-new {
    position: relative;
}

.chat-new-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.chat-new-btn svg,
.chat-back svg,
.chat-attach svg,
.chat-send svg,
.chat-file svg {
    width: 18px;
    height: 18px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.chat-menu {
    position: absolute;
    top: calc(100% + 6px);
    right: 0;
    z-index: 20;
    display: flex;
    flex-direction: column;
    min-width: 200px;
    padding: 6px;
    background: var(--surface);
    border-radius: var(--r-panel);
    box-shadow: 0 0 0 0.5px var(--ring), 0 10px 30px rgba(0, 0, 0, .15);
}

.chat-menu[hidden] {
    display: none;
}

.chat-menu button {
    padding: 9px 10px;
    font: inherit;
    color: var(--ink);
    text-align: left;
    background: none;
    border: 0;
    border-radius: var(--r-control);
    cursor: pointer;
}

.chat-menu button:hover {
    background: var(--tint);
}

.chat-search {
    margin: 0 14px 10px;
    width: auto;
}

.chat-list {
    flex: 1;
    min-height: 0;
    padding: 0 8px 10px;
    overflow-y: auto;
}

.chat-list-empty {
    padding: 20px 10px;
    font-size: var(--small);
    color: var(--muted);
    text-align: center;
}

.chat-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 8px;
    color: inherit;
    text-decoration: none;
    border-radius: var(--r-control);
}

.chat-item:hover {
    color: inherit;
    background: var(--tint);
}

.chat-item.is-active {
    background: var(--accent-soft);
}

.chat-item-body {
    display: flex;
    flex: 1;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.chat-item-top,
.chat-item-bottom {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
}

.chat-item-title {
    flex: 1;
    overflow: hidden;
    font-weight: 600;
    white-space: nowrap;
    text-overflow: ellipsis;
}

.chat-item-time {
    flex: none;
    font-size: 12px;
    color: var(--muted);
}

.chat-item-last {
    flex: 1;
    overflow: hidden;
    font-size: var(--small);
    color: var(--muted);
    white-space: nowrap;
    text-overflow: ellipsis;
}

.chat-item.is-unread .chat-item-last {
    color: var(--ink);
}

.chat-item-badge {
    flex: none;
    min-width: 20px;
    padding: 1px 6px;
    font-size: 11px;
    font-weight: 600;
    text-align: center;
    color: var(--on-accent);
    background: var(--accent);
    border-radius: 999px;
}

.chat-main {
    position: relative;
    display: flex;
    flex-direction: column;
    min-width: 0;
    min-height: 0;
    background: var(--bg);
}

.chat-main.is-drop::after {
    content: "Отпустите — файлы прикрепятся к сообщению";
    position: absolute;
    inset: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    color: var(--accent-ink);
    background: color-mix(in srgb, var(--accent-soft) 85%, transparent);
    border: 2px dashed var(--accent);
    border-radius: var(--r-panel);
}

.chat-empty {
    display: flex;
    flex: 1;
    align-items: center;
    justify-content: center;
    color: var(--muted);
}

.chat-head {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 16px;
    background: var(--surface);
    border-bottom: 1px solid var(--line);
}

.chat-back {
    display: none;
}

.chat-head-who {
    display: flex;
    flex: 1;
    align-items: center;
    gap: 10px;
    min-width: 0;
    color: inherit;
    text-decoration: none;
}

a.chat-head-who:hover .chat-head-title {
    color: var(--accent);
}

.chat-head-names {
    display: flex;
    flex-direction: column;
    min-width: 0;
    line-height: 1.3;
}

.chat-head-title {
    overflow: hidden;
    font-weight: 600;
    white-space: nowrap;
    text-overflow: ellipsis;
}

.chat-head-sub {
    font-size: var(--small);
    color: var(--muted);
}

.chat-feed {
    display: flex;
    flex: 1;
    flex-direction: column;
    gap: 2px;
    min-height: 0;
    padding: 14px 18px;
    overflow-y: auto;
}

.chat-feed-empty {
    margin: auto;
    color: var(--muted);
}

.chat-more {
    align-self: center;
    margin-bottom: 8px;
    padding: 6px 12px;
    font: inherit;
    font-size: var(--small);
    color: var(--muted);
    background: var(--surface);
    border: 0;
    border-radius: 999px;
    box-shadow: 0 0 0 0.5px var(--ring);
    cursor: pointer;
}

.chat-day {
    display: flex;
    justify-content: center;
    margin: 12px 0 8px;
}

.chat-day span {
    padding: 3px 10px;
    font-size: 12px;
    font-weight: 500;
    color: var(--muted);
    background: var(--surface);
    border-radius: 999px;
    box-shadow: 0 0 0 0.5px var(--ring);
}

.chat-system {
    align-self: center;
    margin: 6px 0;
    font-size: 12px;
    color: var(--muted);
    text-align: center;
}

.chat-msg {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    max-width: min(640px, 82%);
    margin-top: 8px;
}

.chat-msg.is-joined {
    margin-top: 2px;
}

.chat-msg.is-mine {
    align-self: flex-end;
}

.chat-msg-avatar {
    flex: none;
    width: 32px;
}

.chat-bubble {
    display: flex;
    flex-direction: column;
    gap: 6px;
    min-width: 0;
    padding: 8px 12px 6px;
    background: var(--surface);
    border-radius: 14px 14px 14px 4px;
    box-shadow: 0 0 0 0.5px var(--ring);
}

.chat-msg.is-joined .chat-bubble {
    border-radius: 14px 14px 14px 14px;
}

.chat-msg.is-mine .chat-bubble {
    background: var(--accent-soft);
    border-radius: 14px 14px 4px 14px;
    box-shadow: none;
}

.chat-author {
    font-size: 12px;
    font-weight: 600;
    color: var(--accent-ink);
}

.chat-text {
    font-size: 14px;
    line-height: 1.45;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}

.chat-text a {
    color: var(--accent-ink);
}

.chat-time {
    display: flex;
    align-items: center;
    align-self: flex-end;
    gap: 4px;
    font-size: 11px;
    color: var(--muted);
}

.chat-tick {
    letter-spacing: -2px;
}

.chat-tick.is-read {
    color: var(--accent);
}

.chat-images {
    display: grid;
    gap: 4px;
    max-width: 360px;
}

.chat-images.is-many {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.chat-image img {
    display: block;
    width: 100%;
    height: auto;
    max-height: 320px;
    object-fit: cover;
    border-radius: 10px;
}

.chat-images.is-many .chat-image img {
    aspect-ratio: 1;
}

.chat-file {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 200px;
    padding: 8px 10px;
    color: inherit;
    text-decoration: none;
    background: var(--tint);
    border-radius: 10px;
}

.chat-file:hover {
    color: inherit;
    filter: brightness(0.97);
}

.chat-file svg {
    flex: none;
    color: var(--accent);
}

.chat-file-meta {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.chat-file-name {
    overflow: hidden;
    font-weight: 500;
    white-space: nowrap;
    text-overflow: ellipsis;
}

.chat-file-size {
    font-size: 12px;
    color: var(--muted);
}

.chat-compose {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin: 0;
    padding: 10px 14px 14px;
    background: var(--surface);
    border-top: 1px solid var(--line);
}

.chat-compose.is-sending {
    opacity: .7;
}

.chat-compose-row {
    display: flex;
    align-items: flex-end;
    gap: 8px;
}

.chat-compose textarea {
    flex: 1;
    min-height: 40px;
    max-height: 160px;
    padding: 9px 12px;
    font: inherit;
    line-height: 1.4;
    resize: none;
    background: var(--field);
    border: 0;
    border-radius: 20px;
}

.chat-compose textarea:focus {
    outline: 2px solid var(--focus);
    outline-offset: 0;
}

.chat-attach {
    flex: none;
    width: 40px;
    height: 40px;
}

.chat-send {
    display: inline-flex;
    flex: none;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    padding: 0;
    color: var(--on-accent);
    background: var(--accent);
    border: 0;
    border-radius: 50%;
    cursor: pointer;
}

.chat-send:hover {
    filter: brightness(1.08);
}

.chat-send:disabled {
    opacity: .6;
    cursor: default;
}

.chat-pending {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.chat-pending[hidden] {
    display: none;
}

.chat-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    max-width: 260px;
    padding: 4px 4px 4px 8px;
    font-size: 12px;
    background: var(--tint);
    border-radius: 8px;
}

.chat-chip img {
    width: 28px;
    height: 28px;
    object-fit: cover;
    border-radius: 6px;
}

.chat-chip-name {
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
}

.chat-chip-size {
    flex: none;
    color: var(--muted);
}

.chat-chip-x {
    width: 22px;
    height: 22px;
    padding: 0;
    font-size: 16px;
    line-height: 1;
    color: var(--muted);
    background: none;
    border: 0;
    border-radius: 50%;
    cursor: pointer;
}

.chat-chip-x:hover {
    color: var(--ink);
    background: var(--tint);
}

.chat-dialog {
    width: min(460px, calc(100vw - 32px));
    padding: 0;
    color: var(--ink);
    background: var(--surface);
    border: 0;
    border-radius: var(--r-panel);
    box-shadow: 0 20px 60px rgba(0, 0, 0, .3);
}

.chat-dialog::backdrop {
    background: var(--overlay);
}

.chat-dialog-body {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin: 0;
    padding: 18px;
}

.chat-dialog-body h2 {
    margin: 0;
    font-size: 18px;
}

.chat-dialog-body .field {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.chat-dialog-body .field[hidden] {
    display: none;
}

.chat-dialog .chat-search {
    margin: 0;
}

.chat-people {
    display: flex;
    flex-direction: column;
    gap: 2px;
    max-height: 340px;
    overflow-y: auto;
}

.chat-people-title {
    margin: 10px 0 4px;
    font-size: 12px;
    font-weight: 600;
    color: var(--muted);
}

.chat-person {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 7px 8px;
    font: inherit;
    color: inherit;
    text-align: left;
    background: none;
    border: 0;
    border-radius: var(--r-control);
    cursor: pointer;
}

.chat-person:hover {
    background: var(--tint);
}

.chat-person[hidden] {
    display: none;
}

.chat-person-names {
    display: flex;
    flex: 1;
    flex-direction: column;
    min-width: 0;
    line-height: 1.3;
}

.chat-person-name {
    font-weight: 500;
}

.chat-person-pos {
    font-size: 12px;
    color: var(--muted);
}

.chat-person-x {
    flex: none;
}

.chat-leave {
    align-self: flex-start;
    margin-top: 10px;
    color: var(--danger);
}

@media (max-width: 900px) {
    .chat {
        grid-template-columns: minmax(0, 1fr);
        height: calc(100dvh - var(--topbar) - 32px);
    }

    .chat .chat-main {
        display: none;
    }

    .chat.is-open .chat-side {
        display: none;
    }

    .chat.is-open .chat-main {
        display: flex;
    }

    .chat-back {
        display: inline-flex;
    }

    .chat-msg {
        max-width: 92%;
    }
}

/* --- Панель чата справа --------------------------------------------------------- */

:root {
    --rail: 60px;
}

.app.has-rail {
    grid-template-columns: var(--sidebar) minmax(0, 1fr) var(--rail);
}

.chat-rail {
    position: sticky;
    top: 0;
    z-index: 72;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    height: 100vh;
    padding: 12px 0;
    background: var(--sidebar-bg);
    border-left: 1px solid var(--line);
}

.chat-rail-btn,
.chat-rail-chat {
    position: relative;
    display: inline-flex;
    flex: none;
    align-items: center;
    justify-content: center;
    width: 42px;
    height: 42px;
    padding: 0;
    color: var(--sidebar-muted);
    background: transparent;
    border: 0;
    border-radius: 12px;
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease;
}

.chat-rail-btn:hover,
.chat-rail-chat:hover {
    color: var(--text);
    background: color-mix(in srgb, var(--text) 7%, transparent);
}

.chat-rail-btn.is-active {
    color: var(--accent-ink);
    background: var(--accent-soft);
}

.chat-rail-btn svg {
    width: 22px;
    height: 22px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.chat-rail-chat {
    border-radius: 999px;
}

.chat-rail-chat .avatar {
    box-shadow: 0 0 0 2px transparent;
    transition: box-shadow 0.15s ease;
}

.chat-rail-chat.is-active .avatar {
    box-shadow: 0 0 0 2px var(--sidebar-bg), 0 0 0 4px var(--accent);
}

.chat-rail-badge,
.chat-rail-count {
    position: absolute;
    top: -2px;
    right: -4px;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    font-size: 11px;
    font-weight: 700;
    line-height: 18px;
    text-align: center;
    color: var(--on-accent);
    background: var(--accent);
    border: 2px solid var(--sidebar-bg);
    border-radius: 999px;
    box-sizing: content-box;
}

.chat-rail-badge[hidden] {
    display: none;
}

.chat-rail-list {
    display: flex;
    flex: 0 1 auto;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    min-height: 0;
    padding: 6px 0;
    overflow-y: auto;
    scrollbar-width: none;
    border-top: 1px solid var(--line);
}

.chat-rail-list:empty {
    display: none;
}

.chat-rail-new {
    border: 1px dashed var(--line-strong, var(--line));
    border-radius: 999px;
}

.chat-drawer {
    position: fixed;
    top: 0;
    right: var(--rail);
    bottom: 0;
    z-index: 70;
    width: min(420px, calc(100vw - var(--rail) - 24px));
    background: var(--surface);
    border-left: 1px solid var(--line);
    box-shadow: -16px 0 40px rgba(0, 0, 0, 0.14);
    transform: translateX(16px);
    opacity: 0;
    transition: transform 0.18s ease, opacity 0.18s ease;
}

.chat-drawer.is-visible {
    transform: none;
    opacity: 1;
}

.chat-drawer[hidden] {
    display: none;
}

.chat.is-panel {
    grid-template-columns: minmax(0, 1fr);
    height: 100%;
    min-height: 0;
    border-radius: 0;
    box-shadow: none;
}

.chat.is-panel .chat-side {
    border-right: 0;
}

.chat.is-panel .chat-main {
    display: none;
}

.chat.is-panel.is-open .chat-side {
    display: none;
}

.chat.is-panel.is-open .chat-main {
    display: flex;
}

.chat.is-panel .chat-back {
    display: inline-flex;
}

.chat.is-panel .icon-btn svg {
    width: 18px;
    height: 18px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.chat.is-panel .chat-head {
    gap: 6px;
    padding: 10px 10px 10px 8px;
}

.chat.is-panel .chat-side-title {
    margin: 0;
    font-size: 18px;
}

.chat.is-panel .chat-msg {
    max-width: 88%;
}

@media (min-width: 901px) {
    .app.is-collapsed.has-rail {
        grid-template-columns: var(--sidebar-collapsed) minmax(0, 1fr) var(--rail);
    }
}

@media (max-width: 900px) {
    .app.has-rail {
        grid-template-columns: minmax(0, 1fr);
    }

    .chat-rail,
    .chat-drawer {
        display: none;
    }
}

/* --- «В сети» ------------------------------------------------------------------- */

.avatar-wrap {
    position: relative;
    display: inline-flex;
    flex: none;
}

.presence-dot {
    position: absolute;
    right: 0;
    bottom: 0;
    display: none;
    width: 28%;
    max-width: 14px;
    min-width: 9px;
    aspect-ratio: 1;
    background: var(--success);
    border: 2px solid var(--presence-ring, var(--surface));
    border-radius: 50%;
}

.avatar-wrap.is-online .presence-dot {
    display: block;
}

.chat-rail .avatar-wrap {
    --presence-ring: var(--sidebar-bg);
}

.presence {
    font-size: var(--small);
    color: var(--muted);
}

.presence.is-online,
.chat-head-sub.is-online {
    color: var(--success);
}

.person-card .presence {
    display: block;
    margin-top: 2px;
}

.profile-presence {
    margin: 2px 0 0;
}

.chat-head-sub {
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
}

/* Своё сообщение, пока оно уходит на сервер, и не ушедшее */
.chat-msg.is-pending .chat-bubble {
    opacity: 0.75;
}

.chat-tick.is-pending {
    font-size: 11px;
    letter-spacing: 0;
}

.chat-msg.is-failed .chat-bubble {
    box-shadow: inset 0 0 0 1px var(--danger);
}

.chat-retry {
    margin-left: 6px;
    padding: 0;
    font: inherit;
    font-weight: 600;
    color: var(--danger);
    background: none;
    border: 0;
    cursor: pointer;
}

.chat-retry:hover {
    text-decoration: underline;
}

/* Пункт «Чат» в меню — только на телефоне: на компьютере есть панель справа */
@media (min-width: 901px) {
    .nav a.nav-chat {
        display: none;
    }
}

/* --- Эмодзи в чате ---------------------------------------------------------------- */

.chat-compose {
    position: relative;
}

.chat-emoji-btn svg {
    width: 20px;
    height: 20px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.chat-emoji-btn.is-active {
    color: var(--accent-ink);
    background: var(--accent-soft);
}

.chat-emoji {
    position: absolute;
    bottom: calc(100% + 6px);
    left: 10px;
    z-index: 25;
    width: min(340px, calc(100% - 20px));
    max-height: 300px;
    padding: 6px 8px 10px;
    overflow-y: auto;
    background: var(--surface);
    border-radius: var(--r-panel);
    box-shadow: 0 0 0 0.5px var(--ring), 0 10px 30px rgba(0, 0, 0, .18);
}

.chat-emoji[hidden] {
    display: none;
}

.chat-emoji-title {
    position: sticky;
    top: -6px;
    margin: 0;
    padding: 6px 4px 4px;
    font-size: 11px;
    font-weight: 600;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: .04em;
    background: var(--surface);
}

.chat-emoji-grid {
    display: grid;
    grid-template-columns: repeat(8, 1fr);
}

.chat-emoji-item {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 36px;
    padding: 0;
    font-size: 22px;
    line-height: 1;
    background: none;
    border: 0;
    border-radius: 8px;
    cursor: pointer;
}

.chat-emoji-item:hover,
.chat-emoji-item:focus-visible {
    background: var(--tint);
}

/* Сообщение из 1–3 эмодзи — крупно и без пузыря */
.chat-text.is-emoji {
    font-size: 38px;
    line-height: 1.15;
}

.chat-msg .chat-bubble.is-emoji {
    padding-inline: 4px;
    background: transparent;
    box-shadow: none;
}

/* --- Удаление заказа и корзина ---------------------------------------------------- */

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

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

.order-delete:not(:disabled) {
    color: var(--danger);
}

.order-delete-foot {
    gap: 8px;
}

#order-delete-dialog .modal-body p {
    margin: 0 0 14px;
}

.trash-table .cell-sub {
    display: block;
    font-size: var(--small);
    color: var(--muted);
}

.trash-actions {
    white-space: nowrap;
    text-align: right;
}

.trash-actions form {
    display: inline-block;
    margin: 0 0 0 6px;
}

.trash-purge {
    color: var(--danger);
}

/* --- Упаковка --------------------------------------------------------------------- */

.pack-find {
    display: flex;
    gap: 8px;
    max-width: 520px;
    margin-bottom: 16px;
}

.pack-find input {
    flex: 1;
    min-height: 44px;
    font-size: 18px;
    letter-spacing: .02em;
}

.pack-lanes {
    margin-bottom: 14px;
}

.pack-lanes a {
    padding: 8px 14px;
    font-size: 14px;
}

.pack-count {
    display: inline-block;
    min-width: 22px;
    margin-left: 4px;
    padding: 0 6px;
    font-size: 12px;
    font-weight: 600;
    text-align: center;
    color: var(--muted);
    background: var(--tint);
    border-radius: 999px;
}

.pack-lanes a.is-active .pack-count {
    color: var(--on-accent);
    background: var(--accent);
}

.pack-queue .id a {
    font-size: 16px;
    font-weight: 700;
}

.pack-waybill {
    font-variant-numeric: tabular-nums;
    letter-spacing: .03em;
}

.pack-head .pack-waybill {
    font-weight: 700;
    color: var(--ink);
}

.pack-note {
    margin-bottom: 14px;
    padding: 12px 16px;
    color: var(--muted);
}

.pack-list,
.pack-list ul {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin: 0;
    padding: 0;
    list-style: none;
}

.pack-list {
    max-width: 860px;
}

.pack-line {
    display: flex;
    align-items: stretch;
    gap: 14px;
    padding: 12px;
    background: var(--surface);
    border-radius: var(--r-panel);
    box-shadow: 0 0 0 0.5px var(--ring), var(--shadow-sm);
    transition: background .15s ease, box-shadow .15s ease;
}

.pack-line:hover {
    box-shadow: 0 0 0 1px var(--accent), var(--shadow-sm);
}

.pack-line label {
    display: flex;
    flex: 1;
    align-items: center;
    gap: 16px;
    min-width: 0;
    padding: 4px 6px;
    cursor: pointer;
}

.pack-line input[type="checkbox"] {
    flex: none;
    width: 28px;
    height: 28px;
}

.pack-photo {
    flex: none;
    width: 140px;
    height: 140px;
    padding: 0;
    overflow: hidden;
    background: var(--tint);
    border: 0;
    border-radius: 12px;
    cursor: zoom-in;
}

.pack-photo img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform .2s ease;
}

.pack-photo:hover img {
    transform: scale(1.05);
}

.pack-photo.is-empty {
    cursor: default;
}

.pack-name {
    display: flex;
    flex: 1;
    flex-direction: column;
    gap: 3px;
    min-width: 0;
}

.pack-code {
    align-self: flex-start;
    padding: 1px 8px;
    font-size: 14px;
    font-weight: 700;
    letter-spacing: .02em;
    color: var(--accent-ink);
    background: var(--accent-soft);
    border-radius: 6px;
}

.pack-title {
    font-size: 18px;
    font-weight: 600;
    line-height: 1.3;
}

.pack-variant {
    font-size: 16px;
    color: var(--ink);
    opacity: .75;
}

.pack-qty {
    flex: none;
    min-width: 64px;
    font-size: 26px;
    font-weight: 700;
    text-align: right;
    font-variant-numeric: tabular-nums;
}

.pack-qty.is-many {
    color: var(--danger);
}

.pack-line.is-done {
    background: color-mix(in srgb, var(--success) 12%, var(--surface));
    box-shadow: 0 0 0 1px color-mix(in srgb, var(--success) 45%, transparent);
}

.pack-line.is-done .pack-title {
    color: var(--muted);
    text-decoration: line-through;
}

.pack-bundle {
    padding: 12px;
    background: var(--tint);
    border-radius: var(--r-panel);
}

.pack-bundle-title {
    display: block;
    margin: 0 4px 10px;
    font-weight: 600;
}

.pack-bar {
    position: sticky;
    bottom: 12px;
    z-index: 5;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: flex-end;
    gap: 10px;
    max-width: 860px;
    margin-top: 16px;
    padding: 12px 14px;
    background: var(--surface);
    border-radius: var(--r-panel);
    box-shadow: 0 0 0 0.5px var(--ring), 0 10px 30px rgba(0, 0, 0, .14);
}

.pack-progress {
    flex: 1;
    font-weight: 600;
    color: var(--muted);
}

.pack-bar.is-ready .pack-progress {
    color: var(--success);
}

.pack-bar .btn {
    min-height: 44px;
    padding-inline: 18px;
    font-size: 15px;
}

.pack-stage {
    font-weight: 400;
    opacity: .8;
}

.pack-settings select,
.pack-settings input[type="text"] {
    min-width: 180px;
}

@media (max-width: 640px) {
    .pack-line {
        gap: 10px;
        padding: 8px;
    }

    .pack-line label {
        gap: 10px;
        padding: 2px;
    }

    .pack-photo {
        width: 88px;
        height: 88px;
    }

    .pack-qty {
        min-width: 44px;
        font-size: 22px;
    }

    .pack-stage {
        display: none;
    }
}

.pack-bar .btn:disabled {
    opacity: .4;
    cursor: not-allowed;
    filter: saturate(.4);
}

.trash-search {
    flex-wrap: wrap;
    gap: 8px;
}

.trash-search input[type="search"] {
    flex: 1;
    min-width: 240px;
}

/* Живая доска: карточка, которую только что поменял кто-то другой */
.kanban-card.is-live {
    animation: kanban-live 1.6s ease;
}

@keyframes kanban-live {
    0% { box-shadow: 0 0 0 2px var(--accent), var(--shadow-sm); }
    100% { box-shadow: 0 0 0 0 transparent, var(--shadow-sm); }
}

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

.notify {
    position: relative;
}

.notify-count {
    position: absolute;
    top: 2px;
    right: 1px;
    min-width: 16px;
    height: 16px;
    padding: 0 4px;
    font-size: 10px;
    font-weight: 700;
    line-height: 16px;
    text-align: center;
    color: #FFFFFF;
    background: var(--danger);
    border: 2px solid var(--bg);
    border-radius: 999px;
    box-sizing: content-box;
}

.notify-count[hidden] {
    display: none;
}

.notify-panel {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    z-index: 80;
    display: flex;
    flex-direction: column;
    width: min(380px, calc(100vw - 24px));
    max-height: min(520px, calc(100dvh - 90px));
    overflow: hidden;
    background: var(--surface);
    border-radius: var(--r-panel);
    box-shadow: 0 0 0 0.5px var(--ring), 0 14px 40px rgba(0, 0, 0, .18);
}

.notify-panel[hidden] {
    display: none;
}

.notify-head,
.notify-foot {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 14px;
}

.notify-head {
    border-bottom: 1px solid var(--line);
}

.notify-foot {
    font-size: var(--small);
    border-top: 1px solid var(--line);
}

.notify-all {
    padding: 0;
    font-size: var(--small);
    color: var(--accent-ink);
    background: none;
    border: 0;
    cursor: pointer;
}

.notify-list {
    flex: 1;
    overflow-y: auto;
}

.notify-empty {
    margin: 0;
    padding: 24px 18px;
    font-size: var(--small);
    color: var(--muted);
    text-align: center;
}

.notify-item {
    position: relative;
    display: flex;
    gap: 10px;
    padding: 10px 14px;
    color: inherit;
    text-decoration: none;
    border-bottom: 1px solid var(--line);
}

.notify-item:hover {
    background: var(--tint);
}

.notify-item.is-unread {
    background: color-mix(in srgb, var(--accent-soft) 55%, transparent);
}

.notify-item.is-unread::after {
    content: "";
    position: absolute;
    top: 16px;
    right: 12px;
    width: 8px;
    height: 8px;
    background: var(--accent);
    border-radius: 50%;
}

.notify-icon {
    display: inline-flex;
    flex: none;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    color: var(--accent-ink);
    background: var(--accent-soft);
    border-radius: 50%;
}

.notify-icon.is-activity_due {
    color: var(--danger);
    background: color-mix(in srgb, var(--danger) 14%, transparent);
}

.notify-icon svg {
    width: 16px;
    height: 16px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.notify-body {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
    padding-right: 14px;
}

.notify-title {
    font-weight: 600;
    line-height: 1.3;
}

.notify-text {
    overflow: hidden;
    font-size: var(--small);
    color: var(--muted);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

.notify-time {
    font-size: 11px;
    color: var(--muted);
}

.notify-settings {
    max-width: 640px;
}

.notify-kinds {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 8px;
}

.notify-kind {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
}

/* «@» в комментарии */
.mention-wrap {
    position: relative;
}

.mention-list {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    z-index: 30;
    display: flex;
    flex-direction: column;
    min-width: 260px;
    padding: 4px;
    background: var(--surface);
    border-radius: var(--r-control);
    box-shadow: 0 0 0 0.5px var(--ring), 0 10px 30px rgba(0, 0, 0, .16);
}

.mention-list[hidden] {
    display: none;
}

.mention-item {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    padding: 6px 10px;
    font: inherit;
    color: inherit;
    text-align: left;
    background: none;
    border: 0;
    border-radius: 6px;
    cursor: pointer;
}

.mention-item.is-active,
.mention-item:hover {
    background: var(--tint);
}

.mention-login {
    font-size: var(--small);
    color: var(--muted);
}

/* Беседа «без звука» */
.chat-mute svg,
.chat-muted-icon svg {
    width: 18px;
    height: 18px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.chat-mute.is-on {
    color: var(--muted);
    background: var(--tint);
}

.chat-muted-icon {
    display: inline-flex;
    margin-left: 6px;
    color: var(--muted);
    vertical-align: -3px;
}

.chat-muted-icon svg {
    width: 14px;
    height: 14px;
}

.chat-item.is-muted .chat-item-badge,
.chat-rail-count.is-muted {
    color: var(--ink);
    background: var(--tint);
}

/* --- Аналитика склада --- */
.stock-filter .report-controls input[type="search"] {
    min-width: 220px;
}

.stock-measure {
    display: inline-flex;
    margin: 0 0 12px;
    padding: 3px;
    gap: 2px;
    background: var(--muted-bg);
    border: 1px solid var(--line);
    border-radius: 999px;
}

.stock-measure a {
    padding: 5px 14px;
    border-radius: 999px;
    color: var(--muted);
    text-decoration: none;
    font-size: var(--small, 13px);
    font-weight: 500;
}

.stock-measure a.is-active {
    background: var(--surface);
    color: var(--ink);
    box-shadow: var(--shadow-sm);
}

.stock-table {
    min-width: 900px;
}

.stock-table .muted {
    color: var(--muted);
}

.days-pill {
    display: inline-block;
    min-width: 56px;
    padding: 2px 8px;
    border-radius: 999px;
    text-align: center;
    font-weight: 600;
    background: var(--muted-bg);
}

tr.level-low .days-pill {
    background: var(--danger-soft);
    color: var(--danger);
}

tr.level-watch .days-pill {
    background: var(--warn-soft);
    color: var(--warn-ink);
}

tr.level-ok .days-pill {
    background: var(--accent-soft);
    color: var(--accent-ink);
}

tr.level-idle td {
    color: var(--muted);
}
.tabs a.tab {
    text-decoration: none;
}

/* --- Карточка заказа: разделы, «Вид карточки», обязательные для стадии --- */
.record-side-tools {
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.card-view-btn svg {
    width: 18px;
    height: 18px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
}

.card-section + .card-section {
    margin-top: 6px;
}

.card-section-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    min-height: 0;
    margin: 6px 0 2px;
    padding: 8px 0;
    font-size: 12px;
    font-weight: 700;
    letter-spacing: .04em;
    text-transform: uppercase;
    color: var(--muted);
    background: transparent;
    border: 0;
    border-bottom: 1px solid var(--line-strong);
    border-radius: 0;
    cursor: pointer;
}

.card-section-head:hover {
    color: var(--ink);
    background: transparent;
}

.card-section-head svg {
    width: 16px;
    height: 16px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    transition: transform .15s;
}

.card-section-head[aria-expanded="false"] svg {
    transform: rotate(-90deg);
}

/* Строки разделены сверху: у пустой обёртки (нет накладной, не отгружен) лишней черты не будет */
.card-field .field-row {
    border-bottom: 0;
}

.record-fields > .card-field:has(.field-row) ~ .card-field .field-row {
    border-top: 1px solid var(--line);
}

.record-fields > .card-field:not(:has(.field-row)) {
    display: none;
}

.card-field.is-needed .field-row {
    margin: 0 -10px;
    padding-left: 10px;
    padding-right: 10px;
    background: var(--warn-soft);
    border-left: 3px solid var(--warn-ink);
    border-radius: 6px;
}

.card-fill {
    margin: 0 0 12px;
    padding: 10px 12px;
    font-size: var(--small);
    color: var(--warn-ink);
    background: var(--warn-soft);
    border: 1px solid var(--warn-line);
    border-radius: var(--r-control);
}

.card-view-dialog {
    width: min(440px, calc(100vw - 32px));
}

.card-view-dialog .modal-body {
    max-height: 60vh;
    overflow-y: auto;
}

.card-view-section {
    margin: 14px 0 6px;
    font-size: var(--small);
    color: var(--muted);
}

.card-view-dialog .modal-foot .spacer {
    flex: 1;
}

/* --- Плашка доски: клиент, телефон, свои строки --- */
.kanban-card-client {
    display: flex;
    flex-direction: column;
    gap: 1px;
    min-width: 0;
    font-size: var(--small);
}

.kanban-card-client .kanban-card-customer {
    flex: none;
    color: var(--ink);
    font-weight: 500;
}

.kanban-card-phone {
    position: relative;
    z-index: 1;
    overflow: hidden;
    color: var(--muted);
    font-variant-numeric: tabular-nums;
    text-overflow: ellipsis;
    white-space: nowrap;
}

a.kanban-card-phone {
    text-decoration: none;
}

.kanban-card-lines {
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 0;
    font-size: 12px;
    line-height: 1.35;
}

.kanban-line {
    display: flex;
    gap: 6px;
    min-width: 0;
}

.kanban-line.is-person {
    flex-direction: column;
    gap: 3px;
}

.kanban-line-label {
    flex: none;
    color: var(--muted);
}

.kanban-line-value {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: var(--ink);
}

.kanban-person {
    position: relative;
    z-index: 1;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    max-width: 100%;
    min-width: 0;
    color: var(--ink);
    font-size: var(--small);
    text-decoration: none;
}

.kanban-person span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.kanban-person:hover span {
    color: var(--accent);
    text-decoration: underline;
}

.kanban-card-foot {
    justify-content: flex-end;
}

/* --- Настройки → Карточка заказа --- */
.layout-pipelines {
    margin-bottom: 8px;
}

.layout-own {
    margin-left: 4px;
    padding: 0 6px;
    font-size: 11px;
    border-radius: 999px;
    background: var(--accent-soft);
    color: var(--accent-ink);
}

.report-periods a.is-active .layout-own {
    background: rgba(255, 255, 255, .25);
    color: inherit;
}

.layout-intro {
    margin: 0 0 16px;
}

.layout-editor {
    display: grid;
    gap: 16px;
}

.layout-editor h2 {
    margin: 0 0 4px;
}

.layout-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 12px;
}

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

.layout-section {
    padding: 10px;
    background: var(--bg);
    border: 1px solid var(--line);
    border-radius: var(--r-panel);
}

.layout-hidden {
    margin-top: 12px;
    border-style: dashed;
}

.layout-section-head {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
}

.layout-title {
    flex: 1 1 140px;
    font-weight: 600;
}

.layout-remove {
    font-size: var(--small);
}

.layout-fields {
    display: grid;
    gap: 4px;
    min-height: 40px;
    margin: 0;
    padding: 0;
    list-style: none;
}

.layout-fields.is-empty::after {
    content: 'Перетащите сюда поля';
    padding: 10px;
    font-size: var(--small);
    color: var(--muted);
    text-align: center;
    border: 1px dashed var(--line-strong);
    border-radius: var(--r-control);
}

.layout-field {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 8px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--r-control);
    cursor: grab;
}

.layout-field.is-dragging {
    opacity: .5;
}

.layout-grip {
    color: var(--muted);
    letter-spacing: -2px;
    user-select: none;
}

.layout-field-name {
    flex: 1;
    min-width: 0;
}

.layout-tag {
    padding: 0 6px;
    font-size: 11px;
    color: var(--muted);
    border: 1px solid var(--line);
    border-radius: 999px;
}

.layout-eye {
    width: auto;
    height: auto;
    padding: 2px 6px;
    font-size: 12px;
}

.layout-check {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: var(--small);
    cursor: pointer;
}

.layout-kanban {
    max-width: 420px;
}

.layout-required th, .layout-required td {
    white-space: nowrap;
}

.layout-required .layout-cell {
    text-align: center;
}

.layout-stage {
    text-align: center;
}

.layout-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    margin-right: 6px;
    border-radius: 50%;
    background: var(--stage);
}

.layout-actions {
    position: sticky;
    bottom: 0;
    z-index: 5;
    display: flex;
    gap: 8px;
    padding: 12px 0;
    background: var(--bg);
    border-top: 1px solid var(--line);
}

/* --- Роботы и триггеры --- */
.robot-pipelines {
    margin-bottom: 14px;
}

.robot-failed {
    display: inline-block;
    min-width: 18px;
    margin-left: 4px;
    padding: 0 5px;
    font-size: 11px;
    color: var(--on-danger, #fff);
    background: var(--danger);
    border-radius: 999px;
}

.robot-board {
    display: flex;
    gap: 12px;
    padding-bottom: 12px;
    overflow-x: auto;
    align-items: flex-start;
}

.robot-column {
    flex: 0 0 260px;
    padding: 10px;
    background: var(--muted-bg);
    border: 1px solid var(--line);
    border-top: 3px solid var(--stage);
    border-radius: var(--r-panel);
}

.robot-column-head {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 10px;
    font-weight: 600;
}

.robot-dot {
    width: 9px;
    height: 9px;
    border-radius: 50%;
    background: var(--stage);
}

.robot-group {
    display: grid;
    gap: 6px;
    margin-bottom: 12px;
}

.robot-group-title {
    font-size: 11px;
    font-weight: 700;
    letter-spacing: .05em;
    text-transform: uppercase;
    color: var(--muted);
}

.robot-card {
    display: grid;
    gap: 2px;
    padding: 8px 10px;
    color: var(--ink);
    text-decoration: none;
    background: var(--surface);
    border: 1px solid var(--line);
    border-left: 3px solid var(--accent);
    border-radius: var(--r-control);
    font-size: var(--small);
}

.robot-card.is-trigger {
    border-left-color: var(--warn-ink);
}

.robot-card:hover {
    border-color: var(--line-strong);
    box-shadow: var(--shadow-sm);
}

.robot-card.is-off {
    opacity: .55;
}

.robot-kind, .robot-sum, .robot-cond {
    color: var(--muted);
    overflow-wrap: anywhere;
}

.robot-when {
    justify-self: start;
    padding: 0 6px;
    font-size: 11px;
    background: var(--accent-soft);
    color: var(--accent-ink);
    border-radius: 999px;
}

.robot-tag {
    justify-self: start;
    padding: 0 6px;
    font-size: 11px;
    border: 1px solid var(--line);
    border-radius: 999px;
    color: var(--muted);
}

.robot-add summary {
    padding: 6px 8px;
    font-size: var(--small);
    color: var(--accent);
    border: 1px dashed var(--line-strong);
    border-radius: var(--r-control);
    cursor: pointer;
    list-style: none;
}

.robot-add summary::-webkit-details-marker {
    display: none;
}

.robot-menu {
    display: grid;
    margin-top: 4px;
    padding: 4px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--r-control);
    box-shadow: var(--shadow-card);
}

.robot-menu a {
    padding: 6px 8px;
    color: var(--ink);
    text-decoration: none;
    font-size: var(--small);
    border-radius: 6px;
}

.robot-menu a:hover {
    background: var(--hover);
}

.robot-form .panel {
    margin-bottom: 14px;
}

.robot-delay {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
}

.robot-delay input {
    width: 90px;
}

.robot-conditions {
    display: grid;
    gap: 8px;
}

.robot-condition {
    display: grid;
    grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr) minmax(0, 1.4fr);
    gap: 8px;
}

@media (max-width: 640px) {
    .robot-condition {
        grid-template-columns: 1fr;
    }
}

.robot-hook {
    width: 100%;
    font-family: ui-monospace, Menlo, Consolas, monospace;
    font-size: 12.5px;
}

.robot-delete {
    margin-left: auto;
    color: var(--danger);
}

.run-done { color: var(--success); }
.run-failed { color: var(--danger); font-weight: 600; }
.run-skipped, .run-pending { color: var(--muted); }

/* --- Курьер Кишинёв --- */
.courier-ready {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 14px;
    background: var(--accent-soft);
    border-color: var(--accent);
}

.courier-table {
    min-width: 820px;
}

.courier-history ul {
    margin: 0;
    padding-left: 18px;
    display: grid;
    gap: 4px;
    font-size: var(--small);
}

/* --- Модули --- */
.module-list {
    display: grid;
    gap: 8px;
    margin-top: 12px;
}

.module-row {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 12px 14px;
    border: 1px solid var(--line);
    border-radius: var(--r-control);
    cursor: pointer;
}

.module-row:hover {
    border-color: var(--line-strong);
}

.module-row:has(input:checked) {
    background: var(--accent-soft);
    border-color: var(--accent);
}

.module-row input {
    margin-top: 3px;
    flex: none;
}

.module-text {
    display: grid;
    gap: 2px;
}

/* --- Карточка: активные заказы клиента, кто открывал --- */
.record-aside {
    display: grid;
    gap: 16px;
    align-content: start;
    min-width: 0;
}

.card-extra-title {
    margin: 0 0 8px;
    font-size: 15px;
    font-weight: 600;
    cursor: default;
}

details.card-extra > summary {
    cursor: pointer;
    list-style: none;
    margin: 0;
}

details.card-extra[open] > summary {
    margin-bottom: 8px;
}

.card-extra-list {
    display: grid;
    gap: 8px;
    margin: 0 0 6px;
    padding: 0;
    list-style: none;
    font-size: var(--small);
}

.card-extra-list li {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 2px 8px;
}

.card-extra-list .cell-sub {
    flex-basis: 100%;
}

.stage-chip {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-size: 12px;
    color: var(--muted);
}

.stage-chip::before {
    content: '';
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--stage);
}

/* --- Аналитика звонков --- */
.calls-title {
    margin: 0;
    padding: 14px 16px 10px;
    font-size: 16px;
}

.calls-title.is-flat {
    padding: 0 0 10px;
}

.calls-title .muted {
    font-size: var(--small);
    font-weight: 400;
}

.calls-table {
    min-width: 760px;
}

.calls-hint {
    padding: 0 16px 14px;
}

.panel.is-flush + .panel {
    margin-top: 16px;
}

.calls-heat {
    border-collapse: separate;
    border-spacing: 3px;
    font-size: 11px;
    font-variant-numeric: tabular-nums;
}

.calls-heat th {
    padding: 0 4px;
    color: var(--muted);
    font-weight: 500;
    text-align: center;
}

.calls-heat td {
    width: 30px;
    min-width: 30px;
    height: 26px;
    padding: 0;
    text-align: center;
    border-radius: 4px;
    color: var(--ink);
    background: color-mix(in srgb, var(--accent) var(--heat, 0%), var(--muted-bg));
}

.calls-heat td.has-missed {
    box-shadow: inset 0 0 0 1.5px var(--danger);
}

.active-orders {
    width: 100%;
}

.customer-filter {
    display: flex;
    flex-wrap: wrap;
    gap: 12px 24px;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
}


/* --- Товары: список, плитка, карточка ---------------------------------- */

.product-toolbar {
    align-items: flex-start;
}

.product-toolbar .search-filter {
    flex: 1 1 320px;
}

.product-toolbar-right {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    margin-left: auto;
}

.column-picker {
    position: relative;
}

.column-picker > summary {
    list-style: none;
    cursor: pointer;
}

.column-picker > summary::-webkit-details-marker {
    display: none;
}

.column-picker-pop {
    position: absolute;
    top: calc(100% + 6px);
    right: 0;
    z-index: 30;
    display: flex;
    flex-direction: column;
    gap: 6px;
    min-width: 270px;
    max-height: 70vh;
    overflow: auto;
    padding: 12px 14px;
    background: var(--surface);
    border: 1px solid var(--line-strong);
    border-radius: var(--r-panel, 10px);
    box-shadow: 0 10px 30px rgba(0, 0, 0, .14);
}

.column-picker-pop .check {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    cursor: pointer;
}

.column-picker-title {
    margin: 4px 0 0;
    font-size: var(--small, 13px);
    font-weight: 600;
    color: var(--muted);
}

.column-picker-actions .btn {
    white-space: nowrap;
}

.column-picker-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding-top: 8px;
    margin-top: 4px;
    border-top: 1px solid var(--line);
}

.variant-toggle {
    min-height: 0;
    padding: 1px 6px;
    margin-left: 2px;
    font-size: var(--small, 13px);
    color: var(--accent);
    background: transparent;
    border: 0;
    border-radius: 4px;
}

.variant-toggle:hover {
    background: var(--accent-soft);
}

.variant-toggle-arrow {
    display: inline-block;
    transition: transform .15s;
}

.variant-toggle[aria-expanded="true"] .variant-toggle-arrow {
    transform: rotate(90deg);
}

.product-table tr.variant td:first-child {
    box-shadow: inset 3px 0 0 var(--accent-soft);
}

.product-sort {
    display: flex;
    flex-wrap: wrap;
    gap: 4px 12px;
    margin: -4px 0 12px;
    font-size: var(--small, 13px);
    color: var(--muted);
}

.product-sort a {
    color: var(--muted);
    text-decoration: none;
}

.product-sort a:hover,
.product-sort a.is-active {
    color: var(--accent);
}

.product-sort a.is-active {
    font-weight: 600;
}

.product-tiles {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 14px;
}

.product-tile {
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--r-panel, 10px);
    transition: border-color .15s, box-shadow .15s;
}

.product-tile:hover {
    border-color: var(--line-strong);
    box-shadow: 0 6px 18px rgba(0, 0, 0, .08);
}

.product-tile.is-archived {
    opacity: .6;
}

.product-tile-photo {
    position: relative;
    display: block;
    aspect-ratio: 1 / 1;
    background: var(--surface-hover);
    border-bottom: 1px solid var(--line);
}

.product-tile-photo img,
.product-tile-photo .thumb-empty {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.product-tile-kind {
    position: absolute;
    top: 8px;
    left: 8px;
    padding: 2px 8px;
    font-size: 12px;
    font-weight: 600;
    color: var(--accent-ink);
    background: var(--accent-soft);
    border-radius: 999px;
}

.product-tile-body {
    display: flex;
    flex: 1;
    flex-direction: column;
    gap: 4px;
    padding: 10px 12px 12px;
}

.product-tile-name {
    display: -webkit-box;
    overflow: hidden;
    font-weight: 600;
    line-height: 1.3;
    color: var(--ink);
    text-decoration: none;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

.product-tile-name:hover {
    color: var(--accent);
}

.product-tile-sub {
    font-size: var(--small, 13px);
    color: var(--muted);
}

.product-tile-price {
    margin-top: 2px;
    font-size: 17px;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}

.product-tile-stock {
    display: flex;
    flex-wrap: wrap;
    gap: 2px 10px;
    font-size: var(--small, 13px);
    color: var(--muted);
}

.product-tile-variants {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    padding: 6px 0 0;
    margin: 4px 0 0;
    list-style: none;
    border-top: 1px dashed var(--line);
}

.product-tile-variants a {
    display: inline-block;
    max-width: 100%;
    overflow: hidden;
    padding: 1px 7px;
    font-size: 12px;
    color: var(--ink);
    text-decoration: none;
    text-overflow: ellipsis;
    white-space: nowrap;
    background: var(--surface-hover);
    border: 1px solid var(--line);
    border-radius: 999px;
}

.product-tile-variants a:hover {
    border-color: var(--accent);
}

.product-tile-variants a b {
    font-weight: 600;
    color: var(--accent);
}

.product-tile-variants a.is-out b {
    color: var(--danger, #b3261e);
}

.product-tile-variants a.is-archived {
    opacity: .55;
}

.product-head {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 16px;
    margin: 6px 0 4px;
}

.product-head-photo {
    flex: none;
    width: 96px;
    height: 96px;
    overflow: hidden;
    background: var(--surface-hover);
    border: 1px solid var(--line);
    border-radius: var(--r-panel, 10px);
}

.product-head-photo img,
.product-head-photo .thumb-empty {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.product-head-main {
    flex: 1 1 260px;
    min-width: 0;
}

.product-head-main h1 {
    margin: 0 0 6px;
}

.product-head-variant {
    font-weight: 500;
    color: var(--muted);
}

.product-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin: 0;
}

.product-tag {
    padding: 2px 10px;
    font-size: 13px;
    color: var(--muted);
    background: var(--muted-bg);
    border-radius: 999px;
}

.product-tag.is-ok {
    color: var(--accent-ink);
    background: var(--accent-soft);
}

.product-tag.is-muted {
    color: var(--danger, #b3261e);
}

.product-kpis .kpi-value {
    font-size: 22px;
}

.product-kpis .kpi-value a {
    color: inherit;
}

.kpi-slash {
    margin: 0 4px;
    color: var(--muted);
    font-weight: 400;
}

.record-fields.product-fields {
    display: grid;
    grid-template-columns: minmax(140px, 220px) minmax(0, 1fr);
    gap: 10px 20px;
    max-width: 760px;
    margin: 0;
}

.record-fields.product-fields dt,
.record-fields.product-fields dd {
    margin: 0;
}

@media (max-width: 720px) {
    .product-toolbar-right {
        margin-left: 0;
    }

    .product-tiles {
        grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
        gap: 10px;
    }

    .product-head-photo {
        width: 72px;
        height: 72px;
    }
}


/* --- Приёмка возвратов --------------------------------------------------------- */

.return-find {
    flex-wrap: wrap;
    align-items: center;
    max-width: 760px;
}

.return-find input[name="q"] {
    flex: 1 1 280px;
}

.return-auto {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 14px;
    color: var(--muted);
    cursor: pointer;
}

.return-result {
    display: flex;
    flex-direction: column;
    gap: 12px;
    max-width: 900px;
    margin-bottom: 18px;
}

.return-banner {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 4px 12px;
    padding: 12px 16px;
    font-size: 15px;
    border: 1px solid var(--line);
    border-radius: var(--r-panel, 10px);
}

.return-banner strong {
    font-size: 16px;
}

.return-banner.is-ok {
    color: var(--accent-ink);
    background: var(--accent-soft);
    border-color: var(--accent);
}

.return-banner.is-warn {
    color: var(--warn-ink);
    background: var(--warn-soft);
    border-color: var(--warn-line);
}

.return-banner.is-error {
    color: var(--danger);
    background: var(--danger-soft);
    border-color: var(--danger-line);
}

.return-card {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.return-card-head {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
}

.return-card-head h2 {
    margin: 0 0 4px;
    font-size: 22px;
}

.return-card-head .page-sub {
    margin: 2px 0 0;
}

.return-check-hint {
    margin: 0;
    color: var(--muted);
}

.return-accept {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
    padding-top: 12px;
    border-top: 1px solid var(--line);
}

.return-accept input[name="comment"] {
    flex: 1 1 260px;
}

.return-incomplete {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 14px;
    cursor: pointer;
}

.return-go {
    min-height: 44px;
    margin-left: auto;
    font-size: 16px;
}


/* --- Сверка выплат Nova Post ---------------------------------------------------- */

.payout-upload {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 12px;
    margin-bottom: 16px;
}

.payout-upload .hint {
    flex-basis: 100%;
    margin: 0;
}

.payout-file {
    display: flex;
    flex: 1 1 320px;
    flex-direction: column;
    gap: 6px;
    font-size: var(--small, 13px);
    color: var(--muted);
}

.payout-chips {
    margin-bottom: 14px;
}

.payout-tag {
    display: inline-block;
    padding: 2px 9px;
    font-size: 12px;
    font-weight: 600;
    line-height: 1.5;
    color: var(--muted);
    background: var(--muted-bg);
    border-radius: 999px;
}

.payout-tag.is-ok,
.payout-tag.is-moved {
    color: var(--accent-ink);
    background: var(--accent-soft);
}

.payout-tag.is-warn,
.payout-tag.is-mismatch,
.payout-tag.is-duplicate {
    color: var(--warn-ink);
    background: var(--warn-soft);
}

.payout-tag.is-returned,
.payout-tag.is-missing,
.payout-tag.is-failed {
    color: var(--danger);
    background: var(--danger-soft);
}

.payout-row.is-mismatch td,
.payout-row.is-duplicate td {
    background: var(--warn-soft);
}

.payout-row.is-returned td,
.payout-row.is-missing td,
.payout-row.is-failed td {
    background: var(--danger-soft);
}

.payout-row.is-moved td,
.payout-row.is-linked td {
    color: var(--muted);
}

.payout-force {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
}

.payout-bar {
    max-width: none;
    padding: 10px 14px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--r-panel, 10px);
    box-shadow: 0 6px 20px rgba(0, 0, 0, .08);
}

.payout-settings-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 16px;
    margin: 16px 0;
}

.payout-settings-grid label {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

/* --- Клиенты: массовые действия; списки обзвона ------------------------------------ */

.bulk-confirm {
    display: flex;
    flex-direction: column;
    gap: 12px;
    max-width: 760px;
}

.bulk-confirm > .btn {
    align-self: flex-start;
}

.bulk-confirm-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 12px;
}

.bulk-operators {
    margin: 0;
    padding: 10px 14px;
    border: 1px solid var(--line);
    border-radius: var(--r-control);
}

.bulk-operators legend {
    padding: 0 4px;
    font-size: var(--small, 13px);
    font-weight: 600;
    color: var(--muted);
}

.bulk-operators ul,
.bulk-operators > div {
    display: flex;
    flex-wrap: wrap;
    gap: 6px 16px;
    margin: 0;
    padding: 0;
    list-style: none;
}

.bulk-operators label {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 14px;
}

.bulk-preview ul {
    margin: 8px 0 0;
    padding-left: 18px;
    font-size: 14px;
    columns: 2 260px;
}

.calllists {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 14px;
}

.calllist-card {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin: 0;
}

.calllist-card-head {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.calllist-name {
    font-size: 17px;
    font-weight: 700;
    color: var(--ink);
    text-decoration: none;
}

.calllist-name:hover {
    color: var(--accent);
}

.calllist-progress {
    height: 6px;
    overflow: hidden;
    background: var(--muted-bg);
    border-radius: 999px;
}

.calllist-progress.is-big {
    height: 8px;
    margin: -4px 0 16px;
}

.calllist-progress span {
    display: block;
    height: 100%;
    background: var(--accent);
    border-radius: 999px;
}

.calllist-numbers {
    margin: 0;
    font-size: 14px;
}

.calllist-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: auto;
}

.calllist-result {
    display: inline-block;
    padding: 2px 9px;
    font-size: 12px;
    font-weight: 600;
    color: var(--muted);
    background: var(--muted-bg);
    border-radius: 999px;
}

.calllist-result.is-ordered {
    color: var(--accent-ink);
    background: var(--accent-soft);
}

.calllist-result.is-callback,
.calllist-result.is-no_answer {
    color: var(--warn-ink);
    background: var(--warn-soft);
}

.calllist-result.is-unreachable,
.calllist-result.is-wrong,
.calllist-result.is-declined {
    color: var(--danger);
    background: var(--danger-soft);
}

.calllist-comment {
    max-width: 360px;
    font-size: 13px;
}

.calllist-settings {
    margin-top: 16px;
}

.calllist-settings form {
    display: flex;
    flex-direction: column;
    gap: 12px;
    max-width: 760px;
    margin-top: 12px;
}

.calllist-work {
    display: grid;
    grid-template-columns: minmax(0, 1.5fr) minmax(300px, 1fr);
    gap: 16px;
    align-items: start;
}

.calllist-client,
.calllist-side .panel {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin: 0;
}

.calllist-side {
    position: sticky;
    top: 16px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.calllist-client-head {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
}

.calllist-client-head h2 {
    margin: 0;
    font-size: 24px;
}

.calllist-phone {
    margin: 4px 0 0;
    font-size: 20px;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}

.calllist-phone a {
    color: var(--ink);
    text-decoration: none;
}

.calllist-call {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.calllist-call-btn {
    min-height: 44px;
    padding: 0 22px;
    font-size: 16px;
}

.calllist-sub {
    margin: 4px 0 0;
    font-size: 14px;
    font-weight: 700;
}

.calllist-history {
    padding: 10px 12px;
    font-size: 13px;
    color: var(--warn-ink);
    background: var(--warn-soft);
    border-radius: var(--r-control);
}

.calllist-order {
    display: grid;
    grid-template-columns: auto auto auto minmax(0, 1fr) auto;
    align-items: center;
    gap: 10px;
    padding: 8px 0;
    font-size: 14px;
    border-top: 1px solid var(--line);
}

.calllist-items {
    overflow: hidden;
    color: var(--muted);
    text-overflow: ellipsis;
    white-space: nowrap;
}

.calllist-script {
    font-size: 14px;
    background: var(--accent-soft);
}

.calllist-script p {
    margin: 0 0 6px;
}

.calllist-result-form textarea {
    width: 100%;
    resize: vertical;
}

.calllist-order-btn {
    min-height: 42px;
}

.calllist-buttons {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

.calllist-btn {
    min-height: 40px;
}

.calllist-btn.is-ordered {
    color: var(--accent-ink);
    background: var(--accent-soft);
    border-color: var(--accent);
}

.calllist-btn.is-declined,
.calllist-btn.is-wrong {
    color: var(--danger);
    border-color: var(--danger-line);
}

.calllist-btn.is-no_answer,
.calllist-btn.is-callback {
    color: var(--warn-ink);
    border-color: var(--warn-line);
}

.calllist-callback {
    display: flex;
    gap: 8px;
}

.calllist-callback input {
    flex: 1;
    min-width: 0;
}

.calllist-foot {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

@media (max-width: 900px) {
    .calllist-work {
        grid-template-columns: 1fr;
    }

    .calllist-side {
        position: static;
    }

    .calllist-order {
        grid-template-columns: auto auto 1fr;
    }

    .calllist-items {
        grid-column: 1 / -1;
        white-space: normal;
    }
}

/* --- Выкуп клиента и чёрный список ---------------------------------------------- */

.buyout {
    display: inline-flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 4px 8px;
    margin-left: 6px;
    font-size: var(--small, 13px);
    color: var(--muted);
    vertical-align: middle;
}

.field-view .buyout {
    display: flex;
    margin: 4px 0 0;
}

.buyout-flag {
    display: inline-block;
    padding: 1px 8px;
    font-size: 12px;
    font-weight: 700;
    line-height: 1.5;
    border-radius: 999px;
}

.buyout-flag.is-blacklist {
    color: #fff;
    background: var(--danger);
}

.buyout-flag.is-risky {
    color: var(--warn-ink);
    background: var(--warn-soft);
    border: 1px solid var(--warn-line);
}

.buyout-flag.is-good {
    color: var(--accent-ink);
    background: var(--accent-soft);
}

.kanban-card .buyout-flag {
    align-self: flex-start;
    margin: 2px 0;
    font-size: 11px;
}

td .buyout-flag {
    margin-left: 6px;
}

.blacklist-box {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-top: 16px;
    padding-top: 14px;
    border-top: 1px solid var(--line);
}

.blacklist-box p {
    margin: 0;
}

.blacklist-box.is-on {
    padding: 12px;
    color: var(--danger);
    background: var(--danger-soft);
    border: 1px solid var(--danger-line);
    border-radius: var(--r-control);
}

.blacklist-form {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.blacklist-form input {
    flex: 1 1 180px;
    min-width: 0;
}

.phone-dock-warn {
    display: block;
    font-size: 11px;
    font-weight: 700;
    color: var(--danger);
}

/* --- Сводка дня --------------------------------------------------------------- */

.summary-days {
    align-self: center;
}

.summary-kpis .kpi-value {
    font-size: 30px;
}

.summary-delta {
    display: flex;
    flex-wrap: wrap;
    gap: 2px 10px;
    margin-top: 2px;
    font-size: 12px;
    font-weight: 600;
}

.summary-delta .is-up {
    color: var(--success);
}

.summary-delta .is-down {
    color: var(--danger);
}

.summary-delta .is-same {
    color: var(--muted);
}

.summary-grid {
    display: grid;
    grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr);
    gap: 16px;
    margin-bottom: 16px;
}

.summary-grid .panel {
    margin: 0;
}

.summary-hours {
    display: grid;
    grid-template-columns: repeat(24, minmax(0, 1fr));
    align-items: end;
    gap: 3px;
    height: 150px;
    margin: 8px 0 4px;
}

.summary-hour {
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    height: 100%;
}

.summary-bar {
    display: block;
    min-height: 2px;
    background: var(--accent);
    border-radius: 4px 4px 0 0;
    opacity: .85;
}

.summary-hour:hover .summary-bar {
    opacity: 1;
}

.summary-hour-label {
    height: 16px;
    margin-top: 4px;
    font-size: 11px;
    text-align: center;
    color: var(--muted);
}

.summary-line {
    margin: 10px 0 0;
}

.summary-title {
    margin: 0 0 8px;
    font-size: 16px;
}

.summary-list {
    display: grid;
    grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr);
    gap: 10px 16px;
    margin: 0;
}

.summary-list dt {
    color: var(--muted);
}

.summary-list dd {
    margin: 0;
    text-align: right;
}

@media (max-width: 900px) {
    .summary-grid {
        grid-template-columns: 1fr;
    }

    .summary-list {
        grid-template-columns: 1fr;
    }

    .summary-list dd {
        margin-bottom: 6px;
        text-align: left;
    }
}

/* --- Компании ------------------------------------------------------------------- */

.company-add-contact {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 12px 16px;
    border-top: 1px solid var(--line);
}

.company-add-contact input {
    flex: 1 1 180px;
    min-width: 0;
}

.company-delete {
    margin-top: 16px;
    padding-top: 12px;
    border-top: 1px solid var(--line);
}

.export-intro {
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-width: 860px;
}

.export-intro p {
    margin: 0;
}

/* --- Страницы «нет доступа» / «не найдено» --- */

.unavailable {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    max-width: 560px;
    margin: 48px auto;
    padding: 32px 28px;
    text-align: center;
}

.unavailable h1 {
    margin: 4px 0;
    font-size: 22px;
}

.unavailable p {
    margin: 0;
}

.unavailable-icon {
    font-size: 40px;
}


/* --- Безопасность входа (accounts/two_factor.html) --------------------- */

.tf-steps {
    display: grid;
    gap: 14px;
    padding-left: 20px;
    margin: 0 0 12px;
}

.tf-qr {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 16px;
    margin-top: 10px;
}

/* QR читается только на белом — и в тёмной теме тоже */
.tf-qr img {
    padding: 8px;
    background: #fff;
    border-radius: 8px;
    max-width: 100%;
    height: auto;
}

.tf-secret {
    word-break: break-all;
    letter-spacing: .04em;
}

.tf-enable {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 8px;
}

.tf-enable input {
    width: 140px;
    font-size: 18px;
    letter-spacing: .15em;
}

.tf-actions {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 20px;
    margin-top: 12px;
}

.tf-code-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 6px 20px;
    padding-left: 24px;
    font-size: 16px;
}

.tf-fail {
    color: var(--danger, #c0392b);
}

.tf-agent {
    max-width: 280px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: var(--muted);
}

.tf-hint {
    padding: 0 16px 12px;
}


/* Журнал входов не должен раздвигать страницу на телефоне: таблица прокручивается внутри */
.tf-journal {
    min-width: 0;
    overflow: hidden;
}

@media (max-width: 640px) {
    .tf-agent-col {
        display: none;
    }
}


/* --- Пересчёт склада (orders/stock_count.html) -------------------------- */

.count-start,
.count-form {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 12px;
}

.count-start .field,
.count-form .field {
    margin: 0;
    flex: 1 1 200px;
}

.count-form input[name="quantity"] {
    font-variant-numeric: tabular-nums;
}

.count-entry .return-banner {
    margin-bottom: 12px;
}

.count-chosen {
    margin: 6px 0 0;
    font-weight: 600;
}

.count-matches {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin: 0 0 12px;
    padding: 0;
    list-style: none;
}

.count-short {
    color: var(--danger);
    font-weight: 600;
}

.count-extra {
    color: var(--accent);
    font-weight: 600;
}

.count-more {
    padding: 8px 16px;
}

.count-finish {
    margin-top: 16px;
}


/* Закупочные цены из Excel */
.cost-problems {
    margin: 0 16px 12px;
    padding: 10px 14px 10px 30px;
    border-radius: 8px;
    background: var(--danger-soft);
    color: var(--danger);
}
.cost-note,
.cost-apply {
    margin: 12px 16px 16px;
}
.cost-apply {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}
.cost-upload {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
}
.cost-upload input[type=file] {
    max-width: 100%;
}


/* Настройки → Адрес входа */
.subdomain-input {
    display: flex;
    align-items: stretch;
    max-width: 520px;
}
.subdomain-input input {
    flex: 1 1 auto;
    min-width: 0;
    border-radius: 0;
}
.subdomain-affix {
    display: flex;
    align-items: center;
    padding: 0 10px;
    border: 1px solid var(--line);
    background: var(--surface-2, var(--bg));
    color: var(--muted);
    font-size: var(--small);
    white-space: nowrap;
}
.subdomain-affix:first-child {
    border-right: 0;
    border-radius: 8px 0 0 8px;
}
.subdomain-affix:last-child {
    border-left: 0;
    border-radius: 0 8px 8px 0;
}
.subdomain-current {
    margin: 0 0 12px;
}
@media (max-width: 520px) {
    .subdomain-affix:first-child {
        display: none;
    }
    .subdomain-input input {
        border-radius: 8px 0 0 8px;
    }
}


/* Вход: выбор компании, если логин и пароль подошли в нескольких */
.login-choose {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin: 16px 0;
}
.login-choose-item {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 2px;
    width: 100%;
    padding: 12px 14px;
    text-align: left;
    height: auto;
}
.login-choose-item .muted {
    font-size: var(--small);
    font-weight: 400;
}
