/* ==========================================================================
   Учёт оборудования — базовые стили интерфейса
   Разделы: токены → база → каркас → компоненты → адаптив → печать
   ========================================================================== */

:root {
    --bg: #f1f4f9;
    --surface: #ffffff;
    --surface-muted: #f7f9fc;
    --surface-inset: #eef2f8;
    --ink: #0d1526;
    --ink-soft: #33415c;
    --muted: #5b6b83;
    --line: #e3e9f2;
    --line-strong: #c7d2e1;
    --accent: #2563eb;
    --accent-dark: #1d4ed8;
    --accent-ink: #1e3a8a;
    --accent-soft: #eff5ff;
    --ok: #157f43;
    --ok-soft: #ecfdf3;
    --warn: #a8530a;
    --warn-soft: #fff8eb;
    --danger: #b42318;
    --danger-soft: #fef3f2;
    --sidebar: #0b1424;
    --sidebar-muted: #8f9fb6;
    --radius: 14px;
    --radius-sm: 10px;
    --radius-lg: 18px;
    --shadow-xs: 0 1px 2px rgba(13, 21, 38, .05);
    --shadow: 0 1px 2px rgba(13, 21, 38, .05), 0 12px 28px -22px rgba(13, 21, 38, .35);
    --shadow-lift: 0 2px 4px rgba(13, 21, 38, .06), 0 18px 36px -24px rgba(13, 21, 38, .45);
    --focus: 0 0 0 3px rgba(37, 99, 235, .28);
    --sidebar-w: 250px;
    --nav-h: 58px;
}

* {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    padding: 0;
}

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

body {
    background: var(--bg);
    color: var(--ink);
    font-family: "Inter", "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
    font-size: 15px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}

::selection {
    background: rgba(37, 99, 235, .18);
}

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

a:hover {
    text-decoration: underline;
}

.skip-link {
    position: fixed;
    top: -60px;
    left: 12px;
    z-index: 100;
    padding: 10px 16px;
    border-radius: 0 0 10px 10px;
    background: var(--ink);
    color: #fff;
    font-size: 13px;
    font-weight: 600;
    transition: top .18s ease;
}

.skip-link:focus {
    top: 0;
    color: #fff;
    text-decoration: none;
}

h1,
h2,
h3,
h4 {
    margin: 0 0 8px;
    line-height: 1.25;
    font-weight: 650;
    letter-spacing: -.012em;
    color: var(--ink);
}

h1 {
    font-size: 24px;
}

h2 {
    font-size: 17px;
}

h3 {
    font-size: 15px;
}

p {
    margin: 0 0 12px;
}

hr {
    border: 0;
    border-top: 1px solid var(--line);
}

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

code,
.mono {
    font-family: ui-monospace, "Cascadia Mono", "JetBrains Mono", Consolas, monospace;
    font-variant-numeric: tabular-nums;
}

.mono {
    letter-spacing: -.01em;
}

:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
    border-radius: 4px;
}

/* --- каркас ------------------------------------------------------------- */

.layout {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    position: sticky;
    top: 0;
    display: flex;
    flex-direction: column;
    width: var(--sidebar-w);
    height: 100vh;
    height: 100dvh;
    padding: 18px 12px 14px;
    background:
        radial-gradient(520px 240px at 12% -6%, rgba(59, 130, 246, .22), transparent 70%),
        var(--sidebar);
    color: #e2e8f0;
    flex-shrink: 0;
    overflow-y: auto;
    scrollbar-width: thin;
}

.brand {
    display: flex;
    align-items: center;
    gap: 11px;
    padding: 4px 10px 18px;
    color: #fff;
    font-weight: 700;
    font-size: 16px;
    line-height: 1.15;
    letter-spacing: -.015em;
}

.brand:hover {
    text-decoration: none;
}

