/* ==========================================================================
   Глобинтех · theme «Технический» (design concept B)
   One stylesheet, linked by main.html after bootstrap 5.3 and after {% block header %}
   (so it also restyles the Selectr / Litepicker CSS of dashboard-main.html).
   Replaces main.css, dashboard.css and bd.css; the rules from them that still
   matter are folded in below (marked «from main.css» / «from dashboard.css» / «from bd.css»).
   Sibling of the printed КП (offers/print.html, print D «Компактный технический»):
   same navy / lavender / mauve palette, Fira Sans Condensed figures, tinted table head.
   ========================================================================== */

:root {
    /* print D palette */
    --gt-navy:   #26345f;   /* sidebar, primary, table-head text, figures */
    --gt-blue:   #32457f;   /* logo navy: hover of primary */
    --gt-navy-2: #3b4f8f;   /* active sidebar item */
    --gt-navy-3: #1d2849;   /* pressed / dropdown on navy */
    --gt-accent: #84507a;   /* mauve: field labels only (6.2:1 on white) */
    --gt-lav:    #b4abd9;   /* sidebar section labels (5.6:1 on navy) */
    --gt-ink:    #1c1e29;
    --gt-muted:  #5c596b;   /* 6.8:1 on white */
    --gt-line:   #c9c5d6;   /* grid lines */
    --gt-field:  #8f8aa6;   /* input borders (3.3:1, WCAG non-text) */
    --gt-zebra:  #f5f4f9;
    --gt-tint:   #e9e6f1;   /* table head, editor toolbar, chips */
    --gt-hover:  #dfe4f4;   /* row hover */
    --gt-green:  #2c6e49;   /* create / add (6.1:1 with white) */
    --gt-red:    #b42318;   /* delete (6.6:1) */

    --gt-ui:   'Fira Sans', system-ui, -apple-system, 'Segoe UI', Arial, sans-serif;
    --gt-cond: 'Fira Sans Condensed', 'Arial Narrow', Arial, sans-serif;

    --sidebar-width: 240px;
    --gt-control-h: 30px;

    /* spacing scale: every gap between blocks takes one of these (phones: the tighter set further down) */
    --gt-page-y: 13.5px;    /* page padding = .py-3 .px-4 of the page wrappers; standalone windows use the same */
    --gt-page-x: 20.25px;
    --gt-gap-xs: 4px;       /* label → field, rows of a short list */
    --gt-gap-btn: 6px;      /* neighbouring buttons, chips */
    --gt-gap-s: 8px;        /* heading → its table, action row → table, wrapped rows of a form */
    --gt-gap-m: 12px;       /* tabs → content, card ↔ card, comment ↔ info, head block → table */
    --gt-gap-l: 18px;       /* block → block: cards → tabs, table → action bar, comment → editors, editor ↔ editor */
    --gt-gap-xl: 24px;      /* above a section heading */

    /* bootstrap 5.3 tokens */
    --bs-body-font-family: var(--gt-ui);
    --bs-body-font-size: 13.5px;
    --bs-body-line-height: 1.45;
    --bs-body-color: var(--gt-ink);
    --bs-body-bg: #fff;
    --bs-emphasis-color: var(--gt-ink);
    --bs-secondary-color: var(--gt-muted);
    --bs-heading-color: var(--gt-navy);
    --bs-border-color: var(--gt-line);
    --bs-border-radius: 4px;
    --bs-border-radius-sm: 4px;
    --bs-border-radius-lg: 4px;
    --bs-primary: #26345f;
    --bs-primary-rgb: 38, 52, 95;
    --bs-link-color: #32457f;
    --bs-link-color-rgb: 50, 69, 127;
    --bs-link-hover-color: #26345f;
    --bs-link-hover-color-rgb: 38, 52, 95;
    --bs-focus-ring-color: rgba(38, 52, 95, .25);

    /* Litepicker */
    --litepicker-is-start-color-bg: #26345f;
    --litepicker-is-end-color-bg: #26345f;
    --litepicker-is-in-range-color: #e9e6f1;
    --litepicker-day-color-hover: #26345f;
    --litepicker-is-today-color: #84507a;
    --litepicker-button-prev-month-color-hover: #26345f;
    --litepicker-button-next-month-color-hover: #26345f;
}

/* 1rem = 13.5px (of the browser's 16px default): every bootstrap spacing,
   padding and rem-based size shrinks with it — density without touching markup. */
html { font-size: 84.375%; }
@media (min-width: 768px) { :root { scroll-padding-top: 4rem; } }   /* from bd.css */

body {
    margin: 0 !important;
    min-height: 100vh;
    overflow-x: hidden;                     /* from dashboard.css */
    font-variant-numeric: tabular-nums;
    -webkit-font-smoothing: antialiased;
}

hr { border-top-color: var(--gt-line); opacity: 1; }

/* ---------- headings ---------------------------------------------------- */

main.content h1,
main.content h1.fs-4,
body > h1.fs-4,                             /* standalone windows (rfq-review, rfq-response) */
body > .py-3 > h1.fs-4 {                    /* standalone: offer check */
    font-family: var(--gt-cond);
    font-size: 22px !important;
    font-weight: 600;
    line-height: 28px;
    letter-spacing: .005em;
    color: var(--gt-navy);
    margin: 0;
}
main.content h4 {
    font-family: var(--gt-cond);
    font-size: 13px;
    font-weight: 600;
    letter-spacing: .09em;
    text-transform: uppercase;
    color: var(--gt-navy);
}

/* ---------- sidebar (markup from projects/dashboard-main.html + common/menus.py) ----- */

nav.sidebar {
    --bs-dark-rgb: 38, 52, 95;              /* .bg-dark → logo navy */
    width: var(--sidebar-width);
    position: fixed; top: 0; bottom: 0; left: 0;   /* from dashboard.css */
    z-index: 100;
    font-size: 13.5px;
    outline: 0;                             /* tabindex=-1 for the phone slide-in */
}
nav.sidebar .sidebar-sticky {
    position: relative;
    height: 100vh;
    overflow-x: hidden;
    overflow-y: auto;
    padding: 14px 12px 12px !important;    /* was .p-3 */
}
nav.sidebar hr {
    border-top: 1px solid rgba(255, 255, 255, .14);
    margin: 12px 0;
}

