/* ============================================================
   Учёт инструментов — design system v2
   Mobile-first. Industrial palette. Bottom tab bar.
   ============================================================ */

/* -------- 1. Tokens -------- */
:root {
    color-scheme: dark;
    /* surfaces */
    --bg:           #0b0e13;
    --surface:      #131820;
    --surface-2:    #1a212b;
    --surface-3:    #242c38;
    --overlay:      rgba(11, 14, 19, 0.72);
    /* text */
    --text:         #e9edf2;
    --text-2:       #aab1bd;
    --text-3:       #6f7886;
    /* lines */
    --line:         #232a36;
    --line-strong:  #2e3744;
    /* accent (industrial orange) */
    --accent:       #f97316;
    --accent-2:     #c2410c;
    --accent-soft:  rgba(249, 115, 22, 0.16);
    --accent-fg:    #0b0e13;
    /* status */
    --ok:           #22c55e;
    --ok-soft:      rgba(34, 197, 94, 0.14);
    --warn:         #eab308;
    --warn-soft:    rgba(234, 179, 8, 0.14);
    --info:         #38bdf8;
    --info-soft:    rgba(56, 189, 248, 0.14);
    --bad:          #ef4444;
    --bad-soft:     rgba(239, 68, 68, 0.14);
    /* shadows */
    --shadow-1:     0 1px 2px rgba(0, 0, 0, 0.32);
    --shadow-2:     0 8px 24px rgba(0, 0, 0, 0.32);
    --shadow-3:     0 18px 48px rgba(0, 0, 0, 0.42);
    /* radii */
    --r-sm:         8px;
    --r-md:         12px;
    --r-lg:         16px;
    --r-xl:         20px;
    --r-pill:       999px;
    /* spacing scale (4px base) */
    --s-1:          4px;
    --s-2:          8px;
    --s-3:          12px;
    --s-4:          16px;
    --s-5:          20px;
    --s-6:          24px;
    --s-8:          32px;
    --s-10:         40px;
    /* type */
    --font:         system-ui, -apple-system, "Segoe UI", "Inter", Roboto, "Helvetica Neue", Arial, sans-serif;
    --font-mono:    ui-monospace, "SF Mono", Menlo, Consolas, monospace;
    /* layout */
    --appbar-h:     56px;
    --tabbar-h:     64px;
    --content-max:  1200px;
}
body.light-theme {
    color-scheme: light;
    --bg:           #f4f5f7;
    --surface:      #ffffff;
    --surface-2:    #f8f9fb;
    --surface-3:    #eef0f4;
    --overlay:      rgba(15, 17, 22, 0.42);
    --text:         #0f172a;
    --text-2:       #475569;
    --text-3:       #94a3b8;
    --line:         #e5e7eb;
    --line-strong:  #cbd5e1;
    --accent:       #ea580c;
    --accent-2:     #9a3412;
    --accent-soft:  rgba(234, 88, 12, 0.12);
    --accent-fg:    #ffffff;
    --ok:           #15803d;
    --ok-soft:      rgba(21, 128, 61, 0.10);
    --warn:         #b45309;
    --warn-soft:    rgba(180, 83, 9, 0.10);
    --info:         #0369a1;
    --info-soft:    rgba(3, 105, 161, 0.08);
    --bad:          #b91c1c;
    --bad-soft:     rgba(185, 28, 28, 0.08);
    --shadow-1:     0 1px 2px rgba(15, 17, 22, 0.06);
    --shadow-2:     0 8px 24px rgba(15, 17, 22, 0.08);
    --shadow-3:     0 18px 48px rgba(15, 17, 22, 0.12);
}