.brand-mark {
    display: grid;
    place-items: center;
    width: 36px;
    height: 36px;
    border-radius: 11px;
    background: linear-gradient(140deg, #3b82f6, #22d3ee);
    color: #071221;
    font-size: 17px;
    font-weight: 800;
    flex-shrink: 0;
    box-shadow: 0 6px 16px -8px rgba(56, 189, 248, .8);
}

.brand small {
    display: block;
    margin-top: 3px;
    color: var(--sidebar-muted);
    font-size: 10px;
    font-weight: 600;
    letter-spacing: .12em;
    text-transform: uppercase;
}

.nav {
    display: flex;
    flex-direction: column;
    gap: 2px;
    margin-top: 2px;
}

.nav-label {
    padding: 16px 12px 6px;
    color: var(--sidebar-muted);
    font-size: 10px;
    font-weight: 700;
    letter-spacing: .12em;
    text-transform: uppercase;
}

.nav a {
    position: relative;
    display: flex;
    align-items: center;
    gap: 10px;
    min-height: 38px;
    padding: 9px 12px;
    border-radius: 9px;
    color: #c4d0e0;
    font-size: 14px;
    font-weight: 500;
}

.nav a:hover {
    background: rgba(255, 255, 255, .06);
    color: #fff;
    text-decoration: none;
}

.nav a.active {
    background: rgba(59, 130, 246, .16);
    color: #fff;
    box-shadow: inset 0 0 0 1px rgba(96, 165, 250, .28);
}

.nav a.active::before {
    content: "";
    position: absolute;
    left: 0;
    top: 8px;
    bottom: 8px;
    width: 3px;
    border-radius: 0 3px 3px 0;
    background: #60a5fa;
}

.nav svg {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
    opacity: .9;
}

.sidebar-footer {
    margin-top: auto;
    padding-top: 14px;
    border-top: 1px solid rgba(148, 163, 184, .16);
}

.sidebar-user {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 10px 10px;
    min-width: 0;
}

.avatar {
    display: grid;
    place-items: center;
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: rgba(148, 163, 184, .18);
    color: #fff;
    font-size: 13px;
    font-weight: 700;
    flex-shrink: 0;
}

.sidebar-user-name {
    font-size: 13px;
    font-weight: 600;
    color: #fff;
    line-height: 1.25;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

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

.main {
    flex: 1;
    min-width: 0;
}

.topbar {
    position: sticky;
    top: 0;
    z-index: 20;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    min-height: 64px;
    padding: 10px 32px;
    background: rgba(241, 244, 249, .88);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--line);
}

.topbar-title {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
}

.topbar-title h1 {
    margin: 0;
    font-size: 19px;
    letter-spacing: -.015em;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.topbar-actions {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
}

.topbar-bell {
    margin-left: auto;
}

.content {
    width: 100%;
    max-width: 1340px;
    margin: 0 auto;
    padding: 24px 32px 72px;
}

.page-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 18px;
    flex-wrap: wrap;
}

.page-head p {
    margin: 4px 0 0;
}

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

.auth-page {
    position: relative;
    display: grid;
    place-items: center;
    min-height: 100vh;
    min-height: 100dvh;
    padding: 28px 18px;
    overflow: hidden;
    background:
        radial-gradient(900px 520px at 15% -10%, rgba(37, 99, 235, .35), transparent 62%),
        radial-gradient(700px 460px at 96% 8%, rgba(34, 211, 238, .16), transparent 60%),
        #0b1424;
}

.auth-glow {
    position: absolute;
    inset: 0;
    background-image:
        linear-gradient(rgba(148, 163, 184, .07) 1px, transparent 1px),
        linear-gradient(90deg, rgba(148, 163, 184, .07) 1px, transparent 1px);
    background-size: 56px 56px;
    mask-image: radial-gradient(circle at 50% 0%, #000 0%, transparent 78%);
    -webkit-mask-image: radial-gradient(circle at 50% 0%, #000 0%, transparent 78%);
    pointer-events: none;
}

.auth-shell {
    position: relative;
    width: 100%;
    max-width: 420px;
}

.auth-brand {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 11px;
    padding: 4px 0 20px;
    color: #fff;
    font-size: 17px;
    font-weight: 700;
    letter-spacing: -.015em;
}

.auth-brand small {
    display: block;
    margin-top: 3px;
    color: var(--sidebar-muted);
    font-size: 10px;
    font-weight: 600;
    letter-spacing: .12em;
    text-transform: uppercase;
}

.auth-card {
    padding: 26px 26px 24px;
    border-color: rgba(255, 255, 255, .08);
    box-shadow: 0 1px 2px rgba(3, 8, 20, .4), 0 32px 64px -32px rgba(3, 8, 20, .9);
}

.auth-title {
    margin: 0 0 6px;
    font-size: 21px;
}

.auth-lead {
    margin: 0 0 20px;
    color: var(--muted);
    font-size: 14px;
    line-height: 1.55;
}

.auth-submit {
    min-height: 46px;
    font-size: 15px;
}

.auth-hint {
    margin: 12px 0 0;
    color: var(--muted);
    font-size: 12px;
    text-align: center;
    line-height: 1.5;
}

.auth-state {
    padding: 16px 16px 18px;
    border: 1px solid #f4dfbd;
    border-radius: var(--radius-sm);
    background: var(--warn-soft);
    color: #6d3f07;
}

.auth-state-head {
    display: flex;
    align-items: flex-start;
    gap: 10px;
}

.auth-state-head strong {
    display: block;
    font-size: 14px;
    color: #5b3406;
}

.auth-state-ico {
    display: grid;
    place-items: center;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: rgba(168, 83, 10, .12);
    color: var(--warn);
    flex-shrink: 0;
}

.auth-state-ico svg {
    width: 16px;
    height: 16px;
}

.auth-state-sub {
    margin-top: 2px;
    font-size: 12.5px;
    line-height: 1.45;
    color: #7c4a09;
}

.auth-state-text {
    margin: 12px 0 0;
    font-size: 13px;
    line-height: 1.6;
    color: #6d3f07;
}

.auth-state code {
    padding: 1px 5px;
    border-radius: 5px;
    background: rgba(109, 63, 7, .1);
    font-size: 12px;
}

.auth-code {
    margin: 8px 0 0;
    padding: 9px 12px;
    border: 1px solid rgba(109, 63, 7, .14);
    border-radius: 8px;
    background: #fffdf8;
    color: #4a2c04;
    font-size: 12.5px;
    overflow-x: auto;
}

.auth-code code {
    background: none;
    padding: 0;
}

.auth-foot {
    margin: 18px 0 0;
    color: var(--sidebar-muted);
    font-size: 12px;
    text-align: center;
}

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

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    min-height: 40px;
    padding: 8px 14px;
    border: 1px solid var(--line-strong);
    border-radius: var(--radius-sm);
    background: var(--surface);
    color: var(--ink);
    font: inherit;
    font-size: 14px;
    font-weight: 600;
    line-height: 1.2;
    cursor: pointer;
    text-decoration: none;
    white-space: nowrap;
    box-shadow: var(--shadow-xs);
    transition: background .15s ease, border-color .15s ease, color .15s ease, box-shadow .15s ease, transform .1s ease;
    -webkit-tap-highlight-color: transparent;
}

.btn:hover {
    background: var(--surface-muted);
    border-color: #b6c4d6;
    text-decoration: none;
}

.btn:active {
    transform: translateY(1px);
    box-shadow: none;
}

.btn svg {
    width: 17px;
    height: 17px;
    flex-shrink: 0;
}

.btn-primary {
    border-color: var(--accent);
    background: var(--accent);
    color: #fff;
    box-shadow: 0 1px 2px rgba(29, 78, 216, .25), 0 10px 20px -16px rgba(29, 78, 216, .9);
}

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

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

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

.btn-ghost {
    border-color: transparent;
    background: transparent;
    color: var(--muted);
    box-shadow: none;
}

.btn-ghost:hover {
    background: var(--surface-inset);
    border-color: transparent;
    color: var(--ink);
}

.btn-sm {
    min-height: 34px;
    padding: 5px 11px;
    font-size: 13px;
    border-radius: 9px;
}

.btn-icon {
    width: 40px;
    padding: 0;
}

.btn-block {
    width: 100%;
}

.btn:disabled,
.btn.is-disabled {
    opacity: .5;
    cursor: not-allowed;
    box-shadow: none;
    transform: none;
}

.btn[aria-disabled="true"] {
    opacity: .55;
    pointer-events: none;
}

.btn-self {
    align-self: flex-start;
    min-width: 150px;
}

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

.card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.card-pad {
    padding: 20px;
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 15px 20px;
    border-bottom: 1px solid var(--line);
    flex-wrap: wrap;
    min-height: 56px;
}

.card-header h2,
.card-header h3 {
    margin: 0;
}

.card-body {
    padding: 20px;
}

.card + .card {
    margin-top: 18px;
}

.card-foot {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
    padding: 14px 20px;
    border-top: 1px solid var(--line);
    background: linear-gradient(180deg, var(--surface), var(--surface-muted));
    border-radius: 0 0 var(--radius) var(--radius);
    flex-wrap: wrap;
}

.card-link {
    color: var(--muted);
    font-size: 13px;
    font-weight: 600;
}

.list-tools {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.selection-hint {
    color: var(--muted);
    font-size: 12px;
}

.selection-hint .badge {
    margin-left: 2px;
    font-variant-numeric: tabular-nums;
}

.selection-hint.is-empty .badge {
    background: var(--surface-inset);
    color: var(--muted);
}

/* --- дашборд ------------------------------------------------------------ */

.grid-main {
    display: grid;
    grid-template-columns: minmax(0, 1.55fr) minmax(0, 1fr);
    gap: 18px;
    align-items: start;
}

.progress.progress-thin {
    height: 6px;
    background: var(--surface-inset);
}

.progress.progress-thin > span {
    background: linear-gradient(90deg, #60a5fa, #2563eb);
}

.place-row + .place-row {
    margin-top: 14px;
}

.place-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 6px;
    font-size: 13.5px;
    color: var(--ink-soft);
}

.status-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.status-chip {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    min-height: 34px;
    padding: 5px 11px;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: var(--surface);
    color: var(--ink-soft);
    font-size: 13px;
    font-weight: 500;
    transition: border-color .15s ease, background .15s ease;
}

.status-chip:hover {
    border-color: var(--line-strong);
    background: var(--surface-muted);
    text-decoration: none;
}

.status-chip strong {
    font-size: 13px;
    font-weight: 700;
    color: var(--ink);
    font-variant-numeric: tabular-nums;
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--muted);
    flex-shrink: 0;
}

.status-dot.ok {
    background: #16a34a;
}

.status-dot.info {
    background: #2563eb;
}

.status-dot.warn {
    background: #d97706;
}

.status-dot.danger {
    background: #dc2626;
}

.status-dot.muted {
    background: #94a3b8;
}

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

/* --- метрики ------------------------------------------------------------ */

.stats {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 14px;
    margin-bottom: 20px;
}

.stat {
    position: relative;
    padding: 16px 18px 18px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
    transition: box-shadow .2s ease, transform .2s ease, border-color .2s ease;
}

.stat::before {
    content: "";
    position: absolute;
    inset: 0 auto auto 0;
    width: 100%;
    height: 3px;
    background: linear-gradient(90deg, var(--tone, var(--accent)) 0%, transparent 65%);
    opacity: .8;
}

.stat:hover {
    box-shadow: var(--shadow-lift);
    border-color: var(--line-strong);
}

.stat-label {
    display: flex;
    align-items: center;
    gap: 7px;
    color: var(--muted);
    font-size: 12.5px;
    font-weight: 600;
    letter-spacing: .01em;
}

.stat-label::before {
    content: "";
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--tone, var(--accent));
    flex-shrink: 0;
}

.stat-value {
    margin-top: 10px;
    font-size: 32px;
    font-weight: 700;
    letter-spacing: -.03em;
    line-height: 1;
    font-variant-numeric: tabular-nums;
}

.stat-note {
    margin-top: 8px;
    color: var(--muted);
    font-size: 12px;
}

.stat.tone-ok {
    --tone: #16a34a;
}

.stat.tone-warn {
    --tone: #d97706;
}

.stat.tone-info {
    --tone: #2563eb;
}

.stat.tone-muted {
    --tone: #94a3b8;
}

.stat.tone-danger {
    --tone: #dc2626;
}

/* --- сетки -------------------------------------------------------------- */

.grid-2 {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 18px;
    align-items: start;
}

.grid-3 {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 18px;
    align-items: start;
}

.grid-split {
    display: grid;
    grid-template-columns: minmax(0, 400px) minmax(0, 1fr);
    gap: 18px;
    align-items: start;
}

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

.table-wrap {
    overflow-x: auto;
    border-radius: 0 0 var(--radius) var(--radius);
    -webkit-overflow-scrolling: touch;
}

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

.table th {
    padding: 10px 14px;
    border-bottom: 1px solid var(--line);
    background: var(--surface-muted);
    color: var(--muted);
    font-size: 11.5px;
    font-weight: 700;
    letter-spacing: .06em;
    text-align: left;
    text-transform: uppercase;
    white-space: nowrap;
}

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

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

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

.table tbody tr:hover {
    background: #fafcff;
}

.table tbody tr:has(input[type="checkbox"]:checked) {
    background: var(--accent-soft);
}

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

.table .checkbox {
    width: 44px;
    padding-right: 0;
}

.table .checkbox input {
    width: 16px;
    height: 16px;
    margin: 0;
    accent-color: var(--accent);
    cursor: pointer;
}

.row-title {
    display: inline-block;
    font-weight: 600;
    color: var(--ink);
    line-height: 1.35;
}

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

.row-sub {
    color: var(--muted);
    font-size: 12px;
    line-height: 1.4;
}

.row-actions {
    white-space: nowrap;
}

/* --- бейджи ------------------------------------------------------------- */

.badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 3px 9px;
    border-radius: 999px;
    background: var(--surface-inset);
    color: var(--muted);
    font-size: 12px;
    font-weight: 600;
    line-height: 1.5;
    white-space: nowrap;
    box-shadow: inset 0 0 0 1px rgba(13, 21, 38, .05);
}