/* brand + the strip toggle */
nav.sidebar .sidebar-head { gap: 6px; }
nav.sidebar .sidebar-brand {
    flex: 1;
    min-width: 0;
    gap: 10px;
    padding: 2px 4px;
}
nav.sidebar .brand-mark {
    width: 28px; height: 28px; flex: none;
    border-radius: 4px;
    background: #fff;
    padding: 3px;
}
nav.sidebar .sidebar-brand .fs-4 {
    font-family: var(--gt-cond);
    font-size: 19px !important;
    font-weight: 600;
    letter-spacing: .01em;
    line-height: 1;
}
nav.sidebar .sidebar-toggle {
    flex: none;
    width: 28px; height: 28px;
    align-items: center; justify-content: center;
    padding: 0;
    border: 0;
    border-radius: 4px;
    background: transparent;
    color: var(--gt-lav);
    font-size: 14px;
}
nav.sidebar .sidebar-toggle:hover { background: rgba(255, 255, 255, .08); color: #fff; }
nav.sidebar .sidebar-toggle:focus-visible { outline: 0; box-shadow: 0 0 0 2px var(--gt-lav); }
nav.sidebar .sidebar-head .btn-close { flex: none; padding: 9px; }   /* phone: a 32px tap target */

/* menu: the <ul> holds <span>/<a> straight from menus.py (no <li>) */
nav.sidebar .nav-pills {
    --bs-nav-link-padding-x: 10px;
    --bs-nav-link-padding-y: 5px;
    --bs-nav-link-font-size: 13.5px;
    --bs-nav-pills-border-radius: 4px;
    --bs-nav-pills-link-active-bg: var(--gt-navy-2);
    gap: 1px;
}
nav.sidebar .nav > .nav-link {
    --bs-white-rgb: 222, 226, 240;          /* .text-white → soft white, 9.4:1 */
    line-height: 18px;
    white-space: nowrap;                    /* from main.css */
}
nav.sidebar .nav > a.nav-link:hover { background-color: rgba(255, 255, 255, .07); }
nav.sidebar .nav > a.nav-link.active {
    --bs-white-rgb: 255, 255, 255;
    font-weight: 500;
    box-shadow: inset 3px 0 0 var(--gt-lav);
}
nav.sidebar .nav > a.nav-link:focus-visible { box-shadow: 0 0 0 2px var(--gt-lav); }

/* group label (template3): «Продажи», «Закупки» */
nav.sidebar .nav > span.nav-link {
    --bs-white-rgb: 180, 171, 217;          /* lavender, 5.6:1 on navy */
    padding: 14px 10px 4px;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: .11em;
    text-transform: uppercase;
    cursor: default;
}
nav.sidebar .nav > span.nav-link:first-child { padding-top: 2px; }

/* icons: every label starts 20px in, icons sit in that gutter (group, sub-item and single item alike) */
nav.sidebar .nav > .nav-link > i {
    display: inline-block;
    width: 20px;
    font-size: 13px;
    vertical-align: -1px;
}
nav.sidebar .nav > span.nav-link > i { font-size: 12px; }

/* the single items (Склад … Метки) form their own group */
nav.sidebar .nav > a.nav-sub + a.nav-link:not(.nav-sub) { margin-top: 13px; position: relative; overflow: visible; }
nav.sidebar .nav > a.nav-sub + a.nav-link:not(.nav-sub)::before {
    content: ''; position: absolute; left: 10px; right: 10px; top: -7px;
    border-top: 1px solid rgba(255, 255, 255, .14);
}

/* «Реквизиты» (btn-warning): outlined lavender on navy */
nav.sidebar .btn-warning {
    --bs-btn-color: #fff;
    --bs-btn-bg: transparent;
    --bs-btn-border-color: rgba(180, 171, 217, .6);
    --bs-btn-hover-color: #fff;
    --bs-btn-hover-bg: rgba(255, 255, 255, .08);
    --bs-btn-hover-border-color: var(--gt-lav);
    --bs-btn-active-color: #fff;
    --bs-btn-active-bg: rgba(255, 255, 255, .14);
    --bs-btn-active-border-color: var(--gt-lav);
    --bs-btn-focus-shadow-rgb: 180, 171, 217;
    font-weight: 500;
}
nav.sidebar .btn-warning > i { margin-right: 7px; }

/* user */
nav.sidebar .dropdown > a {
    padding: 2px 4px;
    font-size: 13.5px;
}
nav.sidebar .dropdown > a > i.fs-3 {
    font-size: 20px !important;
    margin-right: 8px !important;
    color: var(--gt-lav);
}
nav.sidebar .dropdown > a > strong { font-weight: 500; }
.dropdown-menu.dropdown-menu-dark {         /* beats the light .dropdown-menu tokens further down */
    --bs-dropdown-bg: var(--gt-navy-3);
    --bs-dropdown-border-color: rgba(255, 255, 255, .14);
    --bs-dropdown-link-color: #dee2f0;
    --bs-dropdown-link-hover-bg: var(--gt-blue);
    --bs-dropdown-link-hover-color: #fff;
    --bs-dropdown-link-active-bg: var(--gt-navy-2);
    --bs-dropdown-link-active-color: #fff;
    --bs-dropdown-divider-bg: rgba(255, 255, 255, .14);
}

/* collapsed: a 56px icon strip (html.sidebar-collapsed, set in <head> from localStorage).
   Labels stay for screen readers (visually hidden); the title of each item is its tooltip. */
@media (min-width: 768px) {
    html.sidebar-collapsed { --sidebar-width: 56px; }
    html.sidebar-collapsed nav.sidebar .sidebar-sticky { padding: 14px 8px 12px !important; }
    html.sidebar-collapsed nav.sidebar .sidebar-head { flex-direction: column; gap: 8px; }
    html.sidebar-collapsed nav.sidebar .sidebar-brand { flex: none; padding: 0; }
    html.sidebar-collapsed nav.sidebar .sidebar-toggle > i { transform: rotate(180deg); }
    html.sidebar-collapsed nav.sidebar .sidebar-brand .fs-4,
    html.sidebar-collapsed nav.sidebar .nav-label {
        position: absolute !important;
        width: 1px; height: 1px;
        margin: -1px; padding: 0;
        overflow: hidden;
        clip: rect(0, 0, 0, 0);
        white-space: nowrap;
        border: 0;
    }
    html.sidebar-collapsed nav.sidebar .nav > .nav-link { text-align: center; }
    html.sidebar-collapsed nav.sidebar .nav > a.nav-link > i { font-size: 15px; vertical-align: -2px; }
    /* group labels become a thin divider (the first one sits under the brand rule already) */
    html.sidebar-collapsed nav.sidebar .nav > span.nav-link { height: 13px; padding: 0; position: relative; }
    html.sidebar-collapsed nav.sidebar .nav > span.nav-link > i { display: none; }
    html.sidebar-collapsed nav.sidebar .nav > span.nav-link::before {
        content: ''; position: absolute; left: 10px; right: 10px; top: 6px;
        border-top: 1px solid rgba(255, 255, 255, .14);
    }
    html.sidebar-collapsed nav.sidebar .nav > span.nav-link:first-child { display: none; }
    html.sidebar-collapsed nav.sidebar .btn-warning { padding: 0; }
    html.sidebar-collapsed nav.sidebar .btn-warning > i { margin: 0; font-size: 15px; }
    html.sidebar-collapsed nav.sidebar .dropdown > a { justify-content: center; padding: 2px 0; }
    html.sidebar-collapsed nav.sidebar .dropdown > a > i.fs-3 { margin-right: 0 !important; }
    html.sidebar-collapsed nav.sidebar .dropdown-toggle::after { display: none; }
    /* hover / keyboard focus on an icon: its label as a flyout beside the strip
       (position: fixed leaves the strip's scroll box; js/sidebar.js sets --label-y = the item's middle) */
    html.sidebar-collapsed nav.sidebar .nav > a.nav-link:is(:hover, :focus-visible) > .nav-label,
    html.sidebar-collapsed nav.sidebar .sidebar-details:is(:hover, :focus-visible) > .nav-label,
    html.sidebar-collapsed nav.sidebar .dropdown > a:not(.show):is(:hover, :focus-visible) > .nav-label {   /* not over its open menu */
        position: fixed !important;
        top: var(--label-y, auto);
        left: calc(var(--sidebar-width) + 6px);
        width: auto; height: auto;
        margin: 0;
        padding: 3px 9px;
        transform: translateY(-50%);
        clip: auto;
        overflow: visible;
        border-radius: 4px;
        background: var(--gt-navy-3);
        box-shadow: 0 4px 12px rgba(20, 26, 48, .3);
        color: #fff;
        font-size: 13px;
        font-weight: 500;
        line-height: 18px;
        text-align: left;
        pointer-events: none;
    }
}

/* phone (<768px): the sidebar is a slide-in (bootstrap .offcanvas-md), opened by ☰ in the top bar */
.topbar {
    display: flex;
    align-items: center;
    gap: 2px;
    height: 44px;
    padding: 0 12px 0 2px;
    background: var(--gt-navy);
}
.topbar-menu {
    display: inline-flex;
    align-items: center; justify-content: center;
    width: 44px; height: 44px;
    padding: 0;
    border: 0;
    border-radius: 4px;
    background: transparent;
    color: #fff;
    font-size: 26px;
}
.topbar-menu:focus-visible { outline: 0; box-shadow: inset 0 0 0 2px var(--gt-lav); }
.topbar-brand {
    display: flex;
    align-items: center;
    gap: 8px;
    color: #fff;
    font-family: var(--gt-cond);
    font-size: 17px;
    font-weight: 600;
    letter-spacing: .01em;
}
.topbar-brand:hover { color: #fff; }
.topbar-brand .brand-mark {
    width: 24px; height: 24px;
    border-radius: 4px;
    background: #fff;
    padding: 2px;
}
.offcanvas-backdrop { background-color: #141a30; }   /* the navy tint of .modal-backdrop */
.offcanvas-backdrop.show { opacity: .55; }
@media (max-width: 767.98px) {
    nav.sidebar {
        --bs-offcanvas-width: min(280px, 85vw); /* the page stays visible behind the backdrop */
        z-index: var(--bs-offcanvas-zindex);    /* over its backdrop */
        border-right: 0;
    }
    nav.sidebar .sidebar-sticky { height: 100%; }
    nav.sidebar .nav-pills { --bs-nav-link-padding-y: 9px; }   /* 36px tap targets */
    nav.sidebar .btn-warning { padding-top: 7px; padding-bottom: 7px; }
}

/* ---------- content frame ---------------------------------------------- */

.content {
    width: 100%;
    margin-left: var(--sidebar-width);      /* from main.css */
}
@media (max-width: 767.98px) { .content { margin-left: 0; } }
/* 768–1099px: the page keeps the strip's offset; the menu opened there lies over the page instead of pushing it off the right edge */
@media (min-width: 768px) and (max-width: 1099.98px) {
    .content { margin-left: 56px; min-width: 0; }
    html:not(.sidebar-collapsed) nav.sidebar { box-shadow: 0 0 24px rgba(20, 26, 48, .35); }
    .table-scroll { overflow-x: auto !important; }   /* a table still too wide (spec, contracts at 768px) scrolls in its box, as on a phone */
    #offer-actions,
    .form-actions { flex-wrap: wrap; } /* an action bar wraps at 768px (a КП without a project has one more button) */
}

/* ---------- form controls ---------------------------------------------- */

.form-control,
.form-select {
    font-size: 13.5px;
    line-height: 20px;
    padding: 4px 8px;
    color: var(--gt-ink);
    border-color: var(--gt-field);
    border-radius: 4px;
}
textarea.form-control { min-height: var(--gt-control-h); }
.form-control::placeholder { color: #6f6a80; opacity: 1; }   /* 5.2:1 */
.form-control:focus,
.form-select:focus {
    border-color: var(--gt-navy);
    box-shadow: 0 0 0 2px rgba(38, 52, 95, .18) !important;
    outline: none;
}
.form-control[readonly] { background-color: var(--gt-zebra); }
/* <select class="form-control"> (Django widgets): bootstrap drops the arrow, put a small one back */
select.form-control:not([multiple]) {
    padding-right: 24px;
    background: #fff url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 10 6'%3e%3cpath fill='none' stroke='%2326345f' stroke-width='1.4' d='M1 1l4 4 4-4'/%3e%3c/svg%3e") no-repeat right 8px center / 9px 6px;
}
.form-control.is-invalid,
td.is-invalid .form-control { border-color: var(--gt-red) !important; }
.invalid-feedback { color: var(--gt-red); font-size: 12px; }
/* radios / checkboxes (forms/bs-radio.html) and pills (forms/modal-form-context.html): navy, not bootstrap blue */
.form-check-input:checked { background-color: var(--gt-navy); border-color: var(--gt-navy); }
.form-check-input:focus { border-color: var(--gt-navy); box-shadow: 0 0 0 2px rgba(38, 52, 95, .18); }
.nav-pills { --bs-nav-pills-link-active-bg: var(--gt-navy); }
/* keyboard focus: a ring that is seen (navy .6 = 3.7:1 on white; the spec cells keep their inset navy frame) */
.form-control:focus-visible,
.form-select:focus-visible,
.form-check-input:focus-visible,
.selectr-selected:focus-visible,
.selectr-input:focus-visible {
    border-color: var(--gt-navy);
    box-shadow: 0 0 0 2px rgba(38, 52, 95, .6) !important;
    outline: none;
}

/* labels: the print's micro-labels (mauve, spaced capitals); not in TinyMCE's own dialogs (.tox) */
label:not(.form-check-label):not(.btn):not(.tox *) {
    font-size: 10.5px;
    font-weight: 600;
    line-height: 14px;
    letter-spacing: .08em;
    text-transform: uppercase;
    color: var(--gt-accent);
    margin-bottom: 4px;
}
label.fw-bold { font-weight: 700 !important; }
/* login / sign-up: the floating label sits inside its field, as bootstrap draws it */
.form-floating > label:not(.form-check-label):not(.btn) {
    font-size: inherit;
    font-weight: 400;
    line-height: 1.45;
    letter-spacing: normal;
    text-transform: none;
    color: var(--gt-muted);
    margin: 0;
}
label:not(:first-of-type) { margin-top: 12px; }   /* from main.css (label/input pairs of {{ form }}) */

/* ---------- buttons: small, squarish ----------------------------------- */

.btn {
    --bs-btn-padding-x: 12px;
    --bs-btn-padding-y: 4px;
    --bs-btn-font-size: 13.5px;
    --bs-btn-font-weight: 500;
    --bs-btn-line-height: 20px;
    --bs-btn-border-radius: 4px;
    --bs-btn-focus-box-shadow: 0 0 0 2px rgba(38, 52, 95, .3);
    letter-spacing: .005em;
}
.btn-sm {
    --bs-btn-padding-x: 10px;
    --bs-btn-padding-y: 3px;
    --bs-btn-font-size: 13px;
    --bs-btn-line-height: 20px;
    --bs-btn-border-radius: 4px;
}
.btn-lg {
    --bs-btn-padding-x: 18px;
    --bs-btn-padding-y: 7px;
    --bs-btn-font-size: 15px;
    --bs-btn-line-height: 22px;
}
.btn.fw-bold { font-weight: 600 !important; }
.btn.bi::before { vertical-align: -1px; }
/* keyboard focus: a solid navy outline (12:1 on white) instead of the faint glow; lavender on the navy sidebar */
.btn:focus-visible,
.btn-close:focus-visible { outline: 2px solid var(--gt-navy); outline-offset: 2px; box-shadow: none; }
nav.sidebar .btn:focus-visible,
nav.sidebar .btn-close:focus-visible { outline-color: var(--gt-lav); }

.btn-primary {
    --bs-btn-color: #fff;
    --bs-btn-bg: var(--gt-navy);
    --bs-btn-border-color: var(--gt-navy);
    --bs-btn-hover-color: #fff;
    --bs-btn-hover-bg: var(--gt-blue);
    --bs-btn-hover-border-color: var(--gt-blue);
    --bs-btn-active-color: #fff;
    --bs-btn-active-bg: var(--gt-navy-3);
    --bs-btn-active-border-color: var(--gt-navy-3);
    --bs-btn-disabled-bg: var(--gt-navy);
    --bs-btn-disabled-border-color: var(--gt-navy);
    --bs-btn-focus-shadow-rgb: 38, 52, 95;
}
.btn-outline-primary {
    --bs-btn-color: var(--gt-navy);
    --bs-btn-bg: #fff;
    --bs-btn-border-color: var(--gt-navy);
    --bs-btn-hover-color: var(--gt-navy);
    --bs-btn-hover-bg: var(--gt-tint);
    --bs-btn-hover-border-color: var(--gt-navy);
    --bs-btn-active-color: var(--gt-navy);
    --bs-btn-active-bg: #d9d4ea;
    --bs-btn-active-border-color: var(--gt-navy);
    --bs-btn-focus-shadow-rgb: 38, 52, 95;
}
/* secondary = neutral: «Сбросить», «Отменить», «...», and the ↺ of a row marked for deletion */
.btn-secondary {
    --bs-btn-color: var(--gt-navy);
    --bs-btn-bg: #fff;
    --bs-btn-border-color: var(--gt-field);
    --bs-btn-hover-color: var(--gt-navy);
    --bs-btn-hover-bg: var(--gt-zebra);
    --bs-btn-hover-border-color: var(--gt-navy);
    --bs-btn-active-color: var(--gt-navy);
    --bs-btn-active-bg: var(--gt-tint);
    --bs-btn-active-border-color: var(--gt-navy);
    --bs-btn-focus-shadow-rgb: 38, 52, 95;
}
.btn-success {
    --bs-btn-color: #fff;
    --bs-btn-bg: var(--gt-green);
    --bs-btn-border-color: var(--gt-green);
    --bs-btn-hover-color: #fff;
    --bs-btn-hover-bg: #245c3c;
    --bs-btn-hover-border-color: #245c3c;
    --bs-btn-active-color: #fff;
    --bs-btn-active-bg: #1d4b31;
    --bs-btn-active-border-color: #1d4b31;
    --bs-btn-focus-shadow-rgb: 44, 110, 73;
}
.btn-danger {
    --bs-btn-color: #fff;
    --bs-btn-bg: var(--gt-red);
    --bs-btn-border-color: var(--gt-red);
    --bs-btn-hover-color: #fff;
    --bs-btn-hover-bg: #921c13;
    --bs-btn-hover-border-color: #921c13;
    --bs-btn-focus-shadow-rgb: 180, 35, 24;
}
.btn-outline-danger {
    --bs-btn-color: var(--gt-red);
    --bs-btn-bg: #fff;
    --bs-btn-border-color: #d6a19c;
    --bs-btn-hover-color: #fff;
    --bs-btn-hover-bg: var(--gt-red);
    --bs-btn-hover-border-color: var(--gt-red);
    --bs-btn-active-bg: #921c13;
    --bs-btn-active-border-color: #921c13;
    --bs-btn-focus-shadow-rgb: 180, 35, 24;
}
/* warning = edit («Редактировать», the pencils, «Обзор»): kept amber so it is still found by colour, toned to the palette */
.btn-warning {
    --bs-btn-color: var(--gt-ink);
    --bs-btn-bg: #f2cf6b;
    --bs-btn-border-color: #ddb447;
    --bs-btn-hover-color: var(--gt-ink);
    --bs-btn-hover-bg: #e9c04f;
    --bs-btn-hover-border-color: #cfa232;
    --bs-btn-active-color: var(--gt-ink);
    --bs-btn-active-bg: #ddb447;
    --bs-btn-active-border-color: #c3972a;
    --bs-btn-focus-shadow-rgb: 221, 180, 71;
}
.btn-group > .btn.dropdown-toggle::after { margin-left: 6px; vertical-align: 2px; }

/* dropdowns */
.dropdown-menu {
    --bs-dropdown-font-size: 13.5px;
    --bs-dropdown-border-radius: 4px;
    --bs-dropdown-border-color: var(--gt-line);
    --bs-dropdown-padding-y: 4px;
    --bs-dropdown-item-padding-y: 5px;
    --bs-dropdown-item-padding-x: 12px;
    --bs-dropdown-link-color: var(--gt-ink);
    --bs-dropdown-link-hover-bg: var(--gt-tint);
    --bs-dropdown-link-hover-color: var(--gt-navy);
    --bs-dropdown-link-active-bg: var(--gt-navy);
    --bs-dropdown-box-shadow: 0 6px 18px rgba(28, 30, 41, .14);
    box-shadow: var(--bs-dropdown-box-shadow);
}

/* badges: condensed capitals; status / source badges (bg-success, src-* …) keep their own colours */
.badge {
    --bs-badge-padding-x: 5px;
    --bs-badge-padding-y: 2px;
    --bs-badge-font-size: 10.5px;
    --bs-badge-font-weight: 600;
    --bs-badge-border-radius: 2px;
    font-family: var(--gt-cond);
    letter-spacing: .06em;
    text-transform: uppercase;
    line-height: 12px;
    border: 1px solid transparent;
    vertical-align: 1px;
}
/* chips (tags: .badge.bg-secondary) */
.badge.bg-secondary {
    --bs-secondary-rgb: 233, 230, 241;      /* .bg-secondary → tint */
    --bs-badge-color: var(--gt-navy);
    --bs-white-rgb: 38, 52, 95;             /* tags page: .text-white chip buttons read navy too */
    border-color: var(--gt-line);
}
/* light backgrounds keep a badge readable: ink, not bootstrap's white (rfq-response «Not submitted»: 1.6:1 → 12:1) */
.badge.bg-warning,
.badge.bg-info,
.badge.bg-light { --bs-badge-color: var(--gt-ink); }

/* ---------- tables: the print's spec table ----------------------------- */

.table {
    --bs-table-bg: transparent;             /* 5.3 paints cells white: keep row hover visible */
    --bs-table-color: var(--gt-ink);
    --bs-table-border-color: var(--gt-line);
    --bs-table-striped-bg: var(--gt-zebra);
    --bs-table-hover-bg: var(--gt-hover);
    border-collapse: separate;              /* borders travel with the sticky head */
    border-spacing: 0;
    border-top: 1px solid var(--gt-line);
    border-left: 1px solid var(--gt-line);
    font-family: var(--gt-cond);
    font-size: 14px;
    font-variant-numeric: tabular-nums;
    margin-bottom: 0;
}
.table > :not(caption) > * > * {
    padding: 5px 9px;
    line-height: 19px;
    border-bottom: 1px solid var(--gt-line);
    border-right: 1px solid var(--gt-line);
    vertical-align: top;
}
.table > thead > tr > th {
    background-color: var(--gt-tint);
    color: var(--gt-navy);
    box-shadow: none;
    border-bottom: 2px solid var(--gt-navy);
    padding-top: 6px;
    padding-bottom: 5px;
    font-size: 11.5px;
    font-weight: 600;
    line-height: 16px;
    letter-spacing: .07em;
    text-transform: uppercase;
    white-space: nowrap;
    vertical-align: bottom;
}
table.fixed-header th {                     /* from main.css */
    position: sticky !important;
    top: 0;
    z-index: 2;
}
/* the top hairline rides with the sticky head instead of scrolling away with the table */
table.fixed-header { border-top: 0; }
table.fixed-header > thead > tr > th { border-top: 1px solid var(--gt-line); }
/* zebra on even rows, as in print */
.table-striped > tbody > tr:nth-of-type(odd) > * { --bs-table-bg-type: transparent; }
.table-striped > tbody > tr:nth-of-type(even) > * { --bs-table-bg-type: var(--gt-zebra); }

/* clickable rows */
tr.link { cursor: pointer; }
tr.link:hover > * { --bs-table-bg-state: var(--gt-hover); }
tr.link:hover > td:first-child { box-shadow: inset 3px 0 0 var(--gt-navy), inset 0 0 0 9999px var(--gt-hover); }
tr.link .secondary { display: none; }       /* from dashboard.css */
tr.link:hover .secondary { display: inline; }

/* lists that start with «#» then a date (.list-numbered: offers, projects, orders): number right-aligned, in navy */
table.list-numbered > tbody > tr > td:first-child,
table.list-numbered > thead > tr > th:first-child {
    width: 1%;
    text-align: right;
    white-space: nowrap;
}
table.list-numbered > tbody > tr > td:first-child { color: var(--gt-navy); font-weight: 500; }
table.list-numbered > tbody > tr > td:nth-child(2) { white-space: nowrap; width: 1%; }
table.projects-list > tbody > tr > td .badge + .badge { margin-left: 2px; }

/* КП list (concept v2, 2026-11-16): «Статус» as a chip in the КП page's .kp-st colours (offers/status-block.html:
   keep the two in step), «Напоминание» = the customer reminder, «Сумма» filter as one joined group like «Период» */
table.offers-list td.st-cell,
table.offers-list td.rem,
table.offers-list th.rem { white-space: nowrap; width: 1%; }
.st-chip { display: inline-block; padding: 0 6px; border: 1px solid; border-radius: 2px; font: 500 13px/18px var(--gt-cond); letter-spacing: .01em; white-space: nowrap; }
.st-chip.open { background: #dde7fb; border-color: #93aadb; color: #1f3a7a; }
.st-chip.sold { background: #d1e7dd; border-color: #a3cfbb; color: #0f4a2c; }
.st-chip.no_outcome { background: #efeef3; border-color: var(--gt-line); color: #4f4c5e; }
.st-chip.replaced { background: #f5ecf3; border-color: #d8bfd2; color: #6b3f62; }
table.offers-list .st-none { color: var(--gt-muted); }
table.offers-list td.rem { font-variant-numeric: tabular-nums; }
table.offers-list td.rem .bi { margin-right: 5px; font-size: 14px; vertical-align: -1px; color: var(--gt-navy); }
table.offers-list td.rem .rem-muted { color: var(--gt-muted); }
table.offers-list td.rem .rem-err,
table.offers-list td.rem .rem-err .bi { color: var(--gt-red); font-weight: 500; }
form .ma-form-field.sum-field > .d-flex > .form-control { flex: 0 0 108px; }
form .ma-form-field.sum-field > .d-flex > .form-control:not(:first-child):not(:last-child) { border-radius: 0; margin-left: -1px; }
form .ma-form-field.sum-field > .d-flex > select.form-control { flex: 0 0 72px; min-width: 0; padding-right: 22px; }
/* one column more: from 1100px to ~1150px the table no longer fits — it scrolls in its own box (as below 1100px), never the page */
.content:has(table.offers-list) { min-width: 0; }
.table-scroll:has(> table.offers-list) { overflow-x: auto !important; }
/* print-preview mini button in the last cell */
tr.link .secondary .btn {
    --bs-btn-padding-x: 0;
    --bs-btn-padding-y: 0;
    --bs-btn-color: var(--gt-navy);
    --bs-btn-bg: #fff;
    --bs-btn-border-color: var(--gt-navy);
    --bs-btn-hover-color: #fff;
    --bs-btn-hover-bg: var(--gt-navy);
    --bs-btn-hover-border-color: var(--gt-navy);
    width: 24px; height: 24px;
    font-size: 12px; line-height: 22px;
}
tr.link .secondary { top: -3px !important; right: -4px !important; }

/* ---------- list page: one toolbar row above the table ------------------ */

/* the rule under every page title (lists and detail pages; order page's second hr is not first-of-type) */
main.content > div > hr:first-of-type,
body > h1.fs-4 + hr,
body > .py-3 > h1.fs-4 + hr { margin: 14px 0 10px; border-top: 2px solid var(--gt-navy); }   /* same navy rule as the editor's field strip */
main.content > div > hr:first-of-type:has(+ .list-toolbar) { margin-bottom: 0; }                 /* the toolbar strip sits on it */

/* toolbar = the row holding the filter form and «+ Оффер» (.list-toolbar in the list templates) */
.list-toolbar {
    align-items: center;
    padding: 9px 10px;
    background: var(--gt-zebra);
    border-bottom: 1px solid var(--gt-line);
}
.list-toolbar > div:first-child { flex: 1 1 auto !important; }
.list-toolbar > div:last-child { flex: 0 0 auto !important; margin-left: 24px; }
.list-toolbar > div:only-child { flex: 1 1 auto !important; margin-left: 0; }   /* filter only, or «+ create» only (right-aligned by .text-end) */
form .ma-form-field {
    display: flex;
    align-items: center;
    gap: 7px;
    margin-right: 14px !important;
}
form .ma-form-field > label {
    margin: 0 !important;
    white-space: nowrap;
}
form .ma-form-field > .form-control,
form .ma-form-field > .d-flex { flex: 1 1 auto; min-width: 0; }
/* only free text stretches; a date range and a select keep the width their content needs */
form .ma-form-field:has(> .d-flex) { flex: 0 0 auto !important; }
form .ma-form-field:has(> select) { flex: 0 0 auto !important; }
form .ma-form-field > .d-flex > .form-control { flex: 0 0 142px; }
form .ma-form-field > select.form-control { width: auto; min-width: 116px; max-width: 220px; flex: 0 0 auto; }
form .ma-form-field:has(> input[type=text]) { min-width: 150px; }
form .ma-form-field.lookup-k { flex: 0 0 auto !important; min-width: 0 !important; }   /* price lookup «К»: a 5-digit box */
form .ma-form-field.lookup-k > .form-control { flex: none; width: 64px; }
/* narrow screens: the buttons drop to a second line instead of pushing «+ Оффер» out */
form .d-flex:has(> .ma-form-field) { flex-wrap: wrap; row-gap: var(--gt-gap-s); }
/* projects «Расширенный поиск»: its fields a row under the summary line, not on it */
form details > summary ~ .d-flex { margin-top: var(--gt-gap-s); }
/* the two period inputs read as one control */
form .ma-form-field > .d-flex > .form-control:first-child { border-top-right-radius: 0; border-bottom-right-radius: 0; }
form .ma-form-field > .d-flex > .form-control:last-child  { border-top-left-radius: 0; border-bottom-left-radius: 0; margin-left: -1px; }
form .ma-form-field > .d-flex > .form-control:focus { position: relative; z-index: 1; }
form .ma-form-field ~ .btn { align-self: center !important; }
form .ma-form-field ~ .btn.mx-2 { margin-left: 0 !important; margin-right: var(--gt-gap-btn) !important; }
/* below 1400px (laptops) the labels go above their fields: still one row, and the search keeps room for its placeholder */
@media (max-width: 1399.98px) {
    form .ma-form-field { flex-direction: column; align-items: stretch; gap: 3px; }
    form .ma-form-field > .form-control,
    form .ma-form-field > .d-flex { flex: 0 0 auto; }
    form .ma-form-field ~ .btn { align-self: flex-end !important; }
}

/* «Найдено: N» between toolbar and table */
.list-count {
    padding: 10px 0 6px;
    font-family: var(--gt-cond);
    font-size: 12.5px;
    color: var(--gt-muted);
    letter-spacing: .02em;
}
main.content > .d-flex.flex-column > .list-count + div.mt-2:has(> table) { margin-top: 0 !important; }
.list-count > span + span::before { content: '·'; margin: 0 8px; }   /* «Найдено: 12 · Баланс за период: …» */
.list-count.projects-summary { display: flex; flex-wrap: wrap; row-gap: 2px; }
.list-count b { font-weight: 500; color: var(--gt-ink); }

/* ---------- offer editor ------------------------------------------------ */

/* header fields (.field-grid in offers/offer-form.html) = the print's info grid: navy rule on top, cells split by hairlines */
.field-grid {
    margin: 14px 0 0 !important;
    border-top: 2px solid var(--gt-navy);
    border-bottom: 1px solid var(--gt-line);
    background: var(--gt-zebra);
}
.field-grid > div {
    margin: 0 !important;
    padding: 8px 12px 10px;
    border-left: 1px solid var(--gt-line);
    flex: 2 1 0 !important;
    min-width: 240px !important;
}
.field-grid > div:first-child { border-left: 0; padding-left: 10px; }
/* buyer / customer names are long: they get the room, the date only what it needs */
.field-grid > .field-narrow { flex: 0 0 160px !important; min-width: 160px !important; }
.field-grid > .field-wide { flex: 3 1 0 !important; min-width: 260px !important; }
.field-grid .field-value { min-height: var(--gt-control-h); display: flex; align-items: center; }
/* «Кому и конечный заказчик» (offers/offer-form.html): a closed strip under the header fields, its title line
   previews what is filled; open, the two fields are one more header row */
.offer-extra { border-bottom: 1px solid var(--gt-line); }
.offer-extra > summary {
    display: flex; align-items: baseline; flex-wrap: wrap; column-gap: 14px; row-gap: 2px;
    padding: 7px 10px; cursor: pointer; list-style: none; user-select: none;
}
.offer-extra > summary::-webkit-details-marker { display: none; }
.offer-extra > summary::before {        /* chevron, turns down when open */
    content: '\F285'; font-family: bootstrap-icons; font-size: 10px; width: 10px; color: var(--gt-navy);
    align-self: center; transition: transform .15s;
}
.offer-extra[open] > summary::before { transform: rotate(90deg); }
.offer-extra > summary:hover .offer-extra-title { color: var(--gt-navy); }
.offer-extra > summary:focus-visible { outline: 0; box-shadow: inset 0 0 0 2px rgba(38, 52, 95, .6); }
.offer-extra-title {
    font-size: 10.5px; font-weight: 600; line-height: 14px; letter-spacing: .08em; text-transform: uppercase;
    color: var(--gt-accent);
}
.offer-extra-preview {
    flex: 1 1 240px; min-width: 0;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;   /* one line, however long */
    font-family: var(--gt-cond); font-size: 13.5px; color: var(--gt-ink);
}
.offer-extra-preview i,
.offer-extra-preview .empty { font-style: normal; color: var(--gt-muted); }
.offer-extra-preview > span + span::before { content: '·'; margin: 0 8px; color: var(--gt-muted); }
.offer-extra[open] .offer-extra-preview { display: none; }   /* open: the fields show it */
.offer-extra > .field-grid { margin: 0 !important; border-top: 1px solid var(--gt-line); border-bottom: 0; }
.btn-success.bi-plus-lg:not(#add-row) {        /* «+» quick-create next to a select (counterparty, product) */
    --bs-btn-color: var(--gt-green);
    --bs-btn-bg: #fff;
    --bs-btn-border-color: var(--gt-field);
    --bs-btn-hover-color: #fff;
    --bs-btn-hover-bg: var(--gt-green);
    --bs-btn-hover-border-color: var(--gt-green);
    width: var(--gt-control-h); height: var(--gt-control-h);
    padding: 0;
    margin-left: 4px !important;
    flex: none;
}

/* section heading «Спецификация» + its action (offer, order edit/page, project transactions) */
.section-head {
    display: flex;
    gap: var(--gt-gap-s);
    margin-top: var(--gt-gap-xl) !important;
    margin-bottom: var(--gt-gap-s);
    align-items: center !important;
}
.section-head > h4 { flex: 1; margin: 0 !important; }
hr + .section-head,
.tab-pane > .section-head:first-child { margin-top: 0 !important; }

/* detail pages: the actions beside the title (project, order), as the offer's action bar draws them */
.page-actions { display: flex; flex-wrap: wrap; align-items: center; gap: var(--gt-gap-btn); }
.page-actions > .ms-3 { margin-left: var(--gt-gap-l) !important; }

/* tabs under a page (project, order, annex, RFQ): a block of their own above, content flush with the title, one gap under the tab line */
main.content .nav-tabs.mt-3 { margin-top: var(--gt-gap-l) !important; }
.nav-tabs + .tab-content { padding: var(--gt-gap-m) 0 0; }
.nav-tabs + .tab-content > .tab-pane { padding-top: 0 !important; }
.nav-tabs + .tab-content > .tab-pane > :first-child { margin-top: 0 !important; }
.tab-pane > .text-end:has(> .btn) {         /* a pane's «+ Добавить …» row above its table */
    display: flex; flex-wrap: wrap; justify-content: flex-end; gap: var(--gt-gap-btn);
    margin-bottom: var(--gt-gap-s);
}
/* project «Вложения»: one attachment per line, the lines apart */
#attachments > .col > div + div { margin-top: var(--gt-gap-xs); }

/* spec table: a printed spec you can type into */
#specification {
    margin-bottom: 0;
}
#specification #spec-body { counter-reset: specrow; }
#specification #spec-body tr.spec-row { counter-increment: specrow; }
#specification > thead > tr > th.table-header-quantity,
#specification > thead > tr > th.table-header-price { text-align: right; }
#specification > thead > tr > th.table-header-currency { text-align: center; }
#specification > thead > tr > th.table-header-description { width: 100%; padding-left: 40px; position: relative; }
#specification > thead > tr > th.table-header-description::before {           /* «№» over the row numbers */
    content: '№';
    position: absolute; left: 0; top: 0; bottom: 0;
    width: 31px; padding: 6px 7px 0 0;
    text-align: right;
    border-right: 1px solid var(--gt-line);
}

#specification #spec-body td { padding: 0; vertical-align: top; }
#specification #spec-body tr.spec-row:nth-child(even) > td { --bs-table-bg-type: var(--gt-zebra); }
#specification #spec-body tr.spec-row:hover > td { --bs-table-bg-state: #eef0f8; }

/* inputs fill their cell: no box until hover / focus */
#specification #spec-body .form-control {
    height: auto;
    min-height: 30px;
    padding: 5px 8px;
    border: 1px solid transparent;
    border-radius: 0;
    background-color: transparent;
    font-family: var(--gt-cond);
    font-size: 14px;
    line-height: 19px;
}
#specification #spec-body .form-control:hover { border-color: var(--gt-line); background-color: #fff; }
#specification #spec-body .form-control:focus {
    border-color: var(--gt-navy);
    background-color: #fff;
    box-shadow: inset 0 0 0 1px var(--gt-navy) !important;
    position: relative; z-index: 1;
}
/* one line, grows with its text (Chrome / Safari; elsewhere the textarea keeps its rows and its resize handle) */
@supports (field-sizing: content) {
    #specification #spec-body textarea.form-control { field-sizing: content; resize: none; }
}
#specification #spec-body .quantity input,
#specification #spec-body .price input { text-align: right; -moz-appearance: textfield; appearance: textfield; }
#specification #spec-body input[type=number]::-webkit-inner-spin-button,
#specification #spec-body input[type=number]::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
#specification #spec-body .spec-cell.quantity input { width: 78px; }
#specification #spec-body .spec-cell.price input { width: 108px; }
#specification #spec-body .spec-cell.currency select { width: 74px; text-align: center; background-color: transparent; background-position: right 7px center; padding-left: 10px; }

/* row number, like the print's № column (where the head has «№»: offer, order) */
#specification:has(> thead th.table-header-description) #spec-body td.description { position: relative; padding-left: 31px; }
#specification:has(> thead th.table-header-description) #spec-body td.description::before {
    content: counter(specrow);
    position: absolute; left: 0; top: 0; bottom: 0;
    width: 31px;
    padding: 6px 7px 0 0;
    text-align: right;
    font-family: var(--gt-cond);
    font-size: 12.5px;
    line-height: 19px;
    color: var(--gt-muted);
    border-right: 1px solid var(--gt-line);
}
/* «...» product picker: quiet until the row is hovered */
#specification #spec-body td.description .btn-secondary {
    width: 26px; height: 22px;
    margin: 4px 5px 0 2px !important;
    padding: 0;
    font-size: 12px; line-height: 14px; font-weight: 600;
    letter-spacing: .05em;
    --bs-btn-color: var(--gt-muted);
    --bs-btn-border-color: transparent;
    --bs-btn-bg: transparent;
}
#specification #spec-body tr:hover td.description .btn-secondary,
#specification #spec-body td.description .btn-secondary:focus-visible {
    --bs-btn-color: var(--gt-navy);
    --bs-btn-border-color: var(--gt-field);
    --bs-btn-bg: #fff;
}
/* sum */
#specification #spec-body td.total {
    padding: 6px 9px 0 !important;
    min-width: 112px;
    font-weight: 500;
    color: var(--gt-ink);
    line-height: 19px;
}
/* × delete / ↺ restore */
#specification #spec-body td.delete { width: 34px; padding: 4px 4px 0; text-align: center; }
#specification #spec-body .delete-button {
    width: 24px; height: 24px; padding: 0;
    font-size: 17px; line-height: 22px;
}
#specification #spec-body .delete-button.btn-danger {
    --bs-btn-color: var(--gt-red);
    --bs-btn-bg: transparent;
    --bs-btn-border-color: transparent;
}
#specification #spec-body tr:hover .delete-button.btn-danger { --bs-btn-border-color: #d6a19c; --bs-btn-bg: #fff; }
#specification #spec-body .delete-button.btn-danger:hover { --bs-btn-color: #fff; --bs-btn-bg: var(--gt-red); --bs-btn-border-color: var(--gt-red); }
#specification #spec-body .delete-button.btn-secondary { font-size: 14px; }
/* a row marked for deletion (its button turned into ↺ btn-secondary) */
#specification #spec-body tr.spec-row:has(.delete-button.btn-secondary) .form-control,
#specification #spec-body tr.spec-row:has(.delete-button.btn-secondary) td.total {
    color: var(--gt-muted);
    text-decoration: line-through;
}