/* -------- 2. Reset -------- */
*, *::before, *::after { box-sizing: border-box; }
html, body { overflow-x: hidden; }
html { -webkit-text-size-adjust: 100%; }
body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: var(--font);
    font-size: 15px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    -webkit-tap-highlight-color: transparent;
    min-height: 100vh;
    padding-bottom: env(safe-area-inset-bottom);
}
h1, h2, h3, h4, h5 { margin: 0; line-height: 1.25; color: var(--text); font-weight: 700; }
h1 { font-size: 22px; }
h2 { font-size: 18px; }
h3 { font-size: 16px; }
p { margin: 0; }
a { color: var(--accent); text-decoration: none; }
a:hover, a:focus-visible { color: var(--accent-2); text-decoration: none; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
img { max-width: 100%; display: block; }
hr { border: 0; border-top: 1px solid var(--line); margin: var(--s-3) 0; }
::selection { background: var(--accent-soft); color: var(--text); }

/* -------- 3. Layout -------- */
.shell {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}
.appbar {
    position: sticky; top: 0; z-index: 100;
    background: var(--surface);
    border-bottom: 1px solid var(--line);
    height: var(--appbar-h);
    display: flex;
    align-items: center;
}
.appbar__inner {
    width: 100%;
    max-width: var(--content-max);
    margin: 0 auto;
    padding: 0 var(--s-4);
    display: flex;
    align-items: center;
    gap: var(--s-3);
}
.appbar__brand {
    display: inline-flex;
    align-items: center;
    gap: var(--s-2);
    color: var(--text);
    font-weight: 700;
    font-size: 15px;
    letter-spacing: -0.01em;
}
.appbar__brand i { color: var(--accent); font-size: 18px; }
.appbar__title {
    font-weight: 700;
    font-size: 16px;
    margin: 0 auto 0 0;
    flex: 1;
    min-width: 0;
    text-overflow: ellipsis;
    overflow: hidden;
    white-space: nowrap;
}
.appbar__actions {
    display: flex;
    gap: var(--s-2);
    margin-left: auto;
    align-items: center;
}
.main {
    flex: 1;
    width: 100%;
    max-width: var(--content-max);
    margin: 0 auto;
    padding: var(--s-4) var(--s-4) calc(var(--tabbar-h) + var(--s-6) + env(safe-area-inset-bottom));
    display: flex;
    flex-direction: column;
    gap: var(--s-4);
}
@media (min-width: 992px) {
    .main { padding-bottom: var(--s-6); }
}

/* -------- 4. Tab bar (mobile) + drawer (desktop) -------- */
.tabbar {
    position: fixed;
    bottom: 0; left: 0; right: 0;
    z-index: 100;
    background: var(--surface);
    border-top: 1px solid var(--line);
    padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
    display: flex;
    box-shadow: 0 -8px 24px rgba(0, 0, 0, 0.14);
}
.tabbar__item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    padding: 6px 4px;
    color: var(--text-2);
    font-size: 11px;
    font-weight: 600;
    text-decoration: none;
    border-radius: var(--r-sm);
    line-height: 1;
    min-height: 52px;
}
.tabbar__item i { font-size: 20px; }
.tabbar__item.is-active { color: var(--accent); }
.tabbar__item.is-active i { color: var(--accent); }
.tabbar__item:hover, .tabbar__item:focus-visible {
    background: var(--surface-2);
    color: var(--text);
    text-decoration: none;
}
@media (min-width: 992px) {
    .tabbar { display: none; }
}

/* desktop nav (inline in appbar) */
.dnav { display: none; }
@media (min-width: 992px) {
    .dnav {
        display: flex;
        gap: 2px;
        flex: 1;
        justify-content: center;
    }
    .dnav__item {
        display: inline-flex;
        align-items: center;
        gap: 6px;
        padding: 8px 12px;
        border-radius: var(--r-sm);
        color: var(--text-2);
        font-weight: 600;
        font-size: 14px;
    }
    .dnav__item i { font-size: 16px; }
    .dnav__item:hover, .dnav__item:focus-visible {
        background: var(--surface-2);
        color: var(--text);
        text-decoration: none;
    }
    .dnav__item.is-active {
        background: var(--accent-soft);
        color: var(--accent);
    }
}

/* -------- 5. Buttons -------- */
.btn {
    --btn-pad-y: 10px;
    --btn-pad-x: 14px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: var(--btn-pad-y) var(--btn-pad-x);
    border-radius: var(--r-md);
    border: 1px solid transparent;
    background: var(--surface-2);
    color: var(--text);
    font-family: inherit;
    font-size: 14px;
    font-weight: 600;
    line-height: 1.2;
    cursor: pointer;
    transition: background 0.12s, color 0.12s, border-color 0.12s, transform 0.05s;
    text-decoration: none;
    min-height: 40px;
    white-space: nowrap;
}
.btn:hover, .btn:focus-visible {
    background: var(--surface-3);
    color: var(--text);
    text-decoration: none;
}
.btn:active { transform: translateY(1px); }
.btn:disabled, .btn.is-disabled { opacity: 0.55; cursor: not-allowed; }
.btn i { font-size: 16px; }
.btn--sm { --btn-pad-y: 6px; --btn-pad-x: 10px; min-height: 32px; font-size: 13px; }
.btn--lg { --btn-pad-y: 12px; --btn-pad-x: 18px; min-height: 48px; font-size: 15px; }
.btn--block { width: 100%; }
.btn--primary {
    background: var(--accent);
    border-color: var(--accent);
    color: var(--accent-fg);
}
.btn--primary:hover, .btn--primary:focus-visible {
    background: var(--accent-2);
    border-color: var(--accent-2);
    color: var(--accent-fg);
}
.btn--ghost {
    background: transparent;
    border-color: var(--line-strong);
    color: var(--text);
}
.btn--ghost:hover, .btn--ghost:focus-visible {
    background: var(--surface-2);
    border-color: var(--line-strong);
}
.btn--danger {
    background: var(--bad);
    border-color: var(--bad);
    color: #fff;
}
.btn--danger:hover, .btn--danger:focus-visible {
    background: #b91c1c;
    border-color: #b91c1c;
    color: #fff;
}
.btn--danger-ghost {
    background: transparent;
    border-color: rgba(239, 68, 68, 0.45);
    color: var(--bad);
}
.btn--danger-ghost:hover, .btn--danger-ghost:focus-visible {
    background: var(--bad-soft);
    border-color: var(--bad);
}
.btn--ok {
    background: var(--ok);
    border-color: var(--ok);
    color: #fff;
}
.btn--icon {
    width: 40px;
    padding: 0;
    flex-shrink: 0;
}
.btn--icon.btn--sm { width: 32px; }
.btn--link {
    background: transparent;
    border: 0;
    color: var(--accent);
    padding: 6px 0;
    min-height: 0;
}
.btn--link:hover { color: var(--accent-2); text-decoration: underline; background: transparent; }