a.badge:hover {
    text-decoration: none;
    box-shadow: inset 0 0 0 1px rgba(13, 21, 38, .16);
}

.badge.ok {
    background: var(--ok-soft);
    color: var(--ok);
    box-shadow: inset 0 0 0 1px rgba(21, 127, 67, .14);
}

.badge.info {
    background: var(--accent-soft);
    color: var(--accent-dark);
    box-shadow: inset 0 0 0 1px rgba(37, 99, 235, .16);
}

.badge.warn {
    background: var(--warn-soft);
    color: var(--warn);
    box-shadow: inset 0 0 0 1px rgba(168, 83, 10, .16);
}

.badge.danger {
    background: var(--danger-soft);
    color: var(--danger);
    box-shadow: inset 0 0 0 1px rgba(180, 35, 24, .16);
}

.badge.muted {
    background: #f1f5f9;
    color: #64748b;
}

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

.form-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px 18px;
}

.form-grid .span-2 {
    grid-column: span 2;
}

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

.field > label {
    font-size: 12.5px;
    font-weight: 600;
    color: #3b4a63;
    letter-spacing: .005em;
}

.input,
select.input,
textarea.input,
input.input {
    width: 100%;
    min-height: 42px;
    padding: 9px 12px;
    border: 1px solid var(--line-strong);
    border-radius: 9px;
    background: #fff;
    color: var(--ink);
    font: inherit;
    font-size: 14px;
    transition: border-color .15s ease, box-shadow .15s ease, background .15s ease;
}