/* add row */
#specification #spec-body tr.add-row > td { padding: 6px 8px; --bs-table-bg-type: #fff; }
#specification #add-row.btn-success {
    --bs-btn-color: var(--gt-green);
    --bs-btn-bg: #fff;
    --bs-btn-border-color: #9cc2ac;
    --bs-btn-hover-color: #fff;
    --bs-btn-hover-bg: var(--gt-green);
    --bs-btn-hover-border-color: var(--gt-green);
    border-style: dashed;
    font-family: var(--gt-ui);
    font-size: 13px;
    padding: 2px 12px 2px 9px;
}
#specification #add-row.bi::before { margin-right: 6px; }

/* totals = the print's boxed ИТОГО, glued under the Сумма column */
#spec-totals {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    margin: 0 !important;
}
#spec-totals > div {
    display: flex;
    align-items: baseline;
    gap: 28px;
    min-width: 330px;
    justify-content: space-between;
    padding: 7px 12px 7px 14px;
    background: var(--gt-tint);
    border: 1px solid var(--gt-navy);
    border-top: 0;
    box-shadow: inset 0 2px 0 var(--gt-navy);   /* 2px navy top, as the print's ИТОГО box */
    font-family: var(--gt-cond);
    font-size: 18px;
    font-weight: 700;
    line-height: 22px;
    color: var(--gt-navy);
    white-space: nowrap;
}
#spec-totals > div + div { border-top: 0; box-shadow: none; }
#spec-totals > div::before {
    content: 'Итого';
    font-size: 11.5px;
    font-weight: 600;
    letter-spacing: .08em;
    text-transform: uppercase;
}