/* FAB */
.fab {
    position: fixed;
    right: 20px;
    bottom: calc(var(--tabbar-h) + 16px + env(safe-area-inset-bottom));
    z-index: 90;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: var(--accent);
    color: var(--accent-fg);
    border: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--shadow-3);
    cursor: pointer;
    font-size: 24px;
}
.fab:hover, .fab:focus-visible {
    background: var(--accent-2);
    color: var(--accent-fg);
}
@media (min-width: 992px) {
    .fab { bottom: 24px; right: 24px; }
}

/* -------- 6. Cards / sections -------- */
.card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--r-lg);
    overflow: hidden;
}
.card--pad { padding: var(--s-4); }
.card--pad-lg { padding: var(--s-5); }
.card__header {
    padding: var(--s-3) var(--s-4);
    border-bottom: 1px solid var(--line);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--s-3);
}
.card__title { font-size: 15px; font-weight: 700; margin: 0; }
.card__body { padding: var(--s-4); }
.card__footer {
    padding: var(--s-3) var(--s-4);
    border-top: 1px solid var(--line);
    display: flex;
    gap: var(--s-2);
    align-items: center;
}

.section {
    display: flex;
    flex-direction: column;
    gap: var(--s-3);
}
.section__head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--s-2);
}
.section__title { font-size: 16px; font-weight: 700; margin: 0; }
.section__sub { color: var(--text-2); font-size: 13px; margin: 2px 0 0; }
.section__counter {
    font-size: 12px;
    color: var(--text-2);
    background: var(--surface-2);
    padding: 2px 8px;
    border-radius: var(--r-pill);
    font-weight: 600;
}

/* -------- 7. Page header -------- */
.phead {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: var(--s-3);
    padding-bottom: var(--s-2);
}
.phead__main { flex: 1; min-width: 0; }
.phead__title { font-size: 22px; font-weight: 800; margin: 0 0 4px; letter-spacing: -0.01em; }
.phead__sub { color: var(--text-2); font-size: 14px; margin: 0; }
.phead__actions { display: flex; gap: var(--s-2); flex-shrink: 0; }
@media (min-width: 768px) {
    .phead__title { font-size: 26px; }
}

/* metric strip */
.metrics {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: var(--s-2);
}
.metric {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--r-md);
    padding: var(--s-3);
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.metric__label { font-size: 11px; color: var(--text-2); text-transform: uppercase; letter-spacing: 0.06em; font-weight: 700; }
.metric__value { font-size: 22px; font-weight: 800; color: var(--text); line-height: 1.1; }
.metric__sub { font-size: 12px; color: var(--text-2); }

/* -------- 8. Forms -------- */
.field { display: flex; flex-direction: column; gap: 6px; }
.field__label {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-2);
}
.field__hint { font-size: 12px; color: var(--text-3); }
.field__hint--warn { color: var(--warn); }

.input, .select, .textarea,
.form-control, .form-select {
    width: 100%;
    background: var(--surface-2);
    color: var(--text);
    border: 1px solid var(--line);
    border-radius: var(--r-md);
    padding: 10px 12px;
    font-family: inherit;
    font-size: 15px;
    line-height: 1.4;
    min-height: 40px;
    transition: border-color 0.12s, box-shadow 0.12s;
}
.input:focus, .select:focus, .textarea:focus,
.form-control:focus, .form-select:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-soft);
    background: var(--surface-2);
    color: var(--text);
}
.input::placeholder, .textarea::placeholder, .form-control::placeholder {
    color: var(--text-3);
}
.textarea { min-height: 96px; resize: vertical; }
.input--sm, .form-control-sm, .form-select-sm {
    padding: 6px 10px;
    font-size: 13px;
    min-height: 32px;
    border-radius: var(--r-sm);
}

/* input with leading icon */
.input-grp {
    position: relative;
    display: flex;
    align-items: stretch;
}
.input-grp i.bi {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-3);
    pointer-events: none;
    font-size: 16px;
}
.input-grp .input,
.input-grp .form-control,
.input-grp .form-select { padding-left: 38px; }