.input::placeholder {
    color: #98a6b9;
}

.input:hover {
    border-color: #b3c1d3;
}

textarea.input {
    min-height: 92px;
    resize: vertical;
    line-height: 1.55;
}

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

.input.is-invalid {
    border-color: #e7a29c;
    background: #fffafa;
}

.input.is-invalid:focus {
    box-shadow: 0 0 0 3px rgba(180, 35, 24, .16);
}

.input:disabled,
.input[readonly] {
    background: var(--surface-muted);
    color: var(--muted);
    cursor: not-allowed;
}

input[type="file"].input {
    padding: 7px 8px;
    font-size: 13px;
    cursor: pointer;
}

input[type="file"].input::file-selector-button {
    margin-right: 10px;
    padding: 6px 10px;
    border: 1px solid var(--line-strong);
    border-radius: 7px;
    background: var(--surface-muted);
    color: var(--ink);
    font: inherit;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
}

input[type="file"].input::file-selector-button:hover {
    background: var(--surface-inset);
}

/* поле поиска, добавляемое в select почти как «фильтр списка» */
.select-filter {
    width: 100%;
    min-height: 34px;
    margin-top: 4px;
    padding: 6px 10px;
    border: 1px dashed var(--line-strong);
    border-radius: 8px;
    background: var(--surface-muted);
    color: var(--ink);
    font: inherit;
    font-size: 13px;
    transition: border-color .15s ease, box-shadow .15s ease, background .15s ease;
}

.select-filter::placeholder {
    color: #98a6b9;
}

.select-filter:focus {
    outline: none;
    border-style: solid;
    border-color: var(--accent);
    background: #fff;
    box-shadow: var(--focus);
}

.field-error {
    color: var(--danger);
    font-size: 12px;
    font-weight: 500;
}

.field-hint {
    color: var(--muted);
    font-size: 12px;
    line-height: 1.45;
}

.checkbox-row {
    display: inline-flex;
    align-items: center;
    gap: 9px;
    min-height: 32px;
    font-size: 14px;
    color: var(--ink-soft);
    cursor: pointer;
}