/* comment: not printed → dashed box */
#offer-form #id_comment {
    border-style: dashed;
    background-color: #fcfbfe;
}
#offer-form > div:has(> .w-100 > #id_comment) { margin-top: var(--gt-gap-l); }

/* the two rich-text fields (offer, user settings) */
.kp-texts {
    gap: var(--gt-gap-l);
    margin-top: var(--gt-gap-l);
    margin-bottom: var(--gt-gap-l);
}
.kp-texts > .m-1 { margin: 0 !important; }

/* sticky action bar: the offer editor's, and .form-actions under every other form (annex, contract, RFQ, supplier page,
   order create/edit, user settings) */
#offer-actions,
.form-actions {
    gap: var(--gt-gap-btn);
    margin: 0 -1.5rem;                      /* bleeds over the .px-4 gutter */
    padding: 10px 1.5rem !important;
    border-top: 1px solid var(--gt-line) !important;
    box-shadow: 0 -6px 16px rgba(28, 30, 41, .06);
    align-items: center;
}
#offer-actions > div,
.form-actions > div { display: flex; align-items: center; gap: var(--gt-gap-btn); }
#offer-actions > div > .ms-3 { margin-left: var(--gt-gap-l) !important; }
/* what the offer bar has inline / as utilities; a block apart from the table or editor above it */
.form-actions { position: sticky; bottom: 0; z-index: 20; background-color: #fff; margin-top: var(--gt-gap-l); }
/* a field focused (Tab) or scrolled to under the bar stops above it */
:root:has(#offer-actions, .form-actions) { scroll-padding-bottom: 80px; }

/* ---------- TinyMCE 8 chrome (oxide skin, toned to the theme) ----------- */

.tox.tox-tinymce {
    border: 1px solid var(--gt-field);
    border-radius: 4px;
}
.tox.tox-tinymce.tox-edit-focus { border-color: var(--gt-navy); box-shadow: 0 0 0 2px rgba(38, 52, 95, .18); }
.tox .tox-edit-area::before { display: none !important; }   /* the blue focus frame: the outer border does it */
.tox:not(.tox-tinymce-inline) .tox-editor-header {
    box-shadow: none !important;
    padding: 0 !important;
    border-bottom: 1px solid var(--gt-line) !important;
    background: var(--gt-tint);
}
.tox .tox-toolbar,
.tox .tox-toolbar__primary,
.tox .tox-toolbar__overflow,
.tox .tox-toolbar-overlord {
    background: var(--gt-tint) !important;
}
.tox .tox-toolbar__group { padding: 0 3px !important; }
.tox .tox-toolbar__group:not(:last-of-type) { border-right: 1px solid var(--gt-line) !important; }
.tox .tox-tbtn {
    height: 26px !important;
    width: 26px !important;
    margin: 3px 1px !important;
    border-radius: 3px !important;
    background: transparent !important;
    color: var(--gt-navy) !important;
}
.tox .tox-tbtn svg { fill: var(--gt-navy) !important; transform: scale(.84); }
.tox .tox-tbtn:hover { background: #d9d4ea !important; }
.tox .tox-tbtn--enabled,
.tox .tox-tbtn--enabled:hover { background: #cdc6e3 !important; }
/* disabled (e.g. undo with nothing to undo) must still look disabled under the navy override */
.tox .tox-tbtn--disabled,
.tox .tox-tbtn--disabled:hover { background: transparent !important; cursor: not-allowed; }
.tox .tox-tbtn--disabled svg { fill: #a9a4bc !important; }
.tox .tox-tbtn--select { width: auto !important; padding: 0 4px !important; }
/* split buttons (lists, text / background colour): the arrow half stays narrow */
.tox .tox-split-button__main { margin-right: 0 !important; border-radius: 3px 0 0 3px !important; }
.tox .tox-split-button__chevron { width: 14px !important; margin-left: 0 !important; border-radius: 0 3px 3px 0 !important; }
.tox .tox-split-button__chevron svg { transform: none; }
.tox .tox-statusbar {
    height: 22px !important;
    border-top: 1px solid var(--gt-line) !important;
    font-family: var(--gt-cond) !important;
    font-size: 11.5px !important;
    color: var(--gt-muted) !important;
}
.tox .tox-statusbar a, .tox .tox-statusbar__wordcount { color: var(--gt-muted) !important; text-transform: none !important; }

/* ---------- Selectr ---------------------------------------------------- */

.selectr-container { font-size: 13.5px; }
.selectr-selected {
    min-height: var(--gt-control-h);
    padding: 4px 26px 4px 8px;
    line-height: 20px;
    border: 1px solid var(--gt-field);
    border-radius: 4px;
}
/* the same thin navy chevron as the native selects (instead of Selectr's filled triangle) */
.selectr-selected::before {
    right: 8px;
    width: 9px; height: 6px;
    border: 0;
    background: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 10 6'%3e%3cpath fill='none' stroke='%2326345f' stroke-width='1.4' d='M1 1l4 4 4-4'/%3e%3c/svg%3e") no-repeat center / 9px 6px;
    transform: translateY(-50%);
    transform-origin: center;
}
.selectr-container.open .selectr-selected::before { border: 0; transform: translateY(-50%) rotate(180deg); }
.selectr-container.open .selectr-selected { border-color: var(--gt-navy) var(--gt-navy) transparent; }
.selectr-container.multiple.has-selected .selectr-selected { padding: 4px 26px 4px 4px; }
.has-selected .selectr-tags { margin: 0; }
.selectr-placeholder { color: #6f6a80; }
.selectr-tag {
    float: left;
    margin: 0 3px 0 0;
    padding: 0 20px 0 6px;
    border: 1px solid var(--gt-line);
    border-radius: 2px;
    background: var(--gt-tint);
    color: var(--gt-navy);
    font-family: var(--gt-cond);
    font-size: 11px;
    font-weight: 600;
    letter-spacing: .06em;
    line-height: 18px;
    text-transform: uppercase;
}
.selectr-selected .selectr-tag-remove { right: 1px; width: 18px; height: 18px; }
.selectr-tag-remove::before, .selectr-tag-remove::after { top: 4px; left: 8px; width: 1.5px; height: 10px; background-color: var(--gt-navy); }
.selectr-options-container {
    border-color: transparent var(--gt-navy) var(--gt-navy);
    border-radius: 0 0 4px 4px;
    box-shadow: 0 8px 18px rgba(28, 30, 41, .14);
}
.selectr-option { padding: 5px 10px; }
.selectr-option.selected { background-color: var(--gt-tint); color: var(--gt-navy); }
.selectr-option.active { background-color: var(--gt-navy); color: #fff; }
.selectr-input { margin: 6px 8px; width: calc(100% - 16px); padding: 4px 8px; border: 1px solid var(--gt-field); border-radius: 4px; }

/* ---------- modals ----------------------------------------------------- */

.modal {
    --bs-modal-width: 460px;
    --bs-modal-border-radius: 4px;
    --bs-modal-inner-border-radius: 3px;
    --bs-modal-border-width: 0;
    --bs-modal-header-padding: 11px 16px 10px;
    --bs-modal-header-border-width: 0;
    --bs-modal-padding: 16px;
    --bs-modal-footer-gap: var(--gt-gap-btn);
    --bs-modal-footer-border-color: var(--gt-line);
    --bs-modal-box-shadow: 0 18px 48px rgba(20, 24, 45, .32);
}
.modal-content { box-shadow: var(--bs-modal-box-shadow); }
.modal-header {
    background: var(--gt-tint);
    border-bottom: 2px solid var(--gt-navy) !important;
}
.modal-title,
.modal-title.fs-5 {
    font-family: var(--gt-cond);
    font-size: 17px !important;
    font-weight: 600;
    line-height: 22px;
    color: var(--gt-navy);
}
.modal { text-align: start; }   /* a popup included inside a .text-end block (project «Добавить вложение») keeps its labels left */
.modal-body > .form-control { margin-bottom: 0; }
/* Django's file input with a current file («На данный момент: <a>»): the label on its own line, as above a field */
.modal-body label:has(+ a) { display: block; }
.modal-footer { padding: 10px 16px; background: var(--gt-zebra); }
.modal-footer { gap: var(--gt-gap-btn); }
.modal-footer > * { margin: 0; }
/* confirm popups (projects/forms/confirm-action-form): the buttons sit one level down, the text keeps the popup's padding */
.modal-footer > .d-flex > div { display: flex; flex-wrap: wrap; gap: var(--gt-gap-btn); }
.confirm-body:has(> :not(input[type=hidden])) { padding: var(--bs-modal-padding); }
/* a popup that lists links (Реквизиты, a contract's annexes): one target per line, apart */
.modal-body:has(> div > a:only-child) { padding-top: 10px; padding-bottom: 10px; }   /* the links' own padding makes up the rest */
.modal-body > div:has(> a:only-child) { margin: 0 !important; }
.modal-body > div > a:only-child { display: block; padding: var(--gt-gap-btn) 0; }
.btn-close { --bs-btn-close-opacity: .75; font-size: 11px; }   /* the icon is 1em */
.modal-backdrop { --bs-backdrop-bg: #141a30; --bs-backdrop-opacity: .55; }

/* ---------- other pages ------------------------------------------------ */

/* order / quotation page: the comment box (bg-white, which no longer shows on the white page) */
.comment-box {
    border: 1px dashed var(--gt-field);
    border-radius: 4px;
    background-color: #fcfbfe !important;
}
/* order page meta: info table | comment box | its pencil, spaced; the pencil keeps its own height */
.info-comment { gap: var(--gt-gap-m); align-items: flex-start; }
.info-comment > .comment-box { margin: 0 !important; }

/* supplier page (rfq-response): its head block, then the lines */
.rfq-response-head ~ .rfq-lines { margin-top: var(--gt-gap-m); }

/* tags page: chips apart, also when they wrap */
.tags-list { display: flex; flex-wrap: wrap; gap: var(--gt-gap-btn); }

/* row buttons in a table cell (✎ ×, + ✎ ×): the inline space plus a little, the row keeps its height */
.table > tbody > tr > td > .btn-sm + .btn-sm { margin-left: 3px; }

/* ---------- carried over (other pages) ---------------------------------- */

.tab-content { padding: 0 1rem; }                               /* from dashboard.css */
div.info-cards > .card { flex-basis: 0; flex-grow: 1; }          /* from dashboard.css */
.info-cards div.card { min-width: max-content; margin: 0; }      /* from main.css; the row's gap spaces them, edges line up with the title */
.info-cards { gap: var(--gt-gap-m); }
main.content .info-cards.mt-3 { margin-top: var(--gt-gap-l) !important; }   /* project: meta → cards, a block apart */
table.balance-table td { padding: 2px 5px; }                     /* from dashboard.css */
main.content > div > table.balance-table td:first-child { padding-left: 0; }   /* project meta: labels on the title's edge */

/* ---------- phone (<768px): same pages, stacked; wide tables scroll sideways in their own box ---------- */

@media (max-width: 767.98px) {
    /* the tighter spacing set: blocks sit a little closer on a small screen */
    :root { --gt-gap-m: 10px; --gt-gap-l: 14px; --gt-gap-xl: 18px; }
    /* the page scrolls, not a 100vh column: filters scroll away and the list gets the whole screen */
    main.content > .d-flex.flex-column { max-height: none !important; }
    /* .table-scroll = the box around a wide table (lists, spec, transactions): it scrolls sideways, the page does not */
    .table-scroll { overflow-x: auto !important; }
    .table-scroll > .table:not(.table-sm) { min-width: 640px; }
    .table-scroll > .table.price-lines { min-width: 720px; }      /* offer check: the source / party line keeps room to wrap */
    .tab-content { padding: 0; }

    /* rows of «filter | summary / + button» (.stack-phone) and the list toolbar stack */
    .stack-phone,
    .list-toolbar { flex-direction: column; align-items: stretch !important; gap: var(--gt-gap-s); }
    .stack-phone > *,
    .list-toolbar > div:first-child,
    .list-toolbar > div:last-child { flex: none !important; margin-left: 0 !important; }

    /* filter forms: text / period full width, a select shares its line with the buttons */
    form .ma-form-field,
    form .ma-form-field:has(> .d-flex) { flex: 1 1 100% !important; margin-right: 0 !important; }
    form .ma-form-field:has(> select) { flex: 1 1 120px !important; }
    form .ma-form-field > select.form-control { max-width: none; }
    form .ma-form-field > .d-flex > .form-control { flex: 1 1 0; min-width: 0; }
    form .ma-form-field.sum-field > .d-flex > .form-control:not(select) { flex: 1 1 0; min-width: 0; }   /* «Сумма» from / to share the line like «Период» (320px phones) */
    form .d-flex:has(> .ma-form-field) { column-gap: var(--gt-gap-s); justify-content: flex-end; }   /* a row left with only the buttons keeps them on the right */
    form .ma-form-field ~ .btn.mx-2 { margin-right: 0 !important; }
    /* a select shrinks to its line (touch: its 16px text would widen it to the longest option and push «Сбросить» down) */
    form .ma-form-field:has(> select) { min-width: 0; }
    form .ma-form-field > select.form-control { width: 100%; min-width: 0; }
    form .ma-form-field.lookup-k { flex: 0 0 64px !important; }
    /* two selects (projects: Автор, Статус): the first takes its line (a long name stays readable), the second
       shares the next one with the buttons, as on the offers list; price lookup: Поставщик + К, the buttons under them */
    form .ma-form-field:has(> select):has(+ .ma-form-field > select) { flex: 1 1 100% !important; }
    form .ma-form-field:has(> select):has(+ .lookup-k) { flex: 1 1 calc(100% - 72px) !important; }
    /* projects summary wraps: no «·» left at a line start */
    .list-count.projects-summary { column-gap: 14px; }
    .list-count.projects-summary > span + span::before { content: none; }

    .tags-list > .badge { --bs-badge-padding-x: 9px; --bs-badge-padding-y: 7px; }   /* a tag chip opens «Удалить»: finger-sized */
    /* offer editor: one field per line, editors full width, ИТОГО fits */
    .field-grid > div,
    .field-grid > .field-narrow,
    .field-grid > .field-wide { flex: 1 1 100% !important; min-width: 0 !important; border-left: 0; }
    .field-grid > div + div { border-top: 1px solid var(--gt-line); }
    .field-grid > div:first-child { padding-left: 12px; }
    .kp-texts > .m-1 { flex: 1 1 100% !important; min-width: 0 !important; }
    #spec-totals > div { min-width: min(330px, 100%); }
    /* the sticky action bar wraps onto a second line instead of running off the screen */
    #offer-actions,
    .form-actions { flex-wrap: wrap; padding: 8px 1.5rem !important; }
    #offer-actions > div,
    .form-actions > div { flex-wrap: wrap; }
    .form-actions { align-items: flex-end; }   /* «Удалить» beside a wrapped group sits on its last line, as on the offer */
    #offer-actions > div > .ms-3 { margin-left: 0 !important; }
    :root:has(#offer-actions, .form-actions) { scroll-padding-bottom: 130px; }   /* a wrapped bar is taller */

    /* project page: transactions keep their two action buttons on one line */
    #transactions .table-scroll > .table { min-width: 720px; }
    #transactions .table-scroll > .table > tbody > tr > td:last-child { white-space: nowrap; }
    /* project page: attachment pencil / × get a finger-sized target */
    #attachments span[onclick] { display: inline-block; padding: 6px; margin: -6px 0; }
}

/* touch screens: no hover, so «...» and × in the spec show as they do on a hovered row */
@media (hover: none) and (pointer: coarse) {
    #specification #spec-body td.description .btn-secondary {
        --bs-btn-color: var(--gt-navy);
        --bs-btn-border-color: var(--gt-field);
        --bs-btn-bg: #fff;
    }
    #specification #spec-body .delete-button.btn-danger { --bs-btn-border-color: #d6a19c; --bs-btn-bg: #fff; }
}

/* small phones (<576px): every popup is full-screen (bootstrap .modal-fullscreen-sm-down, without touching the markup) */
@media (max-width: 575.98px) {
    .modal-dialog { width: 100vw; max-width: none; height: 100%; margin: 0; }
    .modal-content { height: 100%; border: 0; border-radius: 0; }
    .modal-header,
    .modal-footer { border-radius: 0; }
    /* most popups put body + footer inside a <form>: it takes the height, the body scrolls, the footer sits at the bottom */
    .modal-content > form { display: flex; flex-direction: column; flex: 1 1 auto; min-height: 0; }
    .modal-body { overflow-y: auto; }
    .modal-footer { margin-top: auto; }
}

/* ---------- phone (<768px), Закупки: price lookup, RFQ, supplier page, orders ---------- */

@media (max-width: 767.98px) {
    /* a stacked row's boxes take the full width (an inline align-self, as on «+ RFQ», would centre one; a me-2 would shorten one) */
    .stack-phone > * { align-self: stretch !important; margin-right: 0 !important; }

    /* order page: the info table on its line, the comment box and its pencil under it */
    .info-comment { flex-wrap: wrap; row-gap: 10px; }
    .info-comment > table { flex: 1 1 100%; }
    .info-comment > .comment-box { margin-left: 0 !important; }
    /* order page: the read-only spec, events and attachments fit the screen (text wraps), their box scrolls only what still does not */
    .table-scroll.table-fit > .table { min-width: 0; }
    .table-scroll.table-fit > .table > :not(caption) > * > * { padding-left: 6px; padding-right: 6px; }
    /* order page: events and attachments keep their pencil and × side by side */
    #events .table > tbody > tr > td:last-child,
    #attachments .table > tbody > tr > td:last-child { white-space: nowrap; }

    /* public supplier page (rfq-response): each line is a card — the product, its quantity,
       price | delivery side by side, the comment; every cell under its column head (data-label) */
    .rfq-lines { display: block; border: 0; }
    .rfq-lines > thead { display: none; }
    .rfq-lines > tbody { display: block; }
    .rfq-lines > tbody > tr {
        display: grid;
        grid-template-columns: 1fr 1fr;
        align-items: start;
        gap: 8px 10px;
        padding: 10px 0 14px;
        border-bottom: 1px solid var(--gt-line);
    }
    .rfq-lines > tbody > tr:first-child { border-top: 2px solid var(--gt-navy); }
    .rfq-lines > tbody > tr > td { display: block; grid-column: 1 / -1; padding: 0 !important; border: 0 !important; }
    .rfq-lines > tbody > tr > td:first-child { font-size: 15px; font-weight: 600; color: var(--gt-navy); }
    .rfq-lines > tbody > tr > td:first-child > div { font-weight: 400; color: var(--gt-ink); }
    .rfq-lines > tbody > tr > td:first-child p:last-child { margin-bottom: 0; }
    .rfq-lines > tbody > tr > td.line-price,
    .rfq-lines > tbody > tr > td.line-delivery { grid-column: auto; }
    .rfq-lines > tbody > tr > td.line-comment:empty { display: none; }
    .rfq-lines > tbody > tr > td[data-label]::before {
        content: attr(data-label);
        display: block;
        margin-bottom: 4px;
        font-size: 10.5px;
        font-weight: 600;
        line-height: 14px;
        letter-spacing: .08em;
        text-transform: uppercase;
        color: var(--gt-accent);
    }
    .rfq-lines > tbody > tr > td.line-quantity::before { display: inline; margin-right: 8px; }
    /* price | delivery: both heads take two lines, so the boxes stay level when one head wraps (360px) */
    .rfq-lines > tbody > tr > td.line-price::before,
    .rfq-lines > tbody > tr > td.line-delivery::before { display: flex; align-items: flex-end; min-height: 28px; }
}

/* touch screens: no hover, so the row's hover-only button (RFQ list «Обзор», offers print preview) always shows */
@media (hover: none) and (pointer: coarse) {
    tr.link .secondary { display: inline; }
    tr.link div:has(> .secondary) > .primary { padding-right: 24px; }   /* the cell's text stops short of it («Пётр») */
}

/* ---------- phone, the rest: entities, products, transactions, user settings, popups ---------- */

@media (max-width: 767.98px) {
    /* login / sign-up: the card keeps the page gutter of the app pages, not bootstrap's 10px */
    section.vh-100 > .container { --bs-gutter-x: calc(2 * var(--gt-page-x)); }
    /* user settings: the name fields and the two КП editors (inline min-width 300 / 400px) take the full line each */
    .wrap-phone > * { flex: 1 1 100% !important; min-width: 0 !important; }
    /* products: the three row buttons sit closer and a long name may break anywhere, so the table fits a 360px phone */
    .products-table > tbody > tr > td:nth-child(2) { overflow-wrap: anywhere; }
    .products-table > tbody > tr > td:last-child .btn-sm { --bs-btn-padding-x: 7px; }
}

/* phones with a finger: 16px text in fields, or iOS Safari zooms the page into a field on focus
   (the viewport keeps zooming allowed: no maximum-scale) */
@media (max-width: 767.98px) and (pointer: coarse) {
    :root { --gt-gap-btn: 8px; }            /* neighbouring buttons: a finger's margin */
    .form-control,
    .form-select,
    select,
    textarea,
    .selectr-selected,
    .selectr-input,
    #specification #spec-body .form-control { font-size: 16px; }
}

@media (max-width: 575.98px) {
    /* «Реквизиты»: two links, no header and no ×, so it stays a small box (a tap beside it closes it) */
    #DetailsSelectModal .modal-dialog { width: auto; height: auto; margin: 56px 12px; }
    #DetailsSelectModal .modal-content { height: auto; border-radius: var(--bs-modal-border-radius); }
    #DetailsSelectModal .modal-body { padding-top: 6px; padding-bottom: 6px; }
    /* links in a popup (Реквизиты, a contract's annexes): finger-sized */
    .modal-body > div > a:only-child { padding: 8px 0; }
}

/* ---------- «Статистика» (templates/stats/offers.html, static/js/stats.js) ---------- */

/* entity tabs (КП now; contracts, orders later): condensed, navy; the active tab opens onto the filter strip under it */
.stats-tabs {
    --bs-nav-tabs-border-color: var(--gt-line);
    --bs-nav-tabs-link-active-bg: var(--gt-zebra);
    --bs-nav-tabs-link-active-color: var(--gt-navy);
    --bs-nav-tabs-link-active-border-color: var(--gt-line) var(--gt-line) var(--gt-zebra);
    --bs-nav-tabs-link-hover-border-color: var(--gt-tint) var(--gt-tint) var(--gt-line);
    --bs-nav-link-color: var(--gt-navy);
    --bs-nav-link-hover-color: var(--gt-navy);
    --bs-nav-link-padding-x: 14px;
    --bs-nav-link-padding-y: 5px;
    font-family: var(--gt-cond);
    font-size: 14px;
    font-weight: 500;
    letter-spacing: .01em;
}
.stats-tabs .nav-link.active { font-weight: 600; }

/* filter strip: two rows (period · dates · grouping / currency · author · tag · buttons), a form-row gap apart */
.stats-filter > .d-flex.flex-column { row-gap: var(--gt-gap-s); }
.stats-filter .ma-form-field > .d-flex > .form-control { flex-basis: 104px; }   /* the dates need less than the offers list's 142px */
/* segmented choice (Группировка, Валюта): radios in one box, the chosen one filled navy */
.stats-filter .ma-form-field:has(> .seg) { flex: 0 0 auto !important; }
.seg { display: inline-flex; }
.seg > .btn { --bs-btn-padding-x: 10px; margin: 0 !important; font-weight: 500; }   /* theme's «label + label» margin off */
.seg > .btn + .btn { margin-left: -1px !important; }
.seg > .btn:not(:last-child) { border-top-right-radius: 0; border-bottom-right-radius: 0; }
.seg > .btn:not(:first-of-type) { border-top-left-radius: 0; border-bottom-left-radius: 0; }
.seg > .btn-check:checked + .btn { --bs-btn-active-bg: var(--gt-navy); --bs-btn-active-color: #fff; --bs-btn-active-border-color: var(--gt-navy); position: relative; z-index: 1; }
.seg > .btn-check:focus-visible + .btn { outline: 2px solid var(--gt-navy); outline-offset: 2px; z-index: 2; }

/* the line under the strip: the period and its comparison range (.list-count look) */
.stats-range { padding-bottom: var(--gt-gap-s); }

/* blocks of the page: one card ↔ card gap apart */
.stats-block + .stats-block { margin-top: var(--gt-gap-m); }

/* KPI tiles: four figures in a row, 2×2 below 992px; each tile opens the offers of the period */
.kpi-row { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: var(--gt-gap-m); }
@media (max-width: 991.98px) { .kpi-row { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.kpi {
    display: block;
    padding: 8px 12px 10px;
    border: 1px solid var(--gt-line);
    border-top: 2px solid var(--gt-navy);
    border-radius: 0 0 4px 4px;
    background: #fff;
    color: var(--gt-ink);
    text-decoration: none;
}
.kpi:hover { background: var(--gt-zebra); border-color: var(--gt-field); border-top-color: var(--gt-navy); color: var(--gt-ink); }
.kpi:focus-visible { outline: 2px solid var(--gt-navy); outline-offset: 2px; }
/* tile label: the mauve micro-label of the fields; a chevron says «opens a list» (an arrow would read as a trend next to ▲/▼) */
.kpi-label { display: flex; justify-content: space-between; gap: var(--gt-gap-s); font-size: 10.5px; font-weight: 600; line-height: 14px; letter-spacing: .08em; text-transform: uppercase; color: var(--gt-accent); }
.kpi-label > i { color: var(--gt-muted); font-size: 12px; line-height: 14px; }
.kpi:hover .kpi-label > i { color: var(--gt-navy); }
/* the figure scales with its tile (container units), so a 10-digit RUB sum fits a narrow tile instead of running under the next one */
.kpi { container-type: inline-size; }
.kpi-value { margin-top: 3px; font-family: var(--gt-cond); font-size: clamp(18px, 15cqi, 30px); font-weight: 600; line-height: 1.15; color: var(--gt-navy); white-space: nowrap; }
/* г/г line: the change + the year-ago value; wraps under on a narrow tile */
.kpi-sub { display: flex; flex-wrap: wrap; column-gap: var(--gt-gap-s); margin-top: 2px; font-family: var(--gt-cond); font-size: 13px; line-height: 18px; color: var(--gt-muted); }

/* Δ г/г: arrow + sign + colour, never colour alone */
.delta { font-weight: 600; white-space: nowrap; }
.delta.up { color: var(--gt-green); }
.delta.down { color: var(--gt-red); }
.delta.flat { color: var(--gt-muted); font-weight: 500; }

/* card = a framed block with an h4 head (theme h4: condensed navy capitals) */
.stats-card { min-width: 0; padding: 10px 12px 12px; border: 1px solid var(--gt-line); border-radius: 4px; background: #fff; }
.stats-card-head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: var(--gt-gap-xs) var(--gt-gap-l); margin-bottom: var(--gt-gap-s); }
.stats-card-head h4 { margin: 0; }
.stats-card-head .sub { margin-left: var(--gt-gap-s); font-family: var(--gt-cond); font-size: 12.5px; color: var(--gt-muted); letter-spacing: .02em; }

/* chart legend (HTML, so it wraps and reads without colour: the shapes differ) */
.chart-legend { display: flex; flex-wrap: wrap; gap: var(--gt-gap-xs) var(--gt-gap-l); margin: 0; padding: 0; list-style: none; font-family: var(--gt-cond); font-size: 13px; line-height: 18px; color: var(--gt-ink); }
.chart-legend li { display: inline-flex; align-items: center; gap: var(--gt-gap-btn); }
.sw { flex: none; width: 12px; height: 12px; border-radius: 2px; }
.sw-cur { background: #26345f; }
.sw-prev { background: #b4abd9; box-shadow: inset 0 0 0 1px #8f86bf; }   /* lavender is 2.1:1 on white: a darker rim, as on the bars */
.sw-line { position: relative; width: 18px; height: 2px; border-radius: 0; background: #84507a; }
.sw-line::after { content: ''; position: absolute; left: 5px; top: -3px; width: 8px; height: 8px; border: 2px solid #84507a; border-radius: 50%; background: #fff; }

/* canvas boxes: fixed height, the width follows the card; the tags chart has one 30px band per table row */
.chart-box { position: relative; height: 320px; }
.chart-box.tags { height: calc(var(--tag-rows, 7) * 30px + 28px); }

/* under the chart: the click hint (left) and the table (right; it opens full width) */
.chart-foot { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: baseline; gap: var(--gt-gap-xs) var(--gt-gap-m); margin-top: var(--gt-gap-s); font-family: var(--gt-cond); font-size: 12.5px; line-height: 18px; color: var(--gt-muted); }
.chart-foot > details { min-width: 0; }   /* the open table scrolls in its box, not the page (phone) */
.chart-foot > details[open] { flex: 1 1 100%; }
.chart-foot summary { color: var(--bs-link-color); cursor: pointer; text-align: right; }
.chart-foot summary:hover { color: var(--bs-link-hover-color); text-decoration: underline; }
.chart-foot summary:focus-visible { outline: 2px solid var(--gt-navy); outline-offset: 2px; }
.chart-foot details > .table-scroll { margin-top: var(--gt-gap-s); }

/* figure cells: right-aligned, never wrapped; row links read as ink (the whole row is the link, tr.link) */
.stats-page .table .num { text-align: right; white-space: nowrap; }
.stats-page .table a.row-link { color: var(--gt-ink); text-decoration: none; }
.stats-page .table a.row-link:hover { color: var(--gt-navy); text-decoration: underline; }
.stats-page .table td.untagged { font-style: italic; color: var(--gt-muted); }
.stats-page .table td.untagged a.row-link { color: var(--gt-muted); }
/* «Итого»: tinted like the head, a navy rule on top */
.stats-page .table > tfoot > tr > * { background: var(--gt-tint); font-weight: 600; color: var(--gt-navy); box-shadow: inset 0 1px 0 var(--gt-navy); }

/* «Доля»: a thin navy bar on a tint track + the percent */
.share { display: flex; align-items: center; gap: var(--gt-gap-btn); min-width: 84px; }
.share-track { flex: 1 1 auto; height: 6px; border-radius: 3px; background: var(--gt-tint); overflow: hidden; }
.share-fill { display: block; height: 100%; border-radius: 3px; background: var(--gt-navy); }
.share-val { flex: 0 0 44px; text-align: right; }

/* authors | tags: side by side, one per line below 1200px (a half-width card is narrower than the authors table there) */
.stats-split { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--gt-gap-m); align-items: stretch; }
@media (max-width: 1199.98px) { .stats-split { grid-template-columns: minmax(0, 1fr); } }
.stats-card .table-scroll { overflow-x: auto; }   /* a table wider than its card scrolls in its own box */

/* tags card: chart | table side by side when the card is wide enough, else chart over table */
.tags-card { container-type: inline-size; }
.tags-body { display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--gt-gap-m); }   /* a 0-min column: the canvas width must not hold it open */
@container (min-width: 520px) {
    .tags-body { grid-template-columns: minmax(0, 1fr) minmax(0, max-content); align-items: start; }
    /* each bar sits on its table row: the plot = the table body (29px head, 30px rows; Chart.js insets the plot 13.5px) */
    .tags-body > .chart-box.tags { height: calc(var(--tag-rows, 7) * 30px + 27px); margin: 16.5px 0 -14.5px; }
}

/* products: rank, the name with its vendor code (muted, condensed), figures packed on the right */
.stats-page .table td.rank { width: 1%; color: var(--gt-muted); text-align: right; }
.prod-code { margin-left: var(--gt-gap-s); font-family: var(--gt-cond); font-size: 12px; color: var(--gt-muted); letter-spacing: .02em; white-space: nowrap; }
.prod-table { min-width: 640px; }
.prod-table td.num, .prod-table th.num { width: 1%; padding-left: 28px; }
.stats-empty { margin: 0; color: var(--gt-muted); }

/* small muted notes: the tag overlap, the authors hint, the products rule, the page footnote */
.stats-note { margin: var(--gt-gap-s) 0 0; font-family: var(--gt-cond); font-size: 12.5px; line-height: 17px; color: var(--gt-muted); }
.stats-note > i { margin-right: 4px; }
.stats-foot { margin: var(--gt-gap-l) 0 0; padding-top: var(--gt-gap-s); border-top: 1px solid var(--gt-line); }

/* phone (<768px): tiles 2×2, a shorter chart, tighter cards; segmented buttons share the line evenly */
@media (max-width: 767.98px) {
    .kpi-row { gap: var(--gt-gap-s); }
    .kpi { padding: 7px 10px 9px; }
    .stats-card { padding: 8px 10px 10px; }
    .chart-box { height: 230px; }
    .stats-card-head .sub { display: block; margin: 2px 0 0; }
    .stats-filter .ma-form-field:has(> .seg) { flex: 1 1 100% !important; }   /* Группировка, Валюта: a full line, as a text field */
    .seg { display: flex; }
    .seg > .btn { flex: 1 1 0; }
    /* the range line wraps by item, no «·» at a line start (as .projects-summary) */
    .stats-range { display: flex; flex-wrap: wrap; column-gap: 14px; row-gap: 2px; }
    .stats-range > span + span::before { content: none; }
}

/* ---------- ЦБ rates line (templates/common/rates-line.html): black, on top of every logged-in page ---------- */
/* .rates-line keeps its 26px in the page flow, .rates-line-bar is fixed over it; pages under it move down by its height */
:root { --gt-rates-h: 26px; }
.rates-line { height: var(--gt-rates-h); }
.rates-line-bar {
    position: fixed; top: 0; left: 0; right: 0;
    z-index: 1030;                          /* bootstrap's .fixed-top level: over the sidebar (100), sticky bars (20), dropdowns (1000); under offcanvas, modals */
    display: flex; align-items: center; gap: 18px;
    height: var(--gt-rates-h);
    padding: 0 14px;
    overflow: hidden;
    white-space: nowrap;
    background: #111318;
    color: #f2f1f6;
    font: 500 12.5px/1 var(--gt-cond);
    font-variant-numeric: tabular-nums;
}
.rates-line-title { color: #a9a6ba; }
.rates-line-code { margin-right: 5px; color: var(--gt-lav); }
.rates-line-change { margin-left: 5px; font-size: 11.5px; }
.rates-line-change.up { color: #6fcf97; }
.rates-line-change.down { color: #f28b82; }
.rates-line-change.same { color: #a9a6ba; }
.rates-line-change > span { margin-left: 2px; }
@media screen and (min-width: 768px) {
    /* the fixed sidebar starts under the line; the 100vh page column (lists, КП) is 100vh minus the line (not in print: no line there) */
    .rates-line ~ * nav.sidebar { top: var(--gt-rates-h); }
    .rates-line ~ * nav.sidebar .sidebar-sticky { height: calc(100vh - var(--gt-rates-h)); }
    .rates-line ~ * main.content > [style*="max-height: 100vh"] { max-height: calc(100vh - var(--gt-rates-h)) !important; }
}
@media screen and (min-width: 1100px) {
    /* a sticky table head held by the page, not by its own scroll box (RFQ answers): it stops under the line */
    .rates-line ~ * .table-scroll:not([style]) > table.fixed-header th { top: var(--gt-rates-h); }
}
@media (max-width: 767.98px) {
    .rates-line-bar { gap: 12px; padding: 0 12px; }
}
@media (max-width: 374.98px) {
    .rates-line-bar { gap: 8px; padding: 0 8px; }      /* 320–374px phones: the last arrow still fits */
}
@media print {
    .rates-line { display: none; }
}