/* native bootstrap input-group bridge — we keep markup, override looks */
.input-group {
    display: flex;
    align-items: stretch;
    width: 100%;
}
.input-group > .form-control,
.input-group > .form-select,
.input-group > .input,
.input-group > .select {
    flex: 1 1 auto;
    border-radius: 0 var(--r-md) var(--r-md) 0;
    border-left: 0;
}
.input-group > :first-child {
    border-top-left-radius: var(--r-md);
    border-bottom-left-radius: var(--r-md);
}
.input-group > :last-child {
    border-top-right-radius: var(--r-md);
    border-bottom-right-radius: var(--r-md);
}
.input-group-text {
    display: inline-flex;
    align-items: center;
    background: var(--surface-2);
    border: 1px solid var(--line);
    border-right: 0;
    color: var(--text-3);
    padding: 0 12px;
    font-size: 14px;
}
.input-group .btn { border-radius: 0; }
.input-group > .btn:last-child { border-top-right-radius: var(--r-md); border-bottom-right-radius: var(--r-md); }

/* file input */
.file-drop {
    display: block;
    position: relative;
    padding: var(--s-4);
    background: var(--surface-2);
    border: 1px dashed var(--line-strong);
    border-radius: var(--r-md);
    color: var(--text-2);
    text-align: center;
    cursor: pointer;
    font-size: 13px;
    transition: border-color 0.12s, background 0.12s;
}
.file-drop:hover { border-color: var(--accent); background: var(--accent-soft); }
.file-drop input[type="file"] { display: block; margin: 6px auto 0; color: var(--text-2); }

/* checkbox / switch */
.check {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    user-select: none;
}
.check input[type="checkbox"], .form-check-input {
    appearance: none;
    width: 18px;
    height: 18px;
    border: 1.5px solid var(--line-strong);
    border-radius: 4px;
    background: var(--surface-2);
    cursor: pointer;
    position: relative;
    flex-shrink: 0;
    transition: background 0.12s, border-color 0.12s;
}
.check input[type="checkbox"]:checked, .form-check-input:checked {
    background: var(--accent);
    border-color: var(--accent);
}
.check input[type="checkbox"]:checked::after, .form-check-input:checked::after {
    content: "";
    position: absolute;
    left: 5px;
    top: 1px;
    width: 5px;
    height: 9px;
    border: 2px solid var(--accent-fg);
    border-top: 0;
    border-left: 0;
    transform: rotate(45deg);
}
.form-check-input[type="radio"] { border-radius: 50%; }
.form-check-input[type="radio"]:checked::after { border-radius: 50%; left: 3px; top: 3px; width: 8px; height: 8px; background: var(--accent-fg); transform: none; border: 0; }
.form-switch .form-check-input {
    width: 36px;
    height: 20px;
    border-radius: var(--r-pill);
    background: var(--surface-3);
    border: 1.5px solid var(--line-strong);
}
.form-switch .form-check-input::after {
    content: "";
    position: absolute;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: var(--text-2);
    top: 1px;
    left: 1px;
    transition: transform 0.16s, background 0.16s;
    border: 0;
    transform: none;
}
.form-switch .form-check-input:checked { background: var(--accent); border-color: var(--accent); }
.form-switch .form-check-input:checked::after { transform: translateX(16px); background: #fff; border: 0; left: 1px; top: 1px; }

input[type="number"]::-webkit-outer-spin-button,
input[type="number"]::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
input[type="number"] { -moz-appearance: textfield; }

/* -------- 9. Search bar -------- */
.searchbar {
    display: flex;
    align-items: stretch;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--r-md);
    overflow: hidden;
}
.searchbar__icon {
    padding: 0 12px;
    display: inline-flex;
    align-items: center;
    color: var(--text-3);
    font-size: 16px;
}
.searchbar input {
    flex: 1;
    background: transparent;
    border: 0;
    padding: 10px 8px;
    color: var(--text);
    font-size: 15px;
    min-height: 40px;
}
.searchbar input:focus { outline: none; }
.searchbar__action {
    padding: 0 12px;
    background: transparent;
    border: 0;
    color: var(--text-2);
    cursor: pointer;
}
.searchbar__action:hover { color: var(--text); }

/* -------- 10. Chips (filter chips) -------- */
.chips {
    display: flex;
    gap: var(--s-2);
    flex-wrap: wrap;
}
.chips--scroll {
    flex-wrap: nowrap;
    overflow-x: auto;
    padding-bottom: 4px;
    margin: 0 calc(-1 * var(--s-4));
    padding-left: var(--s-4);
    padding-right: var(--s-4);
    -ms-overflow-style: none;
    scrollbar-width: none;
}
.chips--scroll::-webkit-scrollbar { display: none; }
.chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    border-radius: var(--r-pill);
    background: var(--surface);
    border: 1px solid var(--line);
    color: var(--text-2);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    white-space: nowrap;
    transition: background 0.12s, border-color 0.12s, color 0.12s;
}
.chip:hover, .chip:focus-visible {
    background: var(--surface-2);
    color: var(--text);
    text-decoration: none;
}
.chip.is-active {
    background: var(--accent-soft);
    border-color: var(--accent);
    color: var(--accent);
}
.chip__count {
    background: var(--surface-2);
    color: var(--text-2);
    font-size: 11px;
    padding: 1px 6px;
    border-radius: var(--r-pill);
    font-weight: 700;
}
.chip.is-active .chip__count { background: rgba(0, 0, 0, 0.18); color: var(--accent-fg); }