.checkbox-row input {
    width: 17px;
    height: 17px;
    margin: 0;
    accent-color: var(--accent);
    cursor: pointer;
}

.form-section {
    display: flex;
    align-items: baseline;
    gap: 10px;
    grid-column: span 2;
    margin: 6px 0 0;
    padding-top: 14px;
    border-top: 1px solid var(--line);
}

.form-section:first-child {
    padding-top: 0;
    border-top: 0;
    margin-top: 0;
}

.form-section h3 {
    margin: 0;
    font-size: 12px;
    font-weight: 700;
    letter-spacing: .08em;
    text-transform: uppercase;
    color: var(--muted);
}

.form-section .field-hint {
    margin-left: auto;
    text-align: right;
}

/* --- фильтры ------------------------------------------------------------ */

.filters {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: flex-end;
    padding: 16px 20px;
    border-bottom: 1px solid var(--line);
}

.filters .field {
    min-width: 118px;
    flex: 1 1 118px;
}

.filters .field.grow {
    flex: 2 1 200px;
}

.filters .actions {
    display: flex;
    gap: 8px;
    padding-bottom: 1px;
    margin-left: auto;
}

.filters-toggle {
    display: none;
}

.filters-head {
    display: contents;
}

/* --- сообщения и пустые состояния -------------------------------------- */

.flash {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 12px 16px;
    margin-bottom: 16px;
    border: 1px solid #bbf7d0;
    border-radius: var(--radius-sm);
    background: var(--ok-soft);
    color: #14532d;
    font-size: 14px;
    line-height: 1.5;
}

.flash svg {
    width: 18px;
    height: 18px;
    margin-top: 1px;
    flex-shrink: 0;
}

.flash.error {
    border-color: #f7cdc9;
    background: var(--danger-soft);
    color: #7a1d16;
}

.flash ul {
    margin: 6px 0 0;
    padding-left: 18px;
}

.empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 44px 24px 46px;
    color: var(--muted);
    text-align: center;
}

.empty h3 {
    margin: 6px 0 0;
    color: var(--ink);
    font-size: 16px;
}

.empty p {
    margin: 4px 0 0;
    max-width: 46ch;
    font-size: 14px;
}

.empty .btn {
    margin-top: 14px;
}

.empty-ico {
    display: grid;
    place-items: center;
    width: 48px;
    height: 48px;
    margin-bottom: 6px;
    border-radius: 50%;
    background: var(--accent-soft);
    color: var(--accent);
    box-shadow: inset 0 0 0 1px rgba(37, 99, 235, .12);
}

.empty-ico svg {
    width: 22px;
    height: 22px;
}

/* --- вкладки и пагинация ------------------------------------------------ */

.tabs {
    display: flex;
    gap: 3px;
    padding: 3px;
    background: var(--surface-inset);
    border-radius: var(--radius-sm);
    max-width: 100%;
    overflow-x: auto;
    scrollbar-width: none;
}

.tabs::-webkit-scrollbar {
    display: none;
}

.tabs a {
    padding: 7px 12px;
    border-radius: 7px;
    color: var(--muted);
    font-size: 13px;
    font-weight: 600;
    white-space: nowrap;
}

.tabs a.active {
    background: #fff;
    color: var(--ink);
    box-shadow: 0 1px 2px rgba(13, 21, 38, .1);
}

.tabs a:hover {
    text-decoration: none;
    color: var(--ink);
}

.pagination-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 13px 20px;
    border-top: 1px solid var(--line);
    color: var(--muted);
    font-size: 13px;
    flex-wrap: wrap;
}

.pager {
    display: flex;
    gap: 6px;
    align-items: center;
    flex-wrap: wrap;
}

.pager a,
.pager span {
    display: inline-grid;
    place-items: center;
    min-width: 34px;
    height: 34px;
    padding: 0 8px;
    border: 1px solid var(--line);
    border-radius: 9px;
    background: #fff;
    color: var(--ink);
    font-size: 13px;
    font-variant-numeric: tabular-nums;
}

.pager span.current {
    border-color: var(--accent);
    background: var(--accent);
    color: #fff;
    font-weight: 600;
}

.pager span.disabled {
    color: #b8c4d4;
    border-color: transparent;
    background: transparent;
}

.pager a:hover {
    text-decoration: none;
    border-color: var(--line-strong);
    background: var(--surface-muted);
}

/* --- описание «ключ — значение» ---------------------------------------- */

.kv {
    display: grid;
    grid-template-columns: minmax(140px, 180px) minmax(0, 1fr);
    font-size: 14px;
}

.kv > div {
    padding: 9px 0;
    border-bottom: 1px dashed var(--line);
    min-width: 0;
}

.kv > div:nth-last-child(-n+2) {
    border-bottom: 0;
}

.kv .k {
    color: var(--muted);
    font-size: 13px;
    padding-right: 12px;
}

/* --- QR и сканер -------------------------------------------------------- */

.qr-panel {
    display: flex;
    align-items: flex-start;
    gap: 18px;
    flex-wrap: wrap;
}

.qr-box {
    flex-shrink: 0;
    padding: 8px;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: #fff;
}

.qr-box svg {
    display: block;
    width: 150px;
    height: 150px;
}

.qr-panel .btn svg {
    width: 17px;
    height: 17px;
}

.scan-shell {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 18px;
}

.scan-stage {
    position: relative;
}

#reader {
    width: 100%;
    min-height: 300px;
    overflow: hidden;
    border-radius: 12px;
    background: #0b1220;
}

