/* =====================================================
   Складно · дизайн-система
   ===================================================== */

:root {
    /* Палитра (slate, более тёплый и спокойный) */
    --bg:           #f8fafc;
    --bg-soft:      #f1f5f9;
    --card:         #ffffff;
    --text:         #0f172a;
    --text-soft:    #1e293b;
    --muted:        #64748b;
    --muted-2:      #94a3b8;
    --primary:      #4f46e5;
    --primary-dark: #4338ca;
    --primary-soft: #eef2ff;
    --border:       #e8eef5;
    --border-strong:#d6dee9;
    --error:        #dc2626;
    --error-soft:   #fef2f2;
    --success:      #15803d;
    --success-soft: #ecfdf5;
    --warning:      #c2410c;
    --warning-soft: #fff7ed;
    --info:         #0369a1;
    --info-soft:    #f0f9ff;

    /* Радиусы — крупнее, современнее */
    --r-sm: 8px;
    --r:    12px;
    --r-lg: 16px;
    --r-xl: 22px;

    /* Тени — мягкие, многослойные (modern SaaS) */
    --shadow-xs:  0 1px 2px rgba(16, 24, 40, 0.04);
    --shadow-sm:  0 1px 2px rgba(16, 24, 40, 0.05), 0 1px 3px rgba(16, 24, 40, 0.04);
    --shadow:     0 2px 6px rgba(16, 24, 40, 0.05), 0 8px 24px -6px rgba(16, 24, 40, 0.10);
    --shadow-lg:  0 4px 12px rgba(16, 24, 40, 0.06), 0 18px 40px -10px rgba(16, 24, 40, 0.16);
    --shadow-xl:  0 8px 20px rgba(16, 24, 40, 0.08), 0 30px 60px -12px rgba(16, 24, 40, 0.22);

    /* Размеры оболочки */
    --sidebar-w: 250px;
    --appbar-h: 62px;

    /* Тайминги */
    --ease: cubic-bezier(0.4, 0.0, 0.2, 1);
    --t-fast: 120ms;
    --t: 180ms;

    /* Шкала отступов 4-кратная */
    --s-1: 4px;
    --s-2: 8px;
    --s-3: 12px;
    --s-4: 16px;
    --s-5: 24px;
    --s-6: 32px;
    --s-8: 48px;
}

* { box-sizing: border-box; }

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

body {
    font-family: "Plus Jakarta Sans", "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
    color: var(--text);
    background: var(--bg);
    line-height: 1.55;
    font-size: 14px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
}

a {
    color: var(--primary);
    text-decoration: none;
    transition: color var(--t-fast) var(--ease);
}
a:hover { color: var(--primary-dark); text-decoration: underline; }

h1, h2, h3, h4 { font-weight: 600; letter-spacing: -0.015em; color: var(--text); line-height: 1.25; }
h1 { font-size: 26px; margin: 0 0 4px; letter-spacing: -0.02em; }
h2 { font-size: 20px; margin: 0 0 4px; }
h3 { font-size: 16px; margin: 0 0 4px; }
h4 { font-size: 14px; margin: 0 0 4px; }

.muted   { color: var(--muted); }
.muted-2 { color: var(--muted-2); }
.small   { font-size: 13px; }
.tabular { font-variant-numeric: tabular-nums; }

/* =====================================================
   App shell — боковое меню + основная область (modern)
   ===================================================== */
.app-main { min-height: 100vh; display: flex; flex-direction: column; }
.has-sidebar .app-main { margin-left: var(--sidebar-w); }