/* -------- 11. Lists (data rows) -------- */
.tlist { display: flex; flex-direction: column; gap: 0; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); overflow: hidden; }
.trow {
    display: flex;
    align-items: center;
    gap: var(--s-3);
    padding: var(--s-3) var(--s-4);
    border-bottom: 1px solid var(--line);
    text-decoration: none;
    color: var(--text);
    transition: background 0.12s;
}
.trow:last-child { border-bottom: 0; }
.trow:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.trow__avatar {
    width: 40px; height: 40px;
    border-radius: var(--r-md);
    background: var(--surface-2);
    color: var(--text-2);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    flex-shrink: 0;
}
.trow__avatar--img { padding: 0; overflow: hidden; }
.trow__avatar--img img { width: 100%; height: 100%; object-fit: cover; display: block; }
.trow__main { flex: 1; min-width: 0; }
.trow__title {
    font-weight: 600;
    font-size: 15px;
    color: var(--text);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.trow__sub {
    font-size: 13px;
    color: var(--text-2);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.trow__meta {
    display: flex;
    flex-direction: column;
    gap: 4px;
    align-items: flex-end;
    flex-shrink: 0;
    font-size: 12px;
    color: var(--text-2);
    text-align: right;
}
.trow__chevron { color: var(--text-3); font-size: 18px; flex-shrink: 0; }

/* -------- 12. Status chips/badges -------- */
.status {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    font-weight: 600;
    padding: 3px 9px;
    border-radius: var(--r-pill);
    background: var(--surface-2);
    color: var(--text-2);
    border: 1px solid var(--line);
    line-height: 1.2;
    white-space: nowrap;
}
.status::before {
    content: "";
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: currentColor;
}
.status--ok    { color: var(--ok);   background: var(--ok-soft);   border-color: transparent; }
.status--warn  { color: var(--warn); background: var(--warn-soft); border-color: transparent; }
.status--info  { color: var(--info); background: var(--info-soft); border-color: transparent; }
.status--bad   { color: var(--bad);  background: var(--bad-soft);  border-color: transparent; }
.status--accent{ color: var(--accent); background: var(--accent-soft); border-color: transparent; }

/* legacy bootstrap badge bridge */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 8px;
    border-radius: var(--r-pill);
    font-size: 11px;
    font-weight: 700;
    line-height: 1.4;
}
.badge.bg-secondary { background: var(--surface-2) !important; color: var(--text-2) !important; }
.badge.bg-primary   { background: var(--accent-soft) !important; color: var(--accent) !important; }
.badge.bg-success   { background: var(--ok-soft) !important; color: var(--ok) !important; }
.badge.bg-info      { background: var(--info-soft) !important; color: var(--info) !important; }
.badge.bg-warning   { background: var(--warn-soft) !important; color: var(--warn) !important; }
.badge.bg-danger    { background: var(--bad-soft) !important; color: var(--bad) !important; }
.badge.bg-dark      { background: var(--surface-3) !important; color: var(--text) !important; }
.badge.text-dark    { color: var(--text) !important; }

/* -------- 13. Alerts -------- */
.alert {
    display: flex;
    align-items: flex-start;
    gap: var(--s-3);
    padding: var(--s-3) var(--s-4);
    border-radius: var(--r-md);
    border: 1px solid var(--line);
    background: var(--surface);
    color: var(--text);
    font-size: 14px;
    margin: 0;
}
.alert .btn-close, .alert button.btn-close { margin-left: auto; }
.alert-success { border-left: 3px solid var(--ok);   background: var(--ok-soft); }
.alert-info    { border-left: 3px solid var(--info); background: var(--info-soft); }
.alert-warning { border-left: 3px solid var(--warn); background: var(--warn-soft); }
.alert-danger  { border-left: 3px solid var(--bad);  background: var(--bad-soft); }
.alert-secondary { border-left: 3px solid var(--line-strong); }
.btn-close {
    appearance: none;
    background: none;
    border: 0;
    color: var(--text-2);
    cursor: pointer;
    width: 28px; height: 28px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--r-sm);
    flex-shrink: 0;
    /* nuke bootstrap's bg image */
    background-image: none !important;
    opacity: 1;
}
.btn-close::before {
    content: "\f659";
    font-family: bootstrap-icons;
    font-size: 14px;
}
.btn-close:hover { background: var(--surface-2); color: var(--text); }