#reader video {
    width: 100% !important;
    height: auto !important;
    border-radius: 12px;
}

#reader:not(:has(video)) {
    background:
        radial-gradient(560px 220px at 50% 0%, rgba(37, 99, 235, .28), transparent 70%),
        #0b1220;
}

#reader:not(:has(video))::after {
    content: "";
    display: block;
    height: 300px;
}

.scan-idle {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 24px;
    text-align: center;
    color: #cbd5e1;
    pointer-events: none;
}

.scan-idle .scan-idle-ico {
    display: grid;
    place-items: center;
    width: 52px;
    height: 52px;
    margin-bottom: 2px;
    border-radius: 50%;
    background: rgba(148, 163, 184, .14);
    box-shadow: inset 0 0 0 1px rgba(148, 163, 184, .28);
    color: #dbeafe;
}

.scan-idle .scan-idle-ico svg {
    width: 24px;
    height: 24px;
}

.scan-idle strong {
    font-size: 14px;
    color: #e2e8f0;
}

.scan-idle span {
    font-size: 12.5px;
    max-width: 30ch;
    line-height: 1.45;
}

.scan-stage:has(#reader video) .scan-idle {
    display: none;
}

.scan-result {
    min-height: 180px;
}

.scan-result .title {
    font-size: 17px;
    font-weight: 650;
    line-height: 1.3;
}

.scan-status {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 5px 11px;
    border-radius: 999px;
    font-weight: 700;
    font-size: 12.5px;
}

.scan-status.ok {
    background: var(--ok-soft);
    color: var(--ok);
}

.scan-status.warn {
    background: var(--warn-soft);
    color: var(--warn);
}

.scan-status.danger {
    background: var(--danger-soft);
    color: var(--danger);
}

.scan-status.info {
    background: var(--accent-soft);
    color: var(--accent-dark);
}

.progress {
    height: 9px;
    overflow: hidden;
    border-radius: 999px;
    background: #e2e8f0;
}

.progress > span {
    display: block;
    height: 100%;
    border-radius: inherit;
    background: linear-gradient(90deg, #22c55e, #15803d);
    transition: width .3s ease;
}

.scan-log {
    max-height: 260px;
    overflow: auto;
    margin: 0;
    padding: 0;
    list-style: none;
}

.scan-log li {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    padding: 9px 0;
    border-bottom: 1px dashed var(--line);
    font-size: 13px;
}

.scan-log li:last-child {
    border-bottom: 0;
}

/* --- история ------------------------------------------------------------ */

.timeline {
    margin: 0;
    padding: 0;
    list-style: none;
}

.timeline li {
    position: relative;
    padding: 0 0 18px 22px;
    border-left: 2px solid var(--line);
}

.timeline li::before {
    content: "";
    position: absolute;
    top: 4px;
    left: -6px;
    width: 10px;
    height: 10px;
    border: 2px solid #fff;
    border-radius: 50%;
    background: var(--accent);
    box-shadow: 0 0 0 1px rgba(37, 99, 235, .25);
}

.timeline li:last-child {
    padding-bottom: 0;
    border-left-color: transparent;
}

.timeline .when {
    color: var(--muted);
    font-size: 12px;
    white-space: nowrap;
}

/* --- публичная карточка ------------------------------------------------- */

.public-page {
    min-height: 100vh;
    background: linear-gradient(180deg, #0b1424 0%, #0b1424 240px, var(--bg) 240px, var(--bg) 100%);
}

.public-hero {
    padding: 22px 16px 0;
}

.public-brand {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 11px;
    max-width: 520px;
    margin: 0 auto;
    color: #fff;
    font-size: 16px;
    font-weight: 700;
    letter-spacing: -.01em;
}

.public-brand small {
    display: block;
    margin-top: 3px;
    color: var(--sidebar-muted);
    font-size: 10px;
    font-weight: 600;
    letter-spacing: .12em;
    text-transform: uppercase;
}

.public-shell {
    max-width: 520px;
    margin: 0 auto;
    padding: 22px 16px 40px;
}

.public-card {
    padding: 20px;
}

.public-card-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 10px;
}

.public-inv {
    font-size: 21px;
    font-weight: 700;
    letter-spacing: -.02em;
    line-height: 1.15;
    overflow-wrap: anywhere;
}

.public-title {
    margin: 0 0 4px;
    font-size: 18px;
    line-height: 1.3;
}

.public-model {
    color: var(--muted);
    font-size: 13px;
    margin-bottom: 16px;
}

.public-photo {
    max-width: 100%;
    margin-bottom: 16px;
}

.public-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 16px;
}

.public-foot {
    margin: 18px 0 0;
    color: var(--muted);
    font-size: 12px;
    text-align: center;
}

/* --- шаги и счётчики ---------------------------------------------------- */

.steps {
    margin: 0;
    padding-left: 20px;
    color: var(--ink-soft);
    font-size: 14px;
    line-height: 1.7;
}

.steps li + li {
    margin-top: 4px;
}

.steps li::marker {
    color: var(--accent);
    font-weight: 700;
}

.progress-counters {
    display: flex;
    flex-wrap: wrap;
    gap: 10px 22px;
    margin-top: 14px;
}

.progress-counter {
    display: flex;
    align-items: baseline;
    gap: 7px;
    font-size: 13px;
}

.progress-counter strong {
    font-size: 15px;
    font-variant-numeric: tabular-nums;
}

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