.sidebar {
    position: fixed; top: 0; left: 0; bottom: 0;
    width: var(--sidebar-w);
    background: linear-gradient(185deg, #141d33 0%, #0b1120 100%);
    border-right: 1px solid rgba(255,255,255,0.06);
    display: flex; flex-direction: column;
    padding: 16px 14px;
    z-index: 40;
    overflow-y: auto;
}
.sidebar-brand {
    display: flex; align-items: center; gap: 11px;
    padding: 6px 10px 18px;
    color: #fff; font-weight: 800; font-size: 18px; letter-spacing: -0.02em;
}
.sidebar-brand:hover { color: #fff; text-decoration: none; }
.brand-mark {
    width: 30px; height: 30px; border-radius: 9px; flex-shrink: 0;
    background: linear-gradient(135deg, #6366f1, #a855f7);
    box-shadow: 0 4px 14px rgba(99,102,241,0.45), inset 0 1px 0 rgba(255,255,255,0.25);
}
.sidebar-nav { display: flex; flex-direction: column; gap: 3px; flex: 1; padding-top: 4px; }
.side-link {
    display: flex; align-items: center; gap: 12px;
    padding: 10px 12px; border-radius: 11px;
    color: #9aa6bf; font-size: 14px; font-weight: 500;
    transition: background var(--t-fast) var(--ease), color var(--t-fast) var(--ease);
}
.side-link:hover { background: rgba(255,255,255,0.06); color: #fff; text-decoration: none; }
.side-link.active {
    background: linear-gradient(135deg, rgba(99,102,241,0.95), rgba(124,58,237,0.92));
    color: #fff; font-weight: 600;
    box-shadow: 0 8px 18px -6px rgba(99,102,241,0.55);
}
.side-ico { display: inline-flex; color: #7c89a6; }
.side-ico .icon { width: 19px; height: 19px; }
.side-link:hover .side-ico, .side-link.active .side-ico { color: #fff; }
.side-label { flex: 1; }
.side-badge { background: var(--error); color: #fff; font-size: 11px; font-weight: 700; min-width: 18px; height: 18px; line-height: 18px; text-align: center; border-radius: 9px; padding: 0 5px; }
.sidebar-foot { border-top: 1px solid rgba(255,255,255,0.08); padding-top: 10px; margin-top: 8px; display: flex; flex-direction: column; gap: 3px; }
.side-link-sm { padding: 9px 12px; font-size: 13px; }

/* Appbar — тонкая верхняя панель в основной области */
.appbar {
    height: var(--appbar-h);
    display: flex; align-items: center; gap: 16px;
    padding: 0 26px;
    background: rgba(255,255,255,0.82);
    backdrop-filter: saturate(180%) blur(10px);
    -webkit-backdrop-filter: saturate(180%) blur(10px);
    border-bottom: 1px solid var(--border);
    position: sticky; top: 0; z-index: 30;
}
.appbar-title { font-size: 15px; font-weight: 700; color: var(--text); letter-spacing: -0.01em; }
.appbar-right { margin-left: auto; display: flex; align-items: center; gap: 14px; }
.appbar-tenant { font-size: 13px; color: var(--muted); font-weight: 600; }
.appbar-user { display: flex; align-items: center; gap: 9px; color: var(--text-soft); }
.appbar-user:hover { text-decoration: none; color: var(--text); }
.user-avatar {
    width: 30px; height: 30px; border-radius: 50%;
    background: linear-gradient(135deg, #6366f1, #a855f7); color: #fff;
    display: flex; align-items: center; justify-content: center;
    font-size: 13px; font-weight: 700; flex-shrink: 0;
}
.appbar-email { font-size: 13px; font-weight: 500; }
.appbar-logout { display: inline-flex; color: var(--muted); padding: 6px; border-radius: 8px; }
.appbar-logout .icon { width: 18px; height: 18px; transform: rotate(90deg); }
.appbar-logout:hover { background: var(--error-soft); color: var(--error); }
.appbar-burger { display: none; }

/* Субтабы — вторичная навигация раздела */
.subtabs {
    display: flex; gap: 2px; align-items: center;
    padding: 0 26px;
    background: var(--card);
    border-bottom: 1px solid var(--border);
    overflow-x: auto;
    position: sticky; top: var(--appbar-h); z-index: 20;
}
.subtab {
    padding: 13px 14px; font-size: 13.5px; color: var(--muted); font-weight: 500;
    border-bottom: 2px solid transparent; white-space: nowrap;
    transition: color var(--t-fast) var(--ease);
}
.subtab:hover { color: var(--text); text-decoration: none; }
.subtab.active { color: var(--primary); border-bottom-color: var(--primary); font-weight: 600; }

.content-wrap { width: 100%; }
.main { max-width: 1320px; margin: 28px auto; padding: 0 26px; width: 100%; }

.is-public .app-main { margin-left: 0; }
.sidebar-scrim { position: fixed; inset: 0; background: rgba(8,12,24,0.5); z-index: 35; }

@media (max-width: 900px) {
    .has-sidebar .app-main { margin-left: 0; }
    .sidebar { transform: translateX(-100%); transition: transform 220ms var(--ease); box-shadow: var(--shadow-xl); }
    .sidebar.is-open { transform: translateX(0); }
    .appbar-burger {
        display: inline-flex; align-items: center; justify-content: center;
        width: 38px; height: 38px; border: 1px solid var(--border); border-radius: 10px;
        background: var(--card); color: var(--text-soft); cursor: pointer;
    }
    .appbar-burger .icon { width: 18px; height: 18px; }
    .appbar-email, .appbar-tenant { display: none; }
    .main { margin: 20px auto; padding: 0 18px; }
}

/* =====================================================
   Topbar
   ===================================================== */

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 var(--s-5);
    background: #0b1220;
    background: linear-gradient(180deg, #0f172a 0%, #0b1220 100%);
    border-bottom: 1px solid #1e293b;
    height: 56px;
    position: sticky;
    top: 0;
    z-index: 10;
    color: #f1f5f9;
}
.brand {
    font-size: 16px;
    font-weight: 700;
    letter-spacing: -0.015em;
    color: #f1f5f9;
    display: inline-flex;
    align-items: center;
    gap: 10px;
}
.brand:hover { text-decoration: none; color: #fff; }
.topnav {
    display: flex;
    gap: 8px;
    align-items: center;
    font-size: 13px;
    color: #94a3b8;
}
.topnav a { color: #cbd5e1; }
.topnav a:hover { color: #fff; text-decoration: none; }
.user-info { color: #94a3b8; }
.user-info strong { color: #f1f5f9; font-weight: 600; }

/* =====================================================
   Main horizontal navigation (with icons, no arrows)
   ===================================================== */

.mainnav {
    display: flex;
    align-items: center;
    gap: 4px;
    margin-left: 28px;
    flex: 1;
    height: 100%;
}
.mn-link {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 7px 12px;
    font-size: 13.5px;
    font-weight: 500;
    color: #94a3b8;
    border-radius: 8px;
    transition: all var(--t-fast) var(--ease);
    line-height: 1;
}
.mn-link:hover {
    background: rgba(255, 255, 255, 0.06);
    color: #f1f5f9;
    text-decoration: none;
}
.mn-link.active {
    background: rgba(99, 102, 241, 0.15);
    color: #fff;
    font-weight: 600;
    box-shadow: inset 0 0 0 1px rgba(99, 102, 241, 0.3);
}
.mn-icon { display: inline-flex; line-height: 0; color: #cbd5e1; }
.mn-icon .icon { width: 18px; height: 18px; }
.mn-link:hover .mn-icon { color: #f1f5f9; }
.mn-link.active .mn-icon { color: #a5b4fc; }
.mn-label { font-size: 14px; }

/* Inline SVG icon base — sizing via width/height, color via currentColor */
.icon { width: 20px; height: 20px; flex: 0 0 auto; vertical-align: middle; }

/* Inline icon inside buttons / text labels */
.btn-ico { display: inline-flex; align-items: center; vertical-align: middle; margin-right: 5px; position: relative; top: -1px; }
.btn-ico .icon { width: 15px; height: 15px; }

/* Topbar text-links (notifications, settings) */
.tb-textlink {
    position: relative;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 13.5px;
    font-weight: 500;
    line-height: 1;
    padding: 7px 12px;
    border-radius: 8px;
    color: #cbd5e1;
    transition: all var(--t-fast) var(--ease);
}
.tb-textlink:hover {
    background: rgba(255, 255, 255, 0.06);
    color: #fff;
    text-decoration: none;
}
.tb-badge {
    background: var(--error);
    color: #fff;
    font-size: 11px;
    min-width: 18px;
    height: 18px;
    line-height: 18px;
    text-align: center;
    border-radius: 9px;
    padding: 0 5px;
    font-weight: 600;
}

/* =====================================================
   Submenu (second-tier horizontal nav)
   ===================================================== */

.submenu {
    background: var(--card);
    border-bottom: 1px solid var(--border);
    padding: 0 var(--s-5);
    display: flex;
    gap: 2px;
    align-items: center;
    overflow-x: auto;
    position: sticky;
    top: 56px;
    z-index: 9;
}
.sm-link {
    display: inline-block;
    padding: 10px 14px;
    font-size: 13.5px;
    color: var(--muted);
    font-weight: 500;
    border-bottom: 2px solid transparent;
    transition: all var(--t-fast) var(--ease);
    white-space: nowrap;
}
.sm-link:hover {
    color: var(--text);
    text-decoration: none;
}
.sm-link.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
    font-weight: 600;
}

/* =====================================================
   Layout
   ===================================================== */

.layout {
    display: flex;
    min-height: calc(100vh - 60px - 50px);
}

.content-wrap { flex: 1; min-width: 0; }
.main {
    max-width: 1320px;
    margin: var(--s-6) auto;
    padding: 0 var(--s-5);
}

/* Контекстный сайдбар внутри раздела (категории каталога и т.п.) */
.subsidebar {
    width: 240px;
    flex-shrink: 0;
    padding-right: 22px;
}
.subsidebar-section {
    padding: 10px 0 6px;
    font-size: 11px;
    color: var(--muted-2);
    text-transform: uppercase;
    letter-spacing: 0.6px;
    font-weight: 600;
}
.subsidebar-link {
    display: block;
    padding: 8px 12px;
    color: var(--text-soft);
    font-size: 13.5px;
    border-radius: var(--r-sm);
    margin: 1px 0;
    transition: all var(--t-fast) var(--ease);
}
.subsidebar-link:hover {
    background: var(--primary-soft);
    color: var(--primary-dark);
    text-decoration: none;
}
.subsidebar-link.active {
    background: var(--primary);
    color: #fff;
    font-weight: 500;
}
.subsidebar-link.active:hover {
    background: var(--primary-dark);
    color: #fff;
}
.subsidebar-link .count {
    float: right;
    font-size: 11px;
    color: var(--muted-2);
}
.subsidebar-link.active .count {
    color: rgba(255,255,255,0.8);
}

.split-layout {
    display: flex;
    gap: 28px;
}
.split-layout .main-content { flex: 1; min-width: 0; }

/* =====================================================
   Auth card (login / register)
   ===================================================== */

.auth-card {
    max-width: 460px;
    margin: 48px auto;
    padding: 36px;
    background: var(--card);
    border-radius: var(--r-lg);
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--border);
}

/* Split auth-layout (login / register) — форма слева, hero справа */
.auth-split {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 32px;
    max-width: 1100px;
    margin: 28px auto;
    min-height: calc(100vh - 56px - 50px - 56px);
    align-items: stretch;
}
.auth-form {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
}
.auth-form-inner {
    width: 100%;
    max-width: 420px;
}
.auth-form h1 {
    font-size: 28px;
    margin-bottom: 6px;
}
.auth-hero {
    background: linear-gradient(135deg, #1e1b4b 0%, #4338ca 45%, #7c3aed 100%);
    color: #f1f5f9;
    border-radius: 18px;
    padding: 40px 36px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    position: relative;
    overflow: hidden;
    box-shadow: 0 20px 60px rgba(67, 56, 202, 0.35);
}
.auth-hero::before {
    content: "";
    position: absolute;
    top: -50%;
    right: -30%;
    width: 500px;
    height: 500px;
    background: radial-gradient(circle, rgba(255,255,255,0.12), transparent 60%);
    pointer-events: none;
}
.auth-hero-inner { position: relative; z-index: 1; }
.auth-hero-logo {
    display: flex;
    align-items: center;
    gap: 12px;
    font-weight: 700;
    font-size: 18px;
    margin-bottom: 36px;
    letter-spacing: -0.01em;
}
.auth-hero-logo-mark {
    display: inline-block;
    width: 32px;
    height: 32px;
    background: rgba(255, 255, 255, 0.15);
    border-radius: 9px;
    border: 1px solid rgba(255, 255, 255, 0.2);
}
.auth-hero-title {
    font-size: 32px;
    line-height: 1.15;
    font-weight: 700;
    letter-spacing: -0.025em;
    color: #fff;
    margin: 0 0 24px;
}
.auth-hero-features {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 12px;
    font-size: 15px;
    color: rgba(255, 255, 255, 0.92);
}
.auth-hero-features li {
    display: flex;
    align-items: flex-start;
    gap: 12px;
}
.auth-hero-features span {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    background: rgba(255, 255, 255, 0.18);
    border-radius: 6px;
    font-size: 12px;
    font-weight: 700;
    flex-shrink: 0;
    margin-top: 2px;
}
.auth-hero-features span .icon { width: 13px; height: 13px; }
@media (max-width: 900px) {
    .auth-split { grid-template-columns: 1fr; min-height: auto; }
    .auth-hero { display: none; }
}

/* =====================================================
   Toolbar (above lists)
   ===================================================== */

.toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin: 0 0 22px;
    gap: 12px;
    flex-wrap: wrap;
}
.toolbar h1 { margin: 0; }
.toolbar form { display: flex; gap: 8px; }
.toolbar input[type="text"],
.toolbar input[type="search"],
.toolbar select {
    padding: 8px 14px;
    border: 1px solid var(--border);
    border-radius: var(--r-sm);
    font-size: 14px;
    min-width: 240px;
    background: var(--card);
    transition: border-color var(--t-fast) var(--ease), box-shadow var(--t-fast) var(--ease);
}
.toolbar input:focus,
.toolbar select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.12);
}

/* =====================================================
   Tables
   ===================================================== */

.table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    background: var(--card);
    border-radius: var(--r-lg);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border);
}
.table thead th {
    text-align: left;
    padding: 12px 16px;
    background: var(--bg-soft);
    font-weight: 600;
    font-size: 11px;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.7px;
    border-bottom: 1px solid var(--border-strong);
    white-space: nowrap;
    vertical-align: middle;
}
.table tbody td {
    text-align: left;
    padding: 13px 16px;
    border-bottom: 1px solid var(--border);
    font-size: 13.5px;
    color: var(--text-soft);
    vertical-align: middle;
}
/* Чуть больше воздуха по краям таблицы */
.table thead th:first-child,
.table tbody td:first-child { padding-left: 20px; }
.table thead th:last-child,
.table tbody td:last-child { padding-right: 20px; }

.table tbody tr:last-child td { border-bottom: none; }
.table tbody tr { transition: background var(--t-fast) var(--ease); }
.table tbody tr:hover td { background: var(--primary-soft); }

/* Ведущая ячейка (номер/название) — акцент */
.table tbody td strong a,
.table tbody td a strong { color: var(--text); font-weight: 700; }
.table tbody td strong a:hover,
.table tbody td a strong:hover { color: var(--primary); }

.table tr.row-unposted td {
    background: repeating-linear-gradient(135deg, #f8fafc, #f8fafc 9px, #f1f5f9 9px, #f1f5f9 18px);
    color: var(--muted);
}
.table tr.row-unposted strong,
.table tr.row-unposted a {
    color: var(--text-soft);
}
.table tr.row-unposted:hover td {
    background: #eef2f7;
}
.product-link {
    color: var(--text);
    text-decoration: none;
}
.product-link:hover {
    color: var(--primary);
    text-decoration: underline;
}
.table .num { text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; color: var(--text); }

/* Вертикальный стек бейджей/меток внутри ячейки */
.cell-stack { display: inline-flex; flex-direction: column; align-items: flex-start; gap: 4px; }
.cell-sub { display: block; font-size: 12px; color: var(--muted); margin-top: 2px; }

.empty {
    padding: 64px 24px;
    text-align: center;
    color: var(--muted);
    background:
        radial-gradient(120% 80% at 50% 0%, rgba(79,70,229,0.04), transparent 70%),
        var(--card);
    border-radius: var(--r-lg);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-xs);
    font-size: 14px;
}
.empty::before {
    content: "";
    display: block;
    width: 44px;
    height: 44px;
    margin: 0 auto 14px;
    background: var(--muted-2);
    -webkit-mask: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'><path d='M21 8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16Z'/><path d='m3.3 7 8.7 5 8.7-5'/><path d='M12 22V12'/></svg>") center / contain no-repeat;
            mask: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'><path d='M21 8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16Z'/><path d='m3.3 7 8.7 5 8.7-5'/><path d='M12 22V12'/></svg>") center / contain no-repeat;
}

/* =====================================================
   Forms — basic
   ===================================================== */

.field { margin-bottom: 18px; }
.field label {
    display: block;
    margin-bottom: 6px;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-soft);
}
.field input,
.field select,
.field textarea {
    width: 100%;
    padding: 9px 12px;
    border: 1px solid var(--border-strong);
    border-radius: 8px;
    font-size: 14px;
    background: var(--card);
    font-family: inherit;
    color: var(--text);
    transition: border-color var(--t-fast) var(--ease), box-shadow var(--t-fast) var(--ease);
    box-shadow: 0 1px 1px rgba(15, 23, 42, 0.03);
}
.field input[type="checkbox"] {
    width: auto;
    margin-right: 6px;
    accent-color: var(--primary);
}
.field input:focus,
.field select:focus,
.field textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.12);
}
.field input::placeholder,
.field textarea::placeholder {
    color: var(--muted-2);
}
.field-error {
    margin-top: 6px;
    font-size: 13px;
    color: var(--error);
}
.form-card {
    background: var(--card);
    border-radius: var(--r-lg);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border);
    padding: 28px;
    max-width: 720px;
}
.form-actions {
    display: flex;
    gap: 10px;
    margin-top: 24px;
    align-items: center;
}

/* =====================================================
   Buttons
   ===================================================== */

.btn-primary,
.btn-primary-small,
.btn-secondary,
.btn-danger {
    border: 1px solid transparent;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    transition: all 100ms var(--ease);
    font-family: inherit;
    line-height: 1.2;
    min-height: 38px;
    white-space: nowrap;
}
.btn-primary {
    background: var(--primary);
    color: #fff;
    padding: 9px 18px;
    box-shadow: inset 0 0 0 1px rgba(255,255,255,0.08), 0 1px 2px rgba(79, 70, 229, 0.25);
}
.btn-primary:hover {
    background: var(--primary-dark);
    color: #fff;
    text-decoration: none;
    box-shadow: inset 0 0 0 1px rgba(255,255,255,0.08), 0 2px 6px rgba(79, 70, 229, 0.3);
}
.btn-primary:active { box-shadow: inset 0 1px 2px rgba(0,0,0,0.1); }

.btn-primary-small {
    background: var(--primary);
    color: #fff;
    padding: 8px 16px;
    font-size: 13.5px;
    min-height: 34px;
    box-shadow: inset 0 0 0 1px rgba(255,255,255,0.08), 0 1px 2px rgba(79, 70, 229, 0.25);
}
.btn-primary-small:hover {
    background: var(--primary-dark);
    color: #fff;
    text-decoration: none;
}

.btn-secondary {
    background: var(--card);
    color: var(--text-soft);
    border: 1px solid var(--border-strong);
    padding: 8px 16px;
    font-size: 13.5px;
    box-shadow: 0 1px 1px rgba(15, 23, 42, 0.03);
}
.btn-secondary:hover {
    background: var(--bg-soft);
    border-color: var(--muted-2);
    color: var(--text);
    text-decoration: none;
}

.btn-danger {
    background: var(--error);
    color: #fff;
    padding: 9px 18px;
    box-shadow: inset 0 0 0 1px rgba(255,255,255,0.08), 0 1px 2px rgba(220, 38, 38, 0.25);
}
.btn-danger:hover {
    background: #b91c1c;
    color: #fff;
    text-decoration: none;
}

/* Table row actions: turn bare links into pill buttons */
.table .actions { white-space: nowrap; text-align: right; }
.table .actions a {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 7px 14px;
    margin-left: 6px;
    min-height: 36px;
    font-size: 14px;
    font-weight: 500;
    color: var(--text-soft);
    background: var(--card);
    border: 1px solid var(--border-strong);
    border-radius: var(--r-sm);
    transition: all var(--t-fast) var(--ease);
    line-height: 1.1;
}
.table .actions a:hover {
    background: var(--primary-soft);
    border-color: var(--primary);
    color: var(--primary-dark);
    text-decoration: none;
}
.table .actions a.danger,
.table .actions a.delete {
    color: var(--error);
    border-color: #fecaca;
}
.table .actions a.danger:hover,
.table .actions a.delete:hover {
    background: var(--error-soft);
    border-color: var(--error);
    color: var(--error);
}

/* =====================================================
   Badges
   ===================================================== */

/* Статус-капсулы: единый текстовый стиль, форма капсулы (pill) */
.badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 3px 11px;
    border-radius: 999px;
    font-size: 11.5px;
    font-weight: 600;
    letter-spacing: 0.2px;
    line-height: 1.55;
    white-space: nowrap;
    border: none;
}
.badge-ok       { background: var(--success-soft); color: var(--success); }
.badge-muted    { background: var(--bg-soft);      color: var(--muted);   }
.badge-warn     { background: var(--warning-soft); color: var(--warning); }
.badge-info     { background: var(--info-soft);    color: var(--info);    }
.badge-error    { background: var(--error-soft);   color: var(--error);   }
.badge.tag-purple { background: #f5f3ff; color: #6d28d9; }
/* badge-plain оставлен для совместимости (точки больше нет ни у кого) */
.badge.badge-plain { }

/* =====================================================
   Messages
   ===================================================== */

.messages {
    padding: 16px 32px 0;
    max-width: 1180px;
    margin: 0 auto;
}
.msg {
    padding: 12px 18px;
    border-radius: var(--r-sm);
    margin-bottom: 10px;
    font-size: 14px;
    border: 1px solid transparent;
    display: flex;
    align-items: center;
    gap: 10px;
}
.msg-success { background: var(--success-soft); color: var(--success); border-color: #a7f3d0; }
.msg-error   { background: var(--error-soft);   color: var(--error);   border-color: #fecaca; }
.msg-info    { background: var(--info-soft);    color: var(--info);    border-color: #bae6fd; }
.msg-warning { background: var(--warning-soft); color: var(--warning); border-color: #fed7aa; }

/* =====================================================
   Dashboard cards
   ===================================================== */

.cards {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 16px;
    margin: 24px 0;
}
.card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    padding: 20px 22px;
    transition: transform var(--t) var(--ease), box-shadow var(--t) var(--ease);
}
.card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow);
}
.card h3 {
    font-size: 13px;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: 600;
    margin-bottom: 8px;
}
.card .num-big {
    font-size: 30px;
    font-weight: 700;
    margin: 4px 0;
    letter-spacing: -0.02em;
    color: var(--text);
}

/* =====================================================
   Thumbnails
   ===================================================== */

.thumb {
    width: 40px;
    height: 40px;
    object-fit: cover;
    border-radius: var(--r-sm);
    background: var(--bg-soft);
    border: 1px solid var(--border);
}

/* =====================================================
   Document forms (operations / sales)
   ===================================================== */

.doc-page { max-width: 1200px; }

.doc-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 16px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}
.doc-title { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.doc-title h1 { margin: 0; line-height: 1.2; }
.doc-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.doc-actions form { margin: 0; }

.doc-section {
    background: var(--card);
    border-radius: var(--r-lg);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border);
    padding: 24px 28px;
    margin-bottom: 20px;
}
.doc-section-title {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin: 0 0 18px;
    padding-left: 11px;
    font-size: 12px;
    font-weight: 700;
    color: var(--text-soft);
    text-transform: uppercase;
    letter-spacing: 0.6px;
    position: relative;
}
.doc-section-title::before {
    content: "";
    position: absolute;
    left: 0; top: 50%;
    transform: translateY(-50%);
    width: 3px; height: 14px;
    border-radius: 2px;
    background: var(--primary);
}
.doc-section-title .small { letter-spacing: 0; text-transform: none; font-weight: 500; }

/* Сводная карточка-обзор документа (под заголовком) */
.doc-summary {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 1px;
    background: var(--border);
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
    margin-bottom: 20px;
}
.ds-item {
    background: var(--card);
    padding: 13px 18px;
    display: flex;
    flex-direction: column;
    gap: 5px;
    min-width: 0;
}
.ds-item.highlight { background: linear-gradient(180deg, var(--primary-soft), #fff); }
.ds-label {
    font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.6px;
    color: var(--muted); font-weight: 600;
}
.ds-value {
    font-size: 14.5px; font-weight: 600; color: var(--text);
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.ds-value.big { font-size: 18px; font-variant-numeric: tabular-nums; letter-spacing: -0.01em; }
.ds-value.accent { color: var(--primary); }
.ds-value.danger { color: var(--error); }
.ds-value.ok { color: var(--success); }

.doc-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px 24px;
}
.doc-grid .field { margin-bottom: 0; }
.doc-grid .field.full { grid-column: 1 / -1; }
@media (max-width: 720px) {
    .doc-grid { grid-template-columns: 1fr; }
}

/* Line table inside document form */
.lines-wrap { overflow-x: auto; }
.lines-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    border: 1px solid var(--border);
    border-radius: var(--r);
    overflow: hidden;
}
.lines-table th {
    text-align: left;
    padding: 11px 14px;
    font-size: 11px;
    font-weight: 600;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.6px;
    border-bottom: 1px solid var(--border-strong);
    background: var(--bg-soft);
}
.lines-table th:first-child, .lines-table td:first-child { padding-left: 16px; }
.lines-table th:last-child, .lines-table td:last-child { padding-right: 16px; }
.lines-table th.num,
.lines-table td.num { text-align: right; }
.lines-table th.del,
.lines-table td.del { width: 40px; text-align: center; }
.lines-table td {
    padding: 8px 10px;
    border-bottom: 1px solid #f1f3f6;
    vertical-align: top;
}
.lines-table tr:last-child td { border-bottom: none; }
.lines-table tr.line-row:hover td { background: var(--bg-soft); }
.lines-table input,
.lines-table select {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: var(--r-sm);
    font-size: 13px;
    background: var(--card);
    font-family: inherit;
    transition: border-color var(--t-fast) var(--ease), box-shadow var(--t-fast) var(--ease);
}
.lines-table input:focus,
.lines-table select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(79, 70, 229, 0.15);
}
.lines-table input.product-lookup {
    font-weight: 500;
}
.lines-table td.col-product { min-width: 320px; }
.lines-table td.col-qty,
.lines-table td.col-price { width: 150px; }

.lines-totals {
    display: flex;
    justify-content: flex-end;
    gap: 28px;
    margin-left: auto;
    margin-top: 16px;
    width: max-content;
    padding: 14px 20px;
    background: var(--bg-soft);
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    font-size: 13.5px;
    color: var(--muted);
}
.lines-totals > div { display: flex; align-items: baseline; gap: 8px; }
.lines-totals .num-big { font-size: 20px; font-weight: 700; color: var(--text); font-variant-numeric: tabular-nums; letter-spacing: -0.01em; }

.add-line-btn {
    margin-top: 16px;
    background: transparent;
    border: 1.5px dashed var(--border-strong);
    color: var(--primary);
    padding: 10px 18px;
    border-radius: var(--r-sm);
    cursor: pointer;
    font-size: 13.5px;
    font-weight: 500;
    transition: all var(--t-fast) var(--ease);
    font-family: inherit;
}
.add-line-btn:hover {
    border-color: var(--primary);
    background: var(--primary-soft);
    color: var(--primary-dark);
}

.doc-status-info {
    margin-top: 16px;
    padding: 16px 20px;
    background: var(--info-soft);
    border: 1px solid #bae6fd;
    color: var(--info);
    border-radius: var(--r);
    font-size: 14px;
    line-height: 1.5;
}

.doc-footer-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 24px;
    gap: 12px;
    flex-wrap: wrap;
}

/* =====================================================
   Footer
   ===================================================== */

.footer {
    text-align: center;
    padding: 16px 24px;
    color: var(--muted-2);
    font-size: 12px;
    background: var(--card);
    border-top: 1px solid var(--border);
}

/* =====================================================
   Print
   ===================================================== */

@media print {
    .topbar, .sidebar, .messages, .footer, .doc-actions, .doc-footer-actions,
    .add-line-btn, .lines-table td.del, .lines-table th.del { display: none !important; }
    .doc-section { box-shadow: none; border: 1px solid var(--border); }
    body { background: #fff; }
    .main { max-width: none; margin: 0; padding: 0; }
    .layout { display: block; }
    .content-wrap { padding: 0; }
}
/* Marketplace */
.plugin-grid { display:grid; grid-template-columns:repeat(auto-fill,minmax(360px,1fr)); gap:16px; }
.plugin-card { display:flex; gap:18px; padding:22px; background:var(--card); border:1px solid var(--border); border-radius:var(--r-lg); color:inherit; text-decoration:none; box-shadow:var(--shadow-xs); }
.plugin-card:hover { color:inherit; text-decoration:none; border-color:var(--border-strong); box-shadow:var(--shadow); transform:translateY(-1px); }
.plugin-logo { width:56px; height:56px; flex:0 0 56px; display:flex; align-items:center; justify-content:center; border-radius:14px; background:linear-gradient(135deg,#2563eb,#0ea5e9); color:#fff; font-size:18px; font-weight:800; box-shadow:0 6px 16px rgba(37,99,235,.22); }
.plugin-logo-large { width:76px; height:76px; flex-basis:76px; border-radius:18px; font-size:23px; }
.plugin-logo .icon { width:26px; height:26px; }
.plugin-logo-large .icon { width:34px; height:34px; }
.plugin-card-body { flex:1; min-width:0; }
.plugin-card-top { display:flex; justify-content:space-between; align-items:flex-start; gap:12px; }
.plugin-card-top h2 { font-size:18px; }
.plugin-card p { color:var(--muted); margin:8px 0 14px; }
.plugin-hero { display:flex; align-items:center; gap:22px; padding:26px; margin-bottom:24px; background:linear-gradient(135deg,#eff6ff,#fff); border:1px solid #dbeafe; border-radius:var(--r-xl); }
.feature-list { display:grid; grid-template-columns:1fr 1fr; gap:20px; margin-top:20px; }
.feature-list div { display:flex; flex-direction:column; gap:4px; }
.feature-list span { color:var(--muted); font-size:13px; }

@media (max-width: 800px) {
    .plugin-grid { grid-template-columns:1fr; }
    .plugin-hero, .split-layout { flex-direction:column; align-items:stretch; }
    .plugin-hero .btn-primary, .split-layout aside { width:100% !important; }
    .feature-list { grid-template-columns:1fr; }
}

/* =====================================================
   COMPACT DENSITY PASS (унификация + плотность по ТЗ)
   Переопределяет общие компоненты на более компактные.
   ===================================================== */

:root { --appbar-h: 54px; }

body { font-size: 13.5px; line-height: 1.5; }

/* Заголовки чуть собраннее */
h1 { font-size: 22px; }
h2 { font-size: 17px; }
h3 { font-size: 15px; }

/* Основная область — меньше внешних отступов */
.main { margin: 18px auto; }
.appbar { height: var(--appbar-h); }
.subtab { padding: 11px 13px; }
.side-link { padding: 8px 12px; }
.sidebar-brand { padding: 4px 10px 14px; }

/* Поля ввода — единая компактная высота */
.field { margin-bottom: 12px; }
.field label { margin-bottom: 4px; font-size: 12.5px; }
.field input,
.field select,
.field textarea,
.toolbar input,
.toolbar select {
    padding: 7px 11px;
    font-size: 13.5px;
    border-radius: 9px;
    min-height: 36px;
    box-shadow: none;
}
.field textarea { min-height: auto; }

/* Кнопки — единый компактный размер */
.btn-primary, .btn-secondary, .btn-danger { min-height: 34px; font-size: 13.5px; padding: 7px 15px; }
.btn-primary-small { min-height: 32px; font-size: 13px; padding: 6px 13px; }

/* Карточки-секции документа — плотнее */
.doc-section { padding: 16px 18px; margin-bottom: 14px; }
.doc-section-title { margin-bottom: 12px; }
.doc-grid { gap: 11px 18px; }
.doc-header { margin-bottom: 14px; }

/* Сводная карточка-обзор — компактнее */
.ds-item { padding: 9px 14px; gap: 3px; }
.ds-value { font-size: 13.5px; }
.ds-value.big { font-size: 16px; }
.doc-summary { margin-bottom: 14px; }

/* Карточки */
.card { padding: 15px 16px; }
.cards { gap: 12px; margin: 18px 0; }

/* Списки — строки ниже, шапка плотнее */
.table thead th { padding: 8px 14px; font-size: 10.5px; }
.table tbody td { padding: 8px 14px; font-size: 13px; }
.table thead th:first-child, .table tbody td:first-child { padding-left: 18px; }
.table thead th:last-child, .table tbody td:last-child { padding-right: 18px; }

/* Таблица позиций документа — компактные строки и инпуты */
.lines-table th { padding: 8px 12px; }
.lines-table td { padding: 5px 10px; }
.lines-table input, .lines-table select { padding: 6px 10px; font-size: 13px; min-height: 32px; }
.lines-totals { padding: 11px 18px; margin-top: 12px; }
.lines-totals .num-big { font-size: 18px; }
.add-line-btn { margin-top: 12px; padding: 8px 15px; }

/* Фильтры (форма-секция списка) — плотная сетка */
.doc-section .doc-grid { gap: 10px 16px; }

/* Дашборд — компактнее */
.kpi-card { padding: 14px 16px; }
.kpi-icon { width: 40px; height: 40px; }
.kpi-value { font-size: 26px; }
.quick-link { padding: 14px 12px; }
.dash-hero { margin-bottom: 20px; padding-bottom: 16px; }
.dash-hero h1 { font-size: 23px; }

/* Сообщения/плашки — компактнее */
.msg { padding: 9px 14px; }
.doc-status-info { padding: 12px 16px; margin-top: 12px; }

/* Кнопка удаления строки товара (вместо галочки DELETE) */
.del-hidden { display: none; }
.lines-table td.del { width: 40px; text-align: center; }
.row-del-btn {
    width: 26px; height: 26px; line-height: 1;
    border: 1px solid transparent; border-radius: 7px;
    background: transparent; color: var(--muted-2);
    font-size: 18px; cursor: pointer; transition: all var(--t-fast) var(--ease);
    display: inline-flex; align-items: center; justify-content: center;
}
.row-del-btn:hover { background: var(--error-soft); color: var(--error); border-color: rgba(220,38,38,0.2); }
.lines-table tr.row-removed { display: none; }