/* -------- 14. Modal / sheet -------- */
.modal-content {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--r-xl);
    color: var(--text);
    box-shadow: var(--shadow-3);
    overflow: hidden;
}
.modal-header {
    background: var(--surface);
    border-bottom: 1px solid var(--line);
    padding: var(--s-3) var(--s-4);
}
.modal-header .modal-title { font-size: 16px; font-weight: 700; margin: 0; }
.modal-body { padding: var(--s-4); }
.modal-footer { background: var(--surface); border-top: 1px solid var(--line); padding: var(--s-3) var(--s-4); gap: var(--s-2); }
.modal-backdrop.show { background: var(--overlay); opacity: 1; }
@media (max-width: 575.98px) {
    .modal-dialog { margin: 0; padding: 0; }
    .modal-content {
        border-radius: var(--r-xl) var(--r-xl) 0 0;
        margin-top: auto;
        max-height: 92vh;
    }
    .modal-dialog {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        max-width: 100%;
        display: flex;
        flex-direction: column;
        justify-content: flex-end;
    }
}

/* -------- 15. Dropdown -------- */
.dropdown-menu {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--r-md);
    color: var(--text);
    box-shadow: var(--shadow-2);
    padding: 4px;
    min-width: 200px;
}
.dropdown-item {
    color: var(--text);
    padding: 8px 12px;
    border-radius: var(--r-sm);
    font-size: 14px;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 8px;
}
.dropdown-item:hover, .dropdown-item:focus-visible {
    background: var(--surface-2);
    color: var(--text);
}
.dropdown-item.text-danger { color: var(--bad) !important; }
.dropdown-item.text-danger:hover { background: var(--bad-soft); color: var(--bad) !important; }
.dropdown-divider { border-color: var(--line); margin: 4px 0; }
.dropdown-toggle::after { color: var(--text-3); }

/* -------- 16. Tables -------- */
.table-responsive { overflow-x: auto; }
.table {
    width: 100%;
    color: var(--text);
    margin: 0;
    --bs-table-bg: transparent;
    --bs-table-color: var(--text);
    --bs-table-hover-bg: var(--surface-2);
    --bs-table-hover-color: var(--text);
    --bs-table-border-color: var(--line);
    border-collapse: collapse;
}
.table thead th {
    background: var(--surface-2);
    color: var(--text-2);
    font-weight: 700;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    padding: 10px 12px;
    border-bottom: 1px solid var(--line);
    text-align: left;
}
.table th, .table td { padding: 10px 12px; border-color: var(--line); vertical-align: middle; }
.table-hover tbody tr:hover { background: var(--surface-2); }
.table-sm th, .table-sm td { padding: 6px 8px; font-size: 13px; }

/* mobile-stack */
@media (max-width: 767.98px) {
    .mobile-stack { display: block; }
    .mobile-stack thead { display: none; }
    .mobile-stack tbody, .mobile-stack tr { display: block; }
    .mobile-stack tr {
        background: var(--surface);
        border: 1px solid var(--line);
        border-radius: var(--r-md);
        margin-bottom: 8px;
        padding: var(--s-3);
    }
    .mobile-stack td {
        display: flex;
        justify-content: space-between;
        align-items: flex-start;
        gap: 12px;
        border: 0;
        padding: 4px 0;
        text-align: right;
    }
    .mobile-stack td::before {
        content: attr(data-label);
        font-weight: 700;
        color: var(--text-2);
        font-size: 12px;
        text-transform: uppercase;
        letter-spacing: 0.05em;
        text-align: left;
        min-width: 38%;
    }
}

/* -------- 17. Tool card (grid item) -------- */
.titem {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--r-lg);
    overflow: hidden;
    display: flex;
    flex-direction: column;
}
.titem__head {
    display: flex;
    align-items: flex-start;
    gap: var(--s-3);
    padding: var(--s-3) var(--s-4);
}
.titem__photo {
    width: 48px; height: 48px;
    border-radius: var(--r-md);
    background: var(--surface-2);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    overflow: hidden;
    color: var(--text-2);
    font-size: 20px;
}
.titem__photo img { width: 100%; height: 100%; object-fit: cover; }
.titem__main { flex: 1; min-width: 0; }
.titem__title { font-weight: 700; font-size: 15px; margin: 0 0 2px; word-break: break-word; }
.titem__sub { font-size: 12px; color: var(--text-2); display: flex; gap: 8px; flex-wrap: wrap; }
.titem__sub span { display: inline-flex; gap: 4px; }
.titem__sub b { font-weight: 600; color: var(--text); }
.titem__check { padding-top: 4px; }
.titem__body { padding: 0 var(--s-4) var(--s-3); display: flex; flex-direction: column; gap: var(--s-2); }
.titem__statusrow {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--s-2);
    padding: 8px 12px;
    background: var(--surface-2);
    border-radius: var(--r-md);
    font-size: 13px;
}
.titem__statusrow b { font-weight: 600; color: var(--text); }
.titem__actions { display: flex; gap: var(--s-2); flex-wrap: wrap; }