.table--notifications tr.is-unread {
    background: #f8fbff;
    box-shadow: inset 3px 0 0 var(--accent);
}

.table--notifications .cell-ico {
    width: 36px;
    padding-right: 0;
    text-align: center;
    vertical-align: top;
    padding-top: 14px;
}

.table--notifications .alert-ico {
    color: #dc2626;
}

.table--notifications .muted-ico {
    color: #94a3b8;
}

@media (max-width: 760px) {
    .table--notifications .cell-ico {
        width: auto;
        padding: 0 0 4px;
        text-align: left;
    }
}

/* --- предпросмотр этикеток --------------------------------------------- */

.label-preview {
    display: grid;
    gap: 10px;
    grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
}

.label-box {
    display: flex;
    gap: 10px;
    align-items: center;
    padding: 10px;
    border: 1px dashed var(--line-strong);
    border-radius: var(--radius-sm);
    background: #fff;
}

.label-box svg {
    width: 86px;
    height: 86px;
    flex-shrink: 0;
}

.label-box .inv {
    font-family: ui-monospace, Consolas, monospace;
    font-size: 15px;
    font-weight: 700;
}

.label-box .nm {
    font-size: 12px;
    line-height: 1.3;
}

/* --- подсказки и мелочи ------------------------------------------------- */

.section-note {
    padding: 12px 14px;
    border: 1px solid #cfe0fb;
    border-radius: var(--radius-sm);
    background: var(--accent-soft);
    color: var(--accent-ink);
    font-size: 13px;
    line-height: 1.5;
}

.section-note.warn {
    border-color: #f6dfb4;
    background: var(--warn-soft);
    color: #7c4708;
}

.section-note code {
    padding: 1px 5px;
    border-radius: 5px;
    background: rgba(30, 58, 138, .08);
    font-size: 12px;
}

.meta-inline {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 4px 10px;
    color: var(--muted);
    font-size: 12.5px;
}