/* tools grid */
.tgrid {
    display: grid;
    grid-template-columns: 1fr;
    gap: var(--s-3);
}
@media (min-width: 640px)  { .tgrid { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 1024px) { .tgrid { grid-template-columns: repeat(3, 1fr); } }
@media (min-width: 1400px) { .tgrid { grid-template-columns: repeat(4, 1fr); } }

/* -------- 18. Worker cards -------- */
.pgrid {
    display: grid;
    grid-template-columns: 1fr;
    gap: var(--s-3);
}
@media (min-width: 640px) { .pgrid { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 1024px){ .pgrid { grid-template-columns: repeat(3, 1fr); } }
@media (min-width: 1400px){ .pgrid { grid-template-columns: repeat(4, 1fr); } }

.pcard {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--r-lg);
    padding: var(--s-4);
    display: flex;
    flex-direction: column;
    gap: var(--s-3);
}
.pcard__top { display: flex; align-items: center; gap: var(--s-3); }
.pcard__avatar {
    width: 44px; height: 44px;
    border-radius: 50%;
    background: var(--accent-soft);
    color: var(--accent);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 16px;
    flex-shrink: 0;
}
.pcard__name { font-weight: 700; font-size: 15px; }
.pcard__role { font-size: 12px; color: var(--text-2); }
.pcard__meta {
    font-size: 13px;
    color: var(--text-2);
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.pcard__meta i { color: var(--text-3); margin-right: 4px; }
.pcard__account {
    margin-top: auto;
    padding-top: var(--s-3);
    border-top: 1px dashed var(--line);
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}
.pcard__login { font-family: var(--font-mono); font-size: 13px; }
.pcard__actions {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

/* -------- 19. Timeline -------- */
.timeline {
    position: relative;
    padding-left: 28px;
    display: flex;
    flex-direction: column;
    gap: var(--s-3);
}
.timeline::before {
    content: "";
    position: absolute;
    left: 9px;
    top: 6px;
    bottom: 6px;
    width: 2px;
    background: var(--line);
}
.tline-item {
    position: relative;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--r-md);
    padding: var(--s-3) var(--s-4);
}
.tline-item::before {
    content: "";
    position: absolute;
    left: -23px;
    top: 14px;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--accent);
    border: 3px solid var(--bg);
}
.tline-item__top {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: var(--s-3);
}
.tline-item__action { font-weight: 600; font-size: 14px; }
.tline-item__time { font-size: 12px; color: var(--text-2); white-space: nowrap; }
.tline-item__meta {
    margin-top: 4px;
    color: var(--text-2);
    font-size: 13px;
    display: flex;
    flex-wrap: wrap;
    gap: var(--s-3);
}

/* -------- 20. Empty state -------- */
.empty {
    text-align: center;
    padding: var(--s-8) var(--s-4);
    color: var(--text-2);
    background: var(--surface);
    border: 1px dashed var(--line);
    border-radius: var(--r-lg);
}
.empty i { font-size: 36px; opacity: 0.6; margin-bottom: var(--s-2); display: block; }
.empty__title { font-weight: 700; color: var(--text); margin-bottom: 4px; }

/* -------- 21. Bulk action bar -------- */
.bulkbar {
    position: sticky;
    top: var(--appbar-h);
    z-index: 90;
    margin: 0 0 var(--s-3);
    background: var(--surface);
    border: 1px solid var(--accent);
    border-radius: var(--r-md);
    padding: 10px 14px;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--s-2);
    box-shadow: var(--shadow-2);
}
@media (max-width: 991.98px) {
    .bulkbar {
        position: fixed;
        top: auto;
        bottom: calc(var(--tabbar-h) + var(--s-3) + env(safe-area-inset-bottom));
        left: var(--s-3);
        right: var(--s-3);
        margin: 0;
    }
}

/* -------- 22. Inventory tree table -------- */
.inv-toggle {
    width: 28px; height: 28px;
    padding: 0;
    min-height: 0;
    flex-shrink: 0;
}
.inv-group td { background: var(--surface-2); font-weight: 700; }
.inv-subgroup td { background: rgba(249, 115, 22, 0.04); font-weight: 600; }
.inv-hidden { display: none !important; }

/* -------- 23. Auth screen -------- */
body.auth-screen .appbar,
body.auth-screen .tabbar,
body.auth-screen .fab { display: none !important; }
body.auth-screen .main { padding: 0; }
.auth {
    min-height: 100vh;
    display: grid;
    grid-template-columns: 1fr;
    align-items: center;
}
@media (min-width: 992px) {
    .auth { grid-template-columns: 1.1fr 1fr; }
}
.auth__hero {
    padding: var(--s-8) var(--s-6);
    background: linear-gradient(135deg, rgba(249, 115, 22, 0.10), transparent), var(--surface);
    border-right: 1px solid var(--line);
    display: none;
    min-height: 100vh;
    flex-direction: column;
    justify-content: center;
    gap: var(--s-5);
}
@media (min-width: 992px) { .auth__hero { display: flex; } }
.auth__brand { display: inline-flex; align-items: center; gap: 8px; font-weight: 700; font-size: 18px; color: var(--text); }
.auth__brand i { color: var(--accent); font-size: 22px; }
.auth__tagline {
    font-size: clamp(28px, 4vw, 42px);
    font-weight: 800;
    line-height: 1.1;
    letter-spacing: -0.02em;
    margin: 0;
}
.auth__lead { color: var(--text-2); font-size: 15px; max-width: 480px; }
.auth__points { display: grid; gap: 12px; max-width: 480px; }
.auth__point {
    display: grid;
    grid-template-columns: 28px 1fr;
    gap: 12px;
    align-items: start;
    color: var(--text-2);
}
.auth__point i { color: var(--accent); font-size: 20px; }
.auth__point b { color: var(--text); display: block; }
.auth__panel {
    padding: var(--s-6) var(--s-4);
    display: flex;
    flex-direction: column;
    justify-content: center;
    min-height: 100vh;
    background: var(--bg);
}
.auth__form {
    width: 100%;
    max-width: 380px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    gap: var(--s-3);
    padding: var(--s-5);
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--r-xl);
    box-shadow: var(--shadow-2);
}
.auth__form h1 { font-size: 22px; margin: 0 0 4px; }
.auth__form .field__hint { color: var(--text-3); font-size: 13px; margin-bottom: 4px; }
.auth__brand--mobile {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin-bottom: var(--s-4);
    font-weight: 700;
}
@media (min-width: 992px) { .auth__brand--mobile { display: none; } }

/* -------- 24. Misc utilities -------- */
.stack { display: flex; flex-direction: column; gap: var(--s-3); }
.row-wrap { display: flex; flex-wrap: wrap; gap: var(--s-2); align-items: center; }
.row-end  { display: flex; gap: var(--s-2); justify-content: flex-end; align-items: center; }
.spacer { flex: 1; }
.muted { color: var(--text-2); }
.faint { color: var(--text-3); }
.mono { font-family: var(--font-mono); font-size: 0.92em; }
.text-end { text-align: right; }
.text-center { text-align: center; }
.text-nowrap { white-space: nowrap; }
.text-success { color: var(--ok) !important; }
.text-info    { color: var(--info) !important; }
.text-warning { color: var(--warn) !important; }
.text-danger  { color: var(--bad) !important; }
.text-muted   { color: var(--text-2) !important; }

.hide-mobile { display: none; }
@media (min-width: 768px) { .hide-mobile { display: revert; } .hide-desktop { display: none; } }

.visually-hidden, .sr-only {
    position: absolute !important;
    width: 1px !important; height: 1px !important;
    padding: 0 !important; margin: -1px !important;
    overflow: hidden !important; clip: rect(0,0,0,0) !important;
    white-space: nowrap !important; border: 0 !important;
}

/* -------- 25. Bootstrap structural fallback (keep modal/dropdown working visually) -------- */
.modal { color: var(--text); }
.btn-group .btn { border-radius: 0; }
.btn-group > .btn:first-child { border-radius: var(--r-md) 0 0 var(--r-md); }
.btn-group > .btn:last-child  { border-radius: 0 var(--r-md) var(--r-md) 0; }
.collapse { transition: height 0.2s; }
details summary { cursor: pointer; }
details summary::-webkit-details-marker { display: none; }

/* -------- 26. Page hero (kept compact for legacy templates) -------- */
.page-hero,
.page-hero__content,
.page-hero__actions,
.page-hero__metrics,
.hero-metric,
.hero-metric span,
.hero-metric strong { display: none; }

/* date picker bridge */
.flatpickr-calendar {
    background: var(--surface) !important;
    border: 1px solid var(--line) !important;
    box-shadow: var(--shadow-2) !important;
    color: var(--text) !important;
    border-radius: var(--r-md) !important;
}

/* -------- 27. Print -------- */
@media print {
    .appbar, .tabbar, .fab, .bulkbar, details.filter, .phead__actions { display: none !important; }
    body { background: #fff; color: #000; }
    .card, .titem, .pcard { box-shadow: none; border-color: #ccc; }
}

/* ==========================================================
   Переключатель режимов: Учёт / Таблица
   ========================================================== */
.modeswitch {
    display: inline-flex;
    background: var(--surface-2);
    border: 1px solid var(--line);
    border-radius: var(--r-pill);
    padding: 2px;
    gap: 2px;
}
.modeswitch__btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 5px 12px;
    border-radius: var(--r-pill);
    font-size: 12px;
    font-weight: 700;
    color: var(--text-2);
    white-space: nowrap;
    transition: background .15s, color .15s;
}
.modeswitch__btn:hover { color: var(--text); }
.modeswitch__btn.is-active {
    background: var(--accent);
    color: #fff;
}
@media (max-width: 640px) {
    .modeswitch__btn { padding: 5px 9px; }
}