.meta-inline span {
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.dot-sep::before {
    content: "·";
    margin-right: 8px;
    color: var(--line-strong);
}

.mobile-nav {
    display: none;
}

.mobile-brand {
    display: none;
}

.photo {
    width: 100%;
    max-width: 320px;
    border: 1px solid var(--line);
    border-radius: 12px;
    object-fit: cover;
}

.attachment-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.attachment-grid img {
    width: 110px;
    height: 110px;
    border: 1px solid var(--line);
    border-radius: 10px;
    object-fit: cover;
}

.stack {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.row {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.row.between {
    justify-content: space-between;
}

.spacer {
    flex: 1;
}

.hide {
    display: none !important;
}

.text-right {
    text-align: right;
}

.nowrap {
    white-space: nowrap;
}

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

/* ==========================================================================
   Адаптив
   ========================================================================== */

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

@media (max-width: 1080px) {
    .stats {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .grid-2,
    .grid-3,
    .grid-split,
    .scan-shell {
        grid-template-columns: minmax(0, 1fr);
    }

    .grid-split {
        gap: 18px;
    }
}

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

    .sidebar {
        display: none;
    }

    .topbar {
        align-items: center;
        flex-wrap: wrap;
        gap: 8px;
        padding: 8px 14px;
        min-height: 56px;
    }

    .topbar-title {
        flex: 1 1 auto;
        min-width: 0;
    }

    .topbar-title h1 {
        font-size: 16px;
    }

    .topbar-actions {
        order: 3;
        width: 100%;
        max-width: 100%;
        overflow-x: auto;
        flex-wrap: nowrap;
        justify-content: flex-start;
        padding-bottom: 2px;
        scrollbar-width: none;
    }

    .topbar-actions::-webkit-scrollbar {
        display: none;
    }

    .topbar-actions .btn {
        min-height: 36px;
        padding: 6px 10px;
        font-size: 13px;
    }

    .topbar-actions .btn-icon {
        width: 36px;
        padding: 0;
    }

    .topbar-bell {
        margin-left: auto;
    }

    .content {
        padding: 14px 14px calc(var(--nav-h) + 40px + env(safe-area-inset-bottom));
    }

    .mobile-brand {
        display: flex;
        align-items: center;
        gap: 8px;
        font-weight: 700;
        font-size: 14px;
        color: var(--ink);
    }

    .mobile-brand .brand-mark {
        width: 30px;
        height: 30px;
        font-size: 15px;
        border-radius: 8px;
        box-shadow: none;
    }

    .mobile-nav {
        position: fixed;
        right: 0;
        bottom: 0;
        left: 0;
        z-index: 40;
        display: grid;
        grid-template-columns: repeat(4, 1fr);
        padding: 5px 6px calc(5px + env(safe-area-inset-bottom));
        background: rgba(255, 255, 255, .97);
        border-top: 1px solid var(--line);
        backdrop-filter: blur(12px);
    }

    .mobile-nav a {
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 3px;
        min-height: 48px;
        padding: 4px 2px;
        border-radius: 9px;
        color: var(--muted);
        font-size: 10.5px;
        font-weight: 600;
        letter-spacing: .01em;
    }

    .mobile-nav a:active {
        background: var(--surface-inset);
    }

    .mobile-nav a.active {
        color: var(--accent-dark);
        background: var(--accent-soft);
    }

    .mobile-nav svg {
        width: 21px;
        height: 21px;
    }

    .form-grid {
        grid-template-columns: minmax(0, 1fr);
    }

    .form-grid .span-2 {
        grid-column: span 1;
    }

    .form-section {
        grid-column: span 1;
        flex-wrap: wrap;
    }

    .form-section .field-hint {
        margin-left: 0;
        text-align: left;
        flex-basis: 100%;
    }

    .kv {
        grid-template-columns: minmax(112px, 40%) minmax(0, 1fr);
        font-size: 13.5px;
    }

    .hide-mobile {
        display: none !important;
    }

    .stats {
        gap: 10px;
        margin-bottom: 16px;
    }

    .stat {
        padding: 13px 14px 15px;
    }

    .stat-value {
        font-size: 26px;
        margin-top: 8px;
    }

    .filters {
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
        padding: 14px;
    }

    .filters .field,
    .filters .field.grow {
        min-width: 100%;
        flex: 1 1 100%;
    }

    .filters .actions {
        margin-left: 0;
        padding-top: 2px;
    }

    .filters .actions .btn-primary {
        flex: 1;
    }

    .filters-toggle {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        gap: 8px;
        width: 100%;
        min-height: 40px;
        padding: 8px 12px;
        border: 1px dashed var(--line-strong);
        border-radius: 9px;
        background: var(--surface-muted);
        color: var(--ink-soft);
        font: inherit;
        font-size: 13px;
        font-weight: 600;
        cursor: pointer;
    }

    .filters-toggle .badge {
        font-size: 11px;
    }

    .filters-toggle svg {
        width: 16px;
        height: 16px;
        transform: rotate(-90deg);
        transition: transform .2s ease;
    }

    .filters.filters-collapsed .filters-toggle svg {
        transform: rotate(90deg);
    }

    .filters.filters-collapsed .filter-opt {
        display: none;
    }

    .table th,
    .table td {
        padding: 9px 10px;
    }

    .table th {
        font-size: 11px;
    }

    .page-head {
        gap: 10px;
    }

    .card-header,
    .card-body {
        padding: 14px;
    }

    .card-header {
        min-height: 52px;
    }

    .list-tools {
        width: 100%;
        justify-content: space-between;
    }

    .card-foot {
        position: sticky;
        bottom: calc(var(--nav-h) + env(safe-area-inset-bottom));
        z-index: 15;
        padding: 12px 14px;
        background: rgba(255, 255, 255, .97);
        backdrop-filter: blur(10px);
    }

    .pagination-bar {
        padding: 12px 14px;
    }

    .pager a,
    .pager span {
        min-width: 32px;
        height: 32px;
    }

    .timeline .when {
        white-space: normal;
    }

    .qr-panel {
        gap: 14px;
    }

    .qr-box svg {
        width: 128px;
        height: 128px;
    }

    .btn {
        min-height: 42px;
    }

    .btn-sm {
        min-height: 36px;
    }
}

/* Мобильные списки: строки таблицы превращаются в карточки */
@media (max-width: 760px) {
    .table--cards {
        font-size: 14px;
    }

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

    .table--cards,
    .table--cards tbody,
    .table--cards tr,
    .table--cards td {
        display: block;
        width: auto;
    }

    .table--cards tbody tr {
        position: relative;
        padding: 14px 16px 12px;
        border-bottom: 1px solid var(--line);
    }

    .table--cards tbody tr:last-child {
        border-bottom: 0;
    }

    .table--cards td {
        padding: 0;
        border: 0;
        text-align: left;
        white-space: normal;
    }

    .table--cards td.checkbox {
        position: absolute;
        top: 12px;
        right: 12px;
        width: auto;
        padding: 0;
    }

    .table--cards td.checkbox input {
        width: 20px;
        height: 20px;
    }

    .table--cards td.cell-inv {
        padding-right: 34px;
        font-size: 13px;
    }

    .table--cards td.cell-title .row-title {
        font-size: 15px;
        margin-top: 3px;
    }

    .table--cards td[data-label] {
        display: flex;
        align-items: baseline;
        gap: 8px;
        margin-top: 4px;
        color: var(--ink-soft);
        font-size: 13px;
    }

    .table--cards td[data-label]::before {
        content: attr(data-label);
        flex: 0 0 auto;
        min-width: 96px;
        margin-right: 0;
        color: var(--muted);
        font-size: 12px;
    }

    .table--cards td.cell-status {
        margin-top: 7px;
    }

    .table--cards td.cell-actions {
        display: flex;
        justify-content: flex-end;
        margin-top: 6px;
        text-align: right;
    }

    .table--cards td.cell-actions .btn {
        min-height: 32px;
        padding: 4px 10px;
    }

    .table--cards td.cell-actions .row-actions {
        white-space: normal;
    }

    .table--cards .row-sub {
        font-size: 12.5px;
    }

    .table--scroll-hint {
        overflow: visible;
    }
}

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

    .card-header .tabs {
        width: 100%;
        flex-wrap: wrap;
        overflow: visible;
    }

    .tabs a {
        flex: 1 1 auto;
        text-align: center;
    }

    .empty {
        padding: 36px 18px;
    }
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: .001ms !important;
        transition-duration: .001ms !important;
    }
}

/* ==========================================================================
   Печать страниц приложения
   ========================================================================== */

@media print {
    .sidebar,
    .topbar,
    .mobile-nav,
    .no-print,
    .filters-toggle {
        display: none !important;
    }

    body {
        background: #fff;
    }

    .content {
        padding: 0;
        max-width: none;
    }

    .card {
        box-shadow: none;
        border-color: #ddd;
    }

    .card-foot {
        position: static;
        background: #fff;
    }
}
