/* ============================================
   KRLab Desk — Единый CSS
   ============================================ */

/* --- @font-face: Inter --- */
@font-face {
    font-family: 'Inter';
    src: url('../fonts/inter/InterVariable.ttf') format('truetype');
    font-weight: 100 900;
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: 'Inter';
    src: url('../fonts/inter/InterVariable-Italic.ttf') format('truetype');
    font-weight: 100 900;
    font-style: italic;
    font-display: swap;
}

/* --- CSS Variables --- */
:root {
    /* Colors */
    --primary: #4f46e5;
    --primary-hover: #4338ca;
    --primary-light: #eef2ff;
    --success: #22c55e;
    --success-hover: #16a34a;
    --danger: #ef4444;
    --danger-hover: #dc2626;
    --warning: #f59e0b;
    --warning-hover: #d97706;
    --info: #3b82f6;
    --info-hover: #2563eb;
    --secondary: #64748b;
    --secondary-hover: #475569;

    /* Neutrals */
    --white: #ffffff;
    --gray-50: #f8fafc;
    --gray-100: #f1f5f9;
    --gray-200: #e2e8f0;
    --gray-300: #cbd5e1;
    --gray-400: #94a3b8;
    --gray-500: #64748b;
    --gray-600: #475569;
    --gray-700: #334155;
    --gray-800: #1e293b;
    --gray-900: #0f172a;
    --dark: #1e293b;
    --light: #f8fafc;

    /* Semantic */
    --text-color: #1e293b;
    --text-muted: #64748b;
    --border-color: #e2e8f0;
    --bg-color: #f1f5f9;
    --card-bg: #ffffff;

    /* Sidebar */
    --sidebar-width: 260px;
    --sidebar-collapsed-width: 70px;
    --sidebar-bg: #1e293b;
    --sidebar-text: #94a3b8;
    --sidebar-active: #4f46e5;

    /* Layout */
    --topbar-height: 64px;

    /* Radius */
    --border-radius: 0.5rem;
    --border-radius-sm: 0.25rem;
    --border-radius-lg: 0.75rem;
    --radius-sm: 0.375rem;
    --radius-md: 0.5rem;
    --radius-lg: 0.75rem;
    --radius-xl: 1rem;

    /* Shadows */
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow: 0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);

    /* Transitions */
    --transition: 0.2s ease;
}

/* --- Reset & Base --- */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    font-size: 0.9375rem;
    line-height: 1.5;
    color: var(--text-color);
    background-color: var(--bg-color);
    min-height: 100vh;
}

a {
    color: var(--primary);
    text-decoration: none;
}
a:hover {
    text-decoration: none;
}

img {
    max-width: 100%;
    height: auto;
}

/* --- Grid System (12-column CSS Grid) --- */
.row {
    display: grid;
    grid-template-columns: repeat(12, 1fr);
    gap: 1.5rem;
}

[class*="col-"] {
    grid-column: span 12;
}

@media (min-width: 1200px) {
    .row .col-xl-3 { grid-column: span 3; }
    .row .col-xl-4 { grid-column: span 4; }
    .row .col-xl-5 { grid-column: span 5; }
    .row .col-xl-6 { grid-column: span 6; }
    .row .col-xl-7 { grid-column: span 7; }
    .row .col-xl-8 { grid-column: span 8; }
    .row .col-xl-9 { grid-column: span 9; }
    .row .col-xl-12 { grid-column: span 12; }
}

@media (min-width: 768px) {
    .row .col-md-3 { grid-column: span 3; }
    .row .col-md-4 { grid-column: span 4; }
    .row .col-md-5 { grid-column: span 5; }
    .row .col-md-6 { grid-column: span 6; }
    .row .col-md-7 { grid-column: span 7; }
    .row .col-md-8 { grid-column: span 8; }
    .row .col-md-9 { grid-column: span 9; }
    .row .col-md-12 { grid-column: span 12; }
}

.col-12 { grid-column: span 12; }

/* Grid gaps */
.g-0 { gap: 0; }
.g-1 { gap: 0.25rem; }
.g-2 { gap: 0.5rem; }
.g-3 { gap: 1rem; }
.g-4 { gap: 1.5rem; }
.g-5 { gap: 2rem; }

/* --- Flex Utilities --- */
.d-flex { display: flex; }
.flex-column { flex-direction: column; }
.d-none { display: none !important; }
.flex-fill { flex: 1 1 auto; }
.align-items-center { align-items: center; }
.align-items-start { align-items: flex-start; }
.align-items-end { align-items: flex-end; }
.justify-content-between { justify-content: space-between; }
.flex-wrap { flex-wrap: wrap; }

/* --- Display Utilities --- */
.d-block { display: block; }
.d-inline-block { display: inline-block; }
.d-inline { display: inline; }

/* --- Spacing --- */
.m-0 { margin: 0; }
.m-1 { margin: 0.25rem; }
.m-2 { margin: 0.5rem; }
.m-3 { margin: 1rem; }
.m-4 { margin: 1.5rem; }
.mt-0 { margin-top: 0; }
.mt-1 { margin-top: 0.25rem; }
.mt-2 { margin-top: 0.5rem; }
.mt-3 { margin-top: 1rem; }
.mt-4 { margin-top: 1.5rem; }
.mb-0 { margin-bottom: 0; }
.mb-1 { margin-bottom: 0.25rem; }
.mb-2 { margin-bottom: 0.5rem; }
.mb-3 { margin-bottom: 1rem; }
.mb-4 { margin-bottom: 1.5rem; }
.ms-1 { margin-left: 0.25rem; }
.ms-2 { margin-left: 0.5rem; }
.ms-auto { margin-left: auto; }
.me-1 { margin-right: 0.25rem; }
.me-2 { margin-right: 0.5rem; }
.me-3 { margin-right: 1rem; }
.me-auto { margin-right: auto; }
.mx-auto { margin-left: auto; margin-right: auto; }
.my-4 { margin-top: 1.5rem; margin-bottom: 1.5rem; }

.p-0 { padding: 0; }
.p-1 { padding: 0.25rem; }
.p-2 { padding: 0.5rem; }
.p-3 { padding: 1rem; }
.p-4 { padding: 1.5rem; }
.pt-2 { padding-top: 0.5rem; }
.pb-2 { padding-bottom: 0.5rem; }
.py-2 { padding-top: 0.5rem; padding-bottom: 0.5rem; }
.px-2 { padding-left: 0.5rem; padding-right: 0.5rem; }
.px-3 { padding-left: 1rem; padding-right: 1rem; }

/* --- Text Utilities --- */
.text-center { text-align: center; }
.text-end { text-align: right; }
.text-start { text-align: left; }
.text-muted { color: var(--text-muted); }
.text-danger { color: var(--danger); }
.text-success { color: var(--success); }
.text-primary { color: var(--primary); }
.text-dark { color: var(--dark); }
.text-white { color: var(--white); }
.text-small { font-size: 0.8125rem; }
.text-decoration-none { text-decoration: none; }

.fw-bold { font-weight: 700; }
.fw-semibold { font-weight: 600; }
.small { font-size: 0.8125rem; }

/* --- Background Utilities --- */
.bg-primary { background-color: var(--primary); color: var(--white); }
.bg-secondary { background-color: var(--secondary); color: var(--white); }
.bg-success { background-color: var(--success); color: var(--white); }
.bg-danger { background-color: var(--danger); color: var(--white); }
.bg-warning { background-color: var(--warning); }
.bg-info { background-color: var(--info); color: var(--white); }
.bg-light { background-color: var(--gray-100); }
.bg-white { background-color: var(--white); }

/* --- Border Utilities --- */
.border-0 { border: 0; }
.border { border: 1px solid var(--border-color); }
.border-bottom { border-bottom: 1px solid var(--border-color); }
.border-top { border-top: 1px solid var(--border-color); }
.rounded { border-radius: var(--border-radius); }
.rounded-sm { border-radius: var(--border-radius-sm); }
.rounded-circle { border-radius: 50%; }

/* --- Width/Height --- */
.w-100 { width: 100%; }
.h-100 { height: 100%; }

/* --- Position --- */
.position-fixed { position: fixed; }
.position-absolute { position: absolute; }
.position-relative { position: relative; }
.top-0 { top: 0; }
.end-0 { right: 0; }
.bottom-0 { bottom: 0; }
.start-0 { left: 0; }

/* --- Shadow --- */
.shadow-sm { box-shadow: var(--shadow-sm); }
.shadow { box-shadow: var(--shadow); }
.shadow-lg { box-shadow: var(--shadow-lg); }

/* --- Overflow --- */
.overflow-auto { overflow: auto; }
.overflow-hidden { overflow: hidden; }

/* --- Gap --- */
.gap-1 { gap: 0.25rem; }
.gap-2 { gap: 0.5rem; }
.gap-3 { gap: 1rem; }

/* ============================================
   Sidebar
   ============================================ */

.sidebar {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    width: var(--sidebar-width);
    background: var(--sidebar-bg);
    color: var(--sidebar-text);
    display: flex;
    flex-direction: column;
    z-index: 1000;
    transition: width 0.3s ease;
}

.sidebar.collapsed {
    width: var(--sidebar-collapsed-width);
}

.sidebar.collapsed .brand,
.sidebar.collapsed .nav-link span,
.sidebar.collapsed .user-details {
    display: none;
}

.sidebar.collapsed .nav-link {
    justify-content: center;
    padding: 0.75rem;
}

.sidebar.collapsed .nav-link i {
    font-size: 1rem;
    margin: 0;
}

.sidebar.collapsed .user-info {
    justify-content: center;
}

.sidebar.collapsed .user-avatar {
    margin: 0;
}

.sidebar-header {
    padding: 1.25rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.brand {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 1.25rem;
    font-weight: 700;
    color: white;
    white-space: nowrap;
    overflow: hidden;
    min-width: 0;
}

.brand i {
    font-size: 1.5rem;
    color: var(--primary);
}

.sidebar-toggle {
    background: none;
    border: none;
    color: var(--sidebar-text);
    cursor: pointer;
    padding: 0.5rem;
    border-radius: 0.375rem;
    transition: all 0.2s;
}

.sidebar-toggle:hover {
    background: rgba(255, 255, 255, 0.1);
    color: white;
}

.sidebar-nav {
    flex: 1;
    padding: 1rem 0;
    overflow-y: auto;
    list-style: none;
}

.nav-item {
    margin: 0.125rem 0.5rem;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    color: var(--sidebar-text);
    text-decoration: none;
    border-radius: 0.5rem;
    transition: all 0.2s;
    font-size: 0.9rem;
}

.nav-link:hover {
    background: rgba(255, 255, 255, 0.1);
    color: white;
    text-decoration: none;
}

.nav-link.active {
    background: var(--sidebar-active);
    color: white;
}

.nav-link i {
    width: 20px;
    text-align: center;
    font-size: 1rem;
}

.nav-divider {
    height: 1px;
    background: rgba(255, 255, 255, 0.1);
    margin: 0.75rem 1rem;
}

/* Sidebar submenu */
.nav-arrow {
    margin-left: auto;
    font-size: 0.7rem;
    transition: transform 0.2s;
}

.nav-item.has-children .nav-link {
    position: relative;
}

.nav-item.has-children.active > .nav-link .nav-arrow,
.nav-item.has-children:hover > .nav-link .nav-arrow {
    transform: rotate(180deg);
}

.nav-submenu {
    list-style: none;
    padding: 0;
    margin: 0;
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease;
}

.nav-item.has-children.active > .nav-submenu,
.nav-item.has-children:hover > .nav-submenu {
    max-height: 400px;
}

.nav-submenu .nav-link {
    padding-left: 3rem;
    font-size: 0.8rem;
}

.nav-submenu .nav-link i {
    width: 16px;
    font-size: 0.8rem;
}

.nav-submenu .nav-item.active .nav-link {
    background: rgba(79, 70, 229, 0.15);
    color: var(--primary);
}

.sidebar-footer {
    padding: 1rem;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.user-info,
a.user-info,
a.user-info:hover,
a.user-info:focus,
a.user-info:visited {
    text-decoration: none !important;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.5rem;
    border-radius: 0.5rem;
    transition: background 0.2s ease;
}

a.user-info:hover {
    background: rgba(255, 255, 255, 0.1);
}

a.user-info .user-name {
    color: white;
}

a.user-info .user-role {
    color: var(--sidebar-text);
}

.user-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--primary);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 1rem;
}

.user-details {
    display: flex;
    flex-direction: column;
}

.user-name {
    color: white;
    font-weight: 500;
    font-size: 0.9rem;
}

.user-role {
    color: var(--sidebar-text);
    font-size: 0.75rem;
}

/* ============================================
   Main Content
   ============================================ */

.main-content {
    margin-left: var(--sidebar-width);
    min-height: 100vh;
    transition: margin-left 0.3s ease;
}

.sidebar.collapsed ~ .main-content {
    margin-left: var(--sidebar-collapsed-width);
}

/* ============================================
   Top Bar
   ============================================ */

.top-bar {
    height: var(--topbar-height);
    background: var(--card-bg);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1.5rem;
    position: sticky;
    top: 0;
    z-index: 100;
}

.top-bar-left {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.page-title {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text-color);
}

.current-date {
    color: var(--text-muted);
    font-size: 0.9rem;
}

.top-bar-right {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.search-box {
    position: relative;
}

.search-box i {
    position: absolute;
    left: 0.75rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
}

.search-box input {
    padding: 0.5rem 1rem 0.5rem 2.25rem;
    border: 1px solid var(--border-color);
    border-radius: 0.5rem;
    font-size: 0.9rem;
    width: 250px;
    transition: all 0.2s;
}

.search-box input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

/* ============================================
   Dashboard Content
   ============================================ */

.page-content {
    padding: 1.5rem;
}

/* ============================================
   Stat Cards
   ============================================ */

.stat-card {
    background: var(--card-bg);
    border-radius: 0.75rem;
    padding: 1.25rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
    border: 1px solid var(--border-color);
    transition: transform 0.2s, box-shadow 0.2s;
}

.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.stat-icon {
    width: 56px;
    height: 56px;
    border-radius: 0.75rem;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
}

.stat-card-warning .stat-icon {
    background: #fef3c7;
    color: #d97706;
}

.stat-card-info .stat-icon {
    background: #dbeafe;
    color: #2563eb;
}

.stat-card-danger .stat-icon {
    background: #fee2e2;
    color: #dc2626;
}

.stat-card-success .stat-icon {
    background: #dcfce7;
    color: #16a34a;
}

.stat-info {
    display: flex;
    flex-direction: column;
}

.stat-value {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--text-color);
    line-height: 1.2;
}

.stat-label {
    color: var(--text-muted);
    font-size: 0.85rem;
}

/* ============================================
   Buttons
   ============================================ */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
    font-weight: 500;
    line-height: 1.5;
    border: 1px solid transparent;
    border-radius: var(--border-radius-sm);
    cursor: pointer;
    transition: all var(--transition);
    text-decoration: none;
    white-space: nowrap;
    user-select: none;
}
.btn:hover {
    text-decoration: none;
    opacity: 0.9;
}
.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}
.btn-sm {
    padding: 0.25rem 0.75rem;
    font-size: 0.8125rem;
}
.btn-lg {
    padding: 0.625rem 1.25rem;
    font-size: 1rem;
}

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

.btn-secondary {
    background-color: var(--secondary);
    color: var(--white);
    border-color: var(--secondary);
}
.btn-secondary:hover {
    background-color: var(--secondary-hover);
    border-color: var(--secondary-hover);
}

.btn-success {
    background-color: var(--success);
    color: var(--white);
    border-color: var(--success);
}
.btn-success:hover {
    background-color: var(--success-hover);
    border-color: var(--success-hover);
}

.btn-danger {
    background-color: var(--danger);
    color: var(--white);
    border-color: var(--danger);
}
.btn-danger:hover {
    background-color: var(--danger-hover);
    border-color: var(--danger-hover);
}

.btn-warning {
    background-color: var(--warning);
    color: var(--white);
    border-color: var(--warning);
}
.btn-warning:hover {
    background-color: var(--warning-hover);
    border-color: var(--warning-hover);
}

.btn-info {
    background-color: var(--info);
    color: var(--white);
    border-color: var(--info);
}
.btn-info:hover {
    background-color: var(--info-hover);
    border-color: var(--info-hover);
}

.btn-outline-primary {
    background-color: transparent;
    color: var(--primary);
    border-color: var(--primary);
}
.btn-outline-primary:hover {
    background-color: var(--primary);
    color: var(--white);
}

.btn-outline-secondary {
    background-color: transparent;
    color: var(--secondary);
    border-color: var(--secondary);
}
.btn-outline-secondary:hover {
    background-color: var(--secondary);
    color: var(--white);
}

.btn-outline-success {
    background-color: transparent;
    color: var(--success);
    border-color: var(--success);
}
.btn-outline-success:hover {
    background-color: var(--success);
    color: var(--white);
}

.btn-outline-danger {
    background-color: transparent;
    color: var(--danger);
    border-color: var(--danger);
}
.btn-outline-danger:hover {
    background-color: var(--danger);
    color: var(--white);
}

.btn-outline-warning {
    background-color: transparent;
    color: var(--warning);
    border-color: var(--warning);
}
.btn-outline-warning:hover {
    background-color: var(--warning);
    color: var(--white);
}

.btn-outline-info {
    background-color: transparent;
    color: var(--info);
    border-color: var(--info);
}
.btn-outline-info:hover {
    background-color: var(--info);
    color: var(--white);
}

.btn-icon {
    width: 40px;
    height: 40px;
    padding: 0;
    border-radius: 0.5rem;
    border: 1px solid var(--border-color);
    background: var(--card-bg);
    color: var(--text-muted);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
    text-decoration: none;
    position: relative;
}

.btn-icon:hover {
    background: var(--bg-color);
    color: var(--text-color);
}

.btn-icon i {
    font-size: 1rem;
}

.notification-btn .badge {
    position: absolute;
    top: -5px;
    right: -5px;
    background: var(--danger);
    color: white;
    font-size: 0.7rem;
    padding: 0.2rem 0.4rem;
    border-radius: 50%;
    min-width: 18px;
    height: 18px;
}

.btn-group {
    display: inline-flex;
}
.btn-group .btn {
    border-radius: 0;
}
.btn-group .btn:first-child {
    border-radius: var(--border-radius-sm) 0 0 var(--border-radius-sm);
}
.btn-group .btn:last-child {
    border-radius: 0 var(--border-radius-sm) var(--border-radius-sm) 0;
}
.btn-group-sm .btn {
    padding: 0.25rem 0.5rem;
    font-size: 0.75rem;
}

.btn-loading {
    position: relative;
    pointer-events: none;
}
.btn-loading::after {
    content: '';
    display: inline-block;
    width: 1rem;
    height: 1rem;
    border: 2px solid currentColor;
    border-right-color: transparent;
    border-radius: 50%;
    animation: btn-spin 0.6s linear infinite;
    margin-left: 0.5rem;
}
@keyframes btn-spin {
    to { transform: rotate(360deg); }
}

/* ============================================
   Cards
   ============================================ */
.card {
    background: var(--card-bg);
    border-radius: 0.75rem;
    border: 1px solid var(--border-color);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
    overflow: hidden;
}
.card-header {
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--border-color);
    background: transparent;
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.card-body {
    padding: 1.25rem;
}
.card-title {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-color);
    margin: 0;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}
.card-text {
    color: var(--text-muted);
    font-size: 0.875rem;
}

/* ============================================
   Tables
   ============================================ */
.table-responsive {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
    margin: 0;
}
.table th {
    background-color: transparent;
    font-weight: 600;
    font-size: 0.8125rem;
    color: var(--text-muted);
    padding: 0.75rem 1rem;
    text-align: left;
    border-bottom: 2px solid var(--border-color);
    white-space: nowrap;
}
.table td {
    padding: 0.875rem 1rem;
    border-bottom: 1px solid var(--border-color);
    vertical-align: middle;
}
.table-hover tbody tr:hover {
    background-color: var(--gray-50);
}
.table-danger td {
    background-color: #fee2e2;
}
.table-warning td {
    background-color: #fffbeb;
}
.table-warning:hover td {
    background-color: #fef3c7;
}
.table a {
    color: var(--primary);
    text-decoration: none;
}
.table a:hover {
    text-decoration: none;
}

/* ============================================
   Forms
   ============================================ */
.form-container {
    max-width: 900px;
    margin: 0 auto;
    padding: 1.5rem;
}
.form-header {
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border-color);
}
.form-footer {
    margin-top: 1.5rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border-color);
    display: flex;
    gap: 0.75rem;
    justify-content: flex-end;
}

.form-group {
    margin-bottom: 1rem;
}

.form-label {
    display: block;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-color);
    margin-bottom: 0.375rem;
}
.form-label.required::after {
    content: ' *';
    color: var(--danger);
}

.form-control {
    display: block;
    width: 100%;
    padding: 0.5rem 0.75rem;
    font-size: 0.9375rem;
    line-height: 1.5;
    color: var(--text-color);
    background-color: var(--white);
    border: 1px solid var(--gray-300);
    border-radius: var(--border-radius-sm);
    transition: border-color var(--transition), box-shadow var(--transition);
    appearance: none;
}
.form-control:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.15);
}
.form-control:disabled {
    background-color: var(--gray-100);
    opacity: 0.7;
    cursor: not-allowed;
}
.form-control-sm {
    padding: 0.25rem 0.5rem;
    font-size: 0.8125rem;
    border-radius: var(--border-radius-sm);
}

.form-select {
    display: block;
    width: 100%;
    padding: 0.5rem 2rem 0.5rem 0.75rem;
    font-size: 0.9375rem;
    line-height: 1.5;
    color: var(--text-color);
    background-color: var(--white);
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3e%3cpath fill='none' stroke='%343a40' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='m2 5 6 6 6-6'/%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right 0.75rem center;
    background-size: 16px 12px;
    border: 1px solid var(--gray-300);
    border-radius: var(--border-radius-sm);
    appearance: none;
}
.form-select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.15);
}
.form-select-sm {
    padding: 0.25rem 2rem 0.25rem 0.5rem;
    font-size: 0.8125rem;
}

.form-check {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
}
.form-check-input {
    width: 1rem;
    height: 1rem;
    margin: 0;
    cursor: pointer;
    accent-color: var(--primary);
}
.form-check-label {
    font-size: 0.875rem;
    cursor: pointer;
}

.form-switch {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}
.form-switch .form-check-input {
    width: 2.5rem;
    height: 1.25rem;
    border-radius: 1rem;
    background-color: var(--gray-400);
    border: none;
    transition: background-color var(--transition);
    position: relative;
}
.form-switch .form-check-input::before {
    content: '';
    position: absolute;
    width: 1rem;
    height: 1rem;
    border-radius: 50%;
    background: var(--white);
    top: 0.125rem;
    left: 0.125rem;
    transition: transform var(--transition);
}
.form-switch .form-check-input:checked {
    background-color: var(--primary);
}
.form-switch .form-check-input:checked::before {
    transform: translateX(1.25rem);
}

.form-text {
    font-size: 0.8125rem;
    color: var(--text-muted);
    margin-top: 0.25rem;
}

.input-group {
    display: flex;
    align-items: stretch;
    border-radius: var(--radius-md);
    border: 1px solid var(--gray-300);
    overflow: hidden;
    transition: border-color var(--transition), box-shadow var(--transition);
}
.input-group .form-control {
    border-radius: 0;
    flex: 1 1 auto;
    border: none;
}
.input-group .form-control:first-child {
    border-radius: var(--border-radius-sm) 0 0 var(--border-radius-sm);
}
.input-group .form-control:last-child {
    border-radius: 0 var(--border-radius-sm) var(--border-radius-sm) 0;
}
.input-group-text {
    display: flex;
    align-items: center;
    padding: 0.5rem 0.75rem;
    font-size: 0.875rem;
    color: var(--text-muted);
    background-color: var(--gray-50);
    border: none;
}
.input-group .input-group-text:first-child {
    border-radius: var(--border-radius-sm) 0 0 var(--border-radius-sm);
    border-right: 1px solid var(--gray-200);
}
.input-group .input-group-text:last-child {
    border-radius: 0 var(--border-radius-sm) var(--border-radius-sm) 0;
    border-left: 1px solid var(--gray-200);
}

.input-group:focus-within {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

/* ============================================
   Badges
   ============================================ */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 0.25em 0.65em;
    font-size: 0.75rem;
    font-weight: 600;
    line-height: 1;
    border-radius: var(--border-radius-sm);
    white-space: nowrap;
    vertical-align: middle;
}

.badge-primary,
.bg-primary {
    background-color: var(--primary);
    color: var(--white);
}
.badge-secondary,
.bg-secondary {
    background-color: var(--secondary);
    color: var(--white);
}
.badge-success,
.bg-success {
    background-color: var(--success);
    color: var(--white);
}
.badge-danger,
.bg-danger {
    background-color: var(--danger);
    color: var(--white);
}
.badge-warning {
    background-color: var(--warning);
    color: var(--white);
}
.badge-info,
.bg-info {
    background-color: var(--info);
    color: var(--white);
}
.badge-light {
    background-color: var(--gray-200);
    color: var(--gray-800);
}
.badge-dark {
    background-color: var(--dark);
    color: var(--white);
}

/* Badge roles */
.badge-admin { background: #dc3545; color: white; }
.badge-manager { background: #0d6efd; color: white; }
.badge-user { background: #6c757d; color: white; }

/* ============================================
   Alerts
   ============================================ */
.alert {
    padding: 1rem 1.25rem;
    border-radius: var(--border-radius);
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 0.875rem;
    border: none;
}
.alert-success {
    background-color: #f0fdf4;
    color: #166534;
    border-left: 4px solid var(--success);
}
.alert-danger {
    background-color: #fef2f2;
    color: #991b1b;
    border-left: 4px solid var(--danger);
}
.alert-warning {
    background-color: #fffbeb;
    color: #92400e;
    border-left: 4px solid var(--warning);
}
.alert-info {
    background-color: #eff6ff;
    color: #1e40af;
    border-left: 4px solid var(--info);
}

/* ============================================
   Modal
   ============================================ */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1050;
    align-items: center;
    justify-content: center;
}
.modal.show {
    display: flex;
}

.modal-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 1040;
    opacity: 0;
    transition: opacity 0.3s;
}
.modal-backdrop.show {
    opacity: 1;
}

.modal-dialog {
    position: relative;
    z-index: 1051;
    width: 100%;
    max-width: 500px;
    margin: 1.75rem auto;
    transform: translateY(-50px);
    opacity: 0;
    transition: transform 0.3s, opacity 0.3s;
    max-height: calc(100vh - 3.5rem);
}
.modal.show .modal-dialog {
    transform: translateY(0);
    opacity: 1;
}
.modal-lg {
    max-width: 800px;
}

.modal-content {
    background: var(--white);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-lg);
    display: flex;
    flex-direction: column;
    max-height: calc(100vh - 3.5rem);
    overflow: hidden;
}
.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--border-color);
    flex-shrink: 0;
}
.modal-title {
    font-size: 1.125rem;
    font-weight: 600;
}
.btn-close {
    background: none;
    border: none;
    font-size: 1.25rem;
    color: var(--gray-400);
    cursor: pointer;
    padding: 0.25rem;
    line-height: 1;
}
.btn-close:hover {
    color: var(--dark);
}
.modal-body {
    padding: 1rem 1.25rem;
    flex: 1 1 auto;
    overflow-y: auto;
    min-height: 0;
    max-height: calc(100vh - 10rem);
}
.modal-form {
    display: flex;
    flex-direction: column;
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
}
.modal-form .form-label {
    font-size: 0.8125rem;
    margin-bottom: 0.25rem;
}

/* Grid inside modal form */
.modal-form .row {
    display: grid !important;
    grid-template-columns: repeat(12, 1fr) !important;
    gap: 0.75rem !important;
}

.modal-form .col-12 { grid-column: span 12 !important; }
.modal-form .col-md-3 { grid-column: span 3 !important; }
.modal-form .col-md-4 { grid-column: span 4 !important; }
.modal-form .col-md-5 { grid-column: span 5 !important; }
.modal-form .col-md-6 { grid-column: span 6 !important; }
.modal-form .col-md-7 { grid-column: span 7 !important; }
.modal-form .col-md-8 { grid-column: span 8 !important; }
.modal-form .col-md-9 { grid-column: span 9 !important; }
.modal-form .col-md-12 { grid-column: span 12 !important; }

/* Form sections inside modal */
.modal-form .form-section {
    margin-bottom: 1rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border-color);
}

.modal-form .form-section:last-child {
    border-bottom: none;
    margin-bottom: 0;
    padding-bottom: 0;
}

.modal-form .section-title {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-color);
    margin-bottom: 0.75rem;
}

.modal-form .section-title i {
    color: var(--primary);
}

.modal-footer {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 0.5rem;
    padding: 0.75rem 1.25rem;
    border-top: 1px solid var(--border-color);
    flex-shrink: 0;
    background: var(--white);
}

/* ============================================
   Toast
   ============================================ */
.toast-container {
    position: fixed;
    top: 1rem;
    right: 1rem;
    z-index: 1060;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.toast {
    display: none;
    align-items: flex-start;
    gap: 0.75rem;
    min-width: 300px;
    max-width: 400px;
    padding: 1rem 1.25rem;
    background: var(--white);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-lg);
    border-left: 4px solid var(--primary);
    animation: toast-slide 0.3s ease;
}
.toast.toast-visible {
    display: flex;
}
.toast-success { border-left-color: var(--success); }
.toast-danger { border-left-color: var(--danger); }
.toast-warning { border-left-color: var(--warning); }
.toast-info { border-left-color: var(--info); }

.toast-body {
    flex: 1;
    font-size: 0.875rem;
}
.toast-header {
    font-weight: 600;
    font-size: 0.875rem;
    margin-bottom: 0.25rem;
}

@keyframes toast-slide {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

/* ============================================
   Spinner
   ============================================ */
.spinner-border {
    display: inline-block;
    width: 2rem;
    height: 2rem;
    border: 0.25em solid var(--gray-300);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spinner-border 0.75s linear infinite;
}
.spinner-border-sm {
    width: 1rem;
    height: 1rem;
    border-width: 0.15em;
}
@keyframes spinner-border {
    to { transform: rotate(360deg); }
}

.fa-spin {
    animation: fa-spin 1s infinite linear;
}
@keyframes fa-spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* ============================================
   Order List
   ============================================ */

.order-list {
    display: flex;
    flex-direction: column;
}

.order-item {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.875rem 1.25rem;
    text-decoration: none;
    color: var(--text-color);
    border-bottom: 1px solid var(--border-color);
    transition: background 0.2s;
}

.order-item:last-child {
    border-bottom: none;
}

.order-item:hover {
    background: var(--gray-50);
    text-decoration: none;
}

.order-item.urgent {
    border-left: 3px solid var(--warning);
}

.order-item.overdue {
    border-left: 3px solid var(--danger);
    background: #fef2f2;
}

.order-priority {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}

.priority-low { background: #94a3b8; }
.priority-normal { background: #3b82f6; }
.priority-high { background: #f59e0b; }
.priority-urgent { background: #ef4444; }

.order-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.order-number {
    font-weight: 600;
    color: var(--primary);
}

.order-counterparty {
    font-size: 0.85rem;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.order-meta {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 0.25rem;
}

.order-status {
    padding: 0.2rem 0.5rem;
    border-radius: 0.25rem;
    font-size: 0.75rem;
    font-weight: 500;
}

.order-deadline {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.order-deadline i {
    margin-right: 0.25rem;
}

/* ============================================
   Status Row
   ============================================ */

.status-row {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.5rem 0;
    border-bottom: 1px solid var(--border-color);
}

.status-row:last-child {
    border-bottom: none;
}

.status-indicator {
    width: 12px;
    height: 12px;
    border-radius: 3px;
    flex-shrink: 0;
}

.status-name {
    flex: 1;
    font-size: 0.9rem;
    color: var(--text-color);
}

.status-count {
    font-weight: 600;
    color: var(--text-color);
}

/* ============================================
   Empty State
   ============================================ */
.empty-state {
    text-align: center;
    padding: 4rem 2rem;
    color: var(--text-muted);
}
.empty-state > i {
    font-size: 4rem;
    margin-bottom: 1rem;
    opacity: 0.3;
    display: block;
}
.empty-state p {
    font-size: 1.1rem;
    margin-bottom: 1.5rem;
}
.empty-state .btn i {
    font-size: 1rem;
    margin-right: 0.375rem;
}

/* ============================================
   Pagination (Загрузить ещё)
   ============================================ */
.pagination-section {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    padding: 1.25rem;
    margin-top: 0.5rem;
}
.pagination-info {
    font-size: 0.875rem;
    color: var(--text-muted);
}
.pagination-info span {
    font-weight: 600;
    color: var(--text-color);
}

/* ============================================
   Page Placeholder (страницы в разработке)
   ============================================ */
.page-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 60vh;
    text-align: center;
    color: var(--text-muted);
}
.page-placeholder i {
    font-size: 4rem;
    margin-bottom: 1.5rem;
    opacity: 0.3;
}
.page-placeholder h2 {
    font-size: 1.5rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
    color: var(--text-color);
}
.page-placeholder p {
    font-size: 1rem;
    max-width: 400px;
}

/* ============================================
   Login Page
   ============================================ */

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

.login-branding {
    flex: 1;
    background: linear-gradient(135deg, var(--primary) 0%, #7c3aed 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 3rem;
    position: relative;
    overflow: hidden;
}

.login-branding::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%23ffffff' fill-opacity='0.05'%3E%3Cpath d='M36 34v-4h-2v4h-4v2h4v4h2v-4h4v-2h-4zm0-30V0h-2v4h-4v2h4v4h2V6h4V4h-4zM6 34v-4H4v4H0v2h4v4h2v-4h4v-2H6zM6 4V0H4v4H0v2h4v4h2V6h4V4H6z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");
    opacity: 0.5;
}

.branding-content {
    position: relative;
    z-index: 1;
    text-align: center;
    color: white;
    max-width: 400px;
}

.brand-logo {
    width: 100px;
    height: 100px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 2rem;
    font-size: 2.5rem;
    backdrop-filter: blur(10px);
    border: 2px solid rgba(255, 255, 255, 0.3);
}

.brand-title {
    font-size: 2.5rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
    letter-spacing: -0.02em;
}

.brand-subtitle {
    font-size: 1.1rem;
    opacity: 0.9;
    margin-bottom: 3rem;
}

.brand-features {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.feature-item {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem;
    background: rgba(255, 255, 255, 0.1);
    border-radius: var(--radius-md);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    transition: transform 0.2s, background 0.2s;
}

.feature-item:hover {
    transform: translateX(5px);
    background: rgba(255, 255, 255, 0.15);
}

.feature-item i {
    font-size: 1.25rem;
    width: 24px;
    text-align: center;
}

.login-form-section {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 3rem;
    background: var(--white);
}

.login-form-section .form-container {
    width: 100%;
    max-width: 400px;
}

.login-form-section .form-header h2 {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--text-color);
    margin-bottom: 0.5rem;
}

.login-form-section .form-header p {
    color: var(--text-muted);
    font-size: 1rem;
}

.btn-login {
    padding: 0.875rem 1.5rem;
    font-size: 1rem;
    font-weight: 600;
    border-radius: var(--radius-md);
    transition: all 0.2s;
    margin-top: 0.5rem;
}

.btn-login:not(:disabled) {
    background: linear-gradient(135deg, var(--primary) 0%, #7c3aed 100%);
    border: none;
    color: white;
}

.btn-login:not(:disabled):hover {
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.btn-login:not(:disabled):active {
    transform: translateY(0);
}

.btn-login:disabled {
    opacity: 0.7;
    cursor: not-allowed;
}

.login-form-section .form-footer {
    text-align: center;
    margin-top: 2rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--border-color);
    display: block;
}

.login-form-section .form-footer p {
    font-size: 0.9rem;
    color: var(--text-muted);
}

.login-form-section .form-footer a {
    color: var(--primary);
    text-decoration: none;
    font-weight: 500;
    transition: color 0.2s;
}

.login-form-section .form-footer a:hover {
    color: var(--primary-hover);
    text-decoration: none;
}

/* ============================================
   Counterparties — Type Toggle
   ============================================ */

.type-toggle {
    cursor: pointer;
}

.type-toggle input[type="checkbox"] {
    display: none;
}

.type-toggle-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    width: 100%;
    padding: 0.625rem 1rem;
    border-radius: 0.5rem;
    font-weight: 500;
    font-size: 0.95rem;
    border: 2px solid transparent;
    transition: all 0.2s ease;
    opacity: 0.45;
    transform: scale(0.97);
}

.type-toggle-btn.btn-success {
    background-color: #dcfce7;
    color: #16a34a;
    border-color: #bbf7d0;
}

.type-toggle-btn.btn-primary {
    background-color: #e0e7ff;
    color: #4f46e5;
    border-color: #c7d2fe;
}

.type-toggle input:checked + .type-toggle-btn {
    opacity: 1;
    transform: scale(1);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.type-toggle input:checked + .type-toggle-btn.btn-success {
    background-color: var(--success);
    color: #fff;
    border-color: var(--success);
}

.type-toggle input:checked + .type-toggle-btn.btn-primary {
    background-color: var(--primary);
    color: #fff;
    border-color: var(--primary);
}

.type-toggle-btn:hover {
    opacity: 0.85;
    transform: scale(0.98);
}

.type-toggle input:checked + .type-toggle-btn:hover {
    opacity: 0.9;
    transform: scale(1);
}

/* Checko.ru Lookup Section */
.checko-lookup-section {
    background: linear-gradient(135deg, #f0fdf4 0%, #dcfce7 100%);
    border: 1px solid #22c55e;
    border-radius: 0.75rem;
    padding: 1rem;
    margin-bottom: 1.25rem;
}

.checko-lookup-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
    color: #16a34a;
    font-weight: 600;
}

.checko-lookup-header i {
    font-size: 1.25rem;
}

.checko-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    font-size: 0.75rem;
    font-weight: 500;
    color: #16a34a;
    background: none;
    padding: 0;
    margin-left: 0.25rem;
}

.checko-lookup-input .input-group {
    border-radius: 0.5rem;
    overflow: hidden;
}

.checko-lookup-spinner {
    display: none;
    align-items: center;
    gap: 0.75rem;
    padding: 1rem;
    color: #16a34a;
}

.checko-lookup-spinner:not(.d-none) {
    display: flex;
}

.checko-lookup-spinner .spinner-border {
    width: 1.5rem;
    height: 1.5rem;
}

/* Counterparties — Table Type Badges */
.counterparty-type {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    padding: 0.35rem 0.75rem;
    border-radius: var(--border-radius-sm);
    font-size: 0.8125rem;
    font-weight: 500;
    white-space: nowrap;
}

.counterparty-type.type-customer {
    background-color: #dcfce7;
    color: #16a34a;
    border: 1px solid #bbf7d0;
}

.counterparty-type.type-supplier {
    background-color: #e0e7ff;
    color: #4f46e5;
    border: 1px solid #c7d2fe;
}

.counterparty-type i {
    font-size: 0.75rem;
}

/* Counterparties — Action Buttons */
.action-btns {
    display: inline-flex;
    gap: 0.375rem;
    align-items: center;
}

.action-btns .btn {
    width: 32px;
    height: 32px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--border-radius-sm);
    font-size: 0.8125rem;
    transition: all 0.2s;
}

.action-btns .btn-edit {
    background-color: #eff6ff;
    color: #3b82f6;
    border: 1px solid #bfdbfe;
}

.action-btns .btn-edit:hover {
    background-color: #3b82f6;
    color: white;
}

.action-btns .btn-delete {
    background-color: #fef2f2;
    color: #ef4444;
    border: 1px solid #fecaca;
}

.action-btns .btn-delete:hover {
    background-color: #ef4444;
    color: white;
}

.action-btns .btn i {
    margin: 0;
}

/* Counterparties — Filter Section */
.filter-card {
    background: var(--white);
    border-radius: 0.75rem;
    border: 1px solid var(--border-color);
    padding: 1rem 1.25rem;
    margin-bottom: 1.5rem;
}

.filter-form {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.filter-form .input-group {
    flex: 1;
}

.filter-form .filter-actions {
    display: flex;
    gap: 0.5rem;
    flex-shrink: 0;
}

/* Counterparties — Modal Form */
.counterparty-form .form-section {
    margin-bottom: 1.25rem;
    padding-bottom: 1.25rem;
    border-bottom: 1px solid var(--border-color);
}

.counterparty-form .form-section:last-child {
    border-bottom: none;
    margin-bottom: 0;
    padding-bottom: 0;
}

.counterparty-form .section-title {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-color);
    margin-bottom: 0.75rem;
}

.counterparty-form .section-title i {
    color: var(--primary);
}

/* Grid inside modal */
.counterparty-form .row {
    display: grid;
    grid-template-columns: repeat(12, 1fr);
    gap: 1rem;
}

.counterparty-form .col-12 {
    grid-column: span 12;
}

.counterparty-form .col-md-4 {
    grid-column: span 4;
}

/* Entity Type Toggle */
.entity-type-toggle {
    display: flex;
    gap: 0.75rem;
}

.entity-type-toggle input[type="radio"] {
    display: none;
}

.entity-type-btn {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.75rem 1rem;
    border: 2px solid var(--border-color);
    border-radius: var(--border-radius);
    background: var(--white);
    color: var(--gray-500);
    font-weight: 500;
    font-size: 0.9375rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.entity-type-btn:hover {
    border-color: var(--gray-300);
    color: var(--text-color);
    background: var(--gray-50);
}

.entity-type-toggle input[type="radio"]:checked + .entity-type-btn,
.entity-type-btn.active {
    border-color: var(--primary);
    background: var(--primary-light);
    color: var(--primary);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

.entity-type-btn i {
    font-size: 1rem;
}

/* Counterparties — Table Improvements */
.counterparties-table td {
    vertical-align: middle;
}

.counterparties-table td:last-child {
    text-align: center;
}

.counterparties-table td:last-child .action-btns {
    justify-content: center;
}

.counterparties-table .cp-name {
    font-weight: 600;
    color: var(--text-color);
    margin-bottom: 0.25rem;
}

.counterparties-table .cp-address {
    font-size: 0.8125rem;
    color: var(--text-muted);
    line-height: 1.4;
}

.counterparties-table .cp-inn {
    font-weight: 600;
    color: var(--text-color);
    margin-bottom: 0.15rem;
}

.counterparties-table .cp-kpp {
    font-size: 0.8125rem;
    color: var(--text-muted);
    line-height: 1.4;
}

.counterparties-table .cp-contact {
    font-size: 0.875rem;
}

.counterparties-table .cp-phone {
    font-family: 'SF Mono', 'Monaco', 'Menlo', monospace;
    font-size: 0.875rem;
    color: var(--gray-600);
}

.counterparties-table .cp-email {
    font-size: 0.875rem;
    color: var(--primary);
}

/* Ingredients — Table Improvements */
.ingredients-table td:last-child {
    text-align: center;
}

.ingredients-table td:last-child .action-btns {
    justify-content: center;
}

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

.btn-group .btn-check:checked + .btn-outline-success {
    background-color: var(--success);
    color: white;
}

.btn-group .btn-check:checked + .btn-outline-primary {
    background-color: var(--primary);
    color: white;
}

/* ============================================
   Ingredients — Bulk Actions
   ============================================ */

.ing-name {
    font-weight: 600;
    color: var(--text-color);
    margin-bottom: 0.25rem;
}

.ing-name-en {
    font-size: 0.8125rem;
    color: var(--text-muted);
    line-height: 1.4;
}

.stock-value {
    font-size: 0.9rem;
}

.table tbody tr td {
    font-size: 0.9rem;
    font-weight: 400;
    vertical-align: middle;
}

.table tbody tr td:first-child {
    font-weight: 500;
}

.table tbody .text-end {
    font-variant-numeric: tabular-nums;
}

.bulk-actions {
    position: fixed;
    bottom: 0;
    left: var(--sidebar-width);
    right: 0;
    background: var(--card-bg);
    border-top: 1px solid var(--border-color);
    padding: 0.75rem 1.5rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    z-index: 99;
    box-shadow: 0 -4px 12px rgba(0, 0, 0, 0.1);
}

.sidebar.collapsed ~ .main-content .bulk-actions {
    left: var(--sidebar-collapsed-width);
}

.selected-count {
    color: var(--text-muted);
    font-size: 0.9rem;
}

.quick-buttons {
    display: flex;
    gap: 0.25rem;
    flex-wrap: wrap;
    margin-top: 0.5rem;
}

.quick-buttons .btn {
    flex: 1;
    min-width: 50px;
}

/* Button Icons Fix */
.btn i {
    margin: 0.375rem;
}

.btn-sm i {
    margin-right: 0.25rem;
}

.top-bar-right .btn {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
}

.top-bar-right .btn i {
    margin-right: 0;
}

/* AI Lookup Section */
.ai-lookup-section {
    background: linear-gradient(135deg, #f0f9ff 0%, #e0f2fe 100%);
    border: 1px solid #0ea5e9;
    border-radius: 0.5rem;
    padding: 0.75rem;
    margin-bottom: 0.75rem;
}

.ai-lookup-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
    color: #0369a1;
    font-weight: 600;
    font-size: 0.875rem;
}

.ai-lookup-header i {
    font-size: 1.25rem;
}

.ai-lookup-input .input-group {
    border-radius: 0.5rem;
    overflow: hidden;
}

.ai-lookup-spinner:not(.d-none) {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 1rem;
    color: #0369a1;
}

.ai-lookup-spinner .spinner-border {
    width: 1.5rem;
    height: 1.5rem;
}

.ai-result-card {
    background: white;
    border-radius: 0.5rem;
    padding: 0.75rem;
    margin-top: 0.75rem;
    border: 1px solid #d1d5db;
}

.ai-result-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
}

.ai-result-header i {
    font-size: 1.25rem;
}

.ai-result-details {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.ai-data-section {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 0.5rem;
    padding: 1rem;
}

.ai-data-section h6 {
    color: #0369a1;
}

/* ============================================
   Animations
   ============================================ */
.fade {
    animation: fadeIn 0.2s ease;
}
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.form-container {
    animation: fadeIn 0.5s ease-out;
}

.branding-content {
    animation: fadeIn 0.5s ease-out 0.2s backwards;
}

/* ============================================
   Accessibility
   ============================================ */
.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.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;
}

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

/* ============================================
   Responsive
   ============================================ */

@media (max-width: 991.98px) {
    .sidebar {
        width: var(--sidebar-collapsed-width);
    }

    .sidebar .nav-link span,
    .sidebar .user-details,
    .sidebar .brand span {
        display: none;
    }

    .main-content {
        margin-left: var(--sidebar-collapsed-width);
    }

    .bulk-actions {
        left: var(--sidebar-collapsed-width);
    }

    .login-container {
        flex-direction: column;
    }

    .login-branding {
        padding: 2rem;
        min-height: auto;
    }

    .brand-logo {
        width: 80px;
        height: 80px;
        font-size: 2rem;
        margin-bottom: 1.5rem;
    }

    .brand-title {
        font-size: 2rem;
    }

    .brand-features {
        flex-direction: row;
        justify-content: center;
        flex-wrap: wrap;
    }

    .feature-item {
        flex: 0 0 auto;
        padding: 0.75rem 1rem;
    }

    .login-form-section {
        padding: 2rem;
    }
}

@media (max-width: 575.98px) {
    .sidebar {
        transform: translateX(-100%);
    }

    .sidebar.show {
        transform: translateX(0);
    }

    .main-content {
        margin-left: 0;
    }

    .top-bar {
        padding: 0 1rem;
    }

    .search-box input {
        width: 150px;
    }

    .page-content {
        padding: 1rem;
    }

    .bulk-actions {
        left: 0;
        flex-wrap: wrap;
    }

    .quick-buttons {
        width: 100%;
    }

    .login-branding {
        padding: 1.5rem;
    }

    .brand-title {
        font-size: 1.75rem;
    }

    .brand-subtitle {
        font-size: 1rem;
        margin-bottom: 2rem;
    }

    .feature-item span {
        display: none;
    }

    .feature-item {
        padding: 0.75rem;
    }

    .feature-item i {
        font-size: 1.5rem;
    }

    .login-form-section {
        padding: 1.5rem;
    }

    .login-form-section .form-header h2 {
        font-size: 1.5rem;
    }
}

/* ============================================
   Dark Mode (login page)
   ============================================ */

@media (prefers-color-scheme: dark) {
    .login-branding ~ .login-form-section {
        --text-color: #f1f5f9;
        --text-muted: #94a3b8;
        --border-color: #334155;
        --bg-color: #0f172a;
        --card-bg: #1e293b;
        background: #0f172a;
    }

    .login-form-section .input-group {
        background-color: #334155;
    }

    .login-form-section .input-group-text {
        background-color: #475569;
        color: #94a3b8;
    }

    .login-form-section .form-control {
        color: #f1f5f9;
        background-color: #1e293b;
        border-color: #334155;
    }

    .login-form-section .alert-danger {
        background-color: #450a0a;
        color: #fca5a5;
    }

    .login-form-section .alert-success {
        background-color: #052e16;
        color: #86efac;
    }

    .login-form-section .form-footer {
        border-top-color: #334155;
    }

    .login-form-section .form-footer a {
        color: #818cf8;
    }

    .login-form-section .form-check-label {
        color: #94a3b8;
    }
}

/* ============================================
   Settings Page
   ============================================ */

.settings-stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1rem;
    margin-bottom: 2rem;
}

.stat-card {
    display: flex;
    align-items: center;
    gap: 1rem;
    background: var(--card-bg);
    border-radius: var(--radius-lg);
    padding: 1.25rem;
    box-shadow: var(--shadow-sm);
}

.stat-icon {
    width: 48px;
    height: 48px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    flex-shrink: 0;
}

.bg-primary-subtle { background: rgba(79, 70, 229, 0.1); }
.bg-danger-subtle { background: rgba(239, 68, 68, 0.1); }
.bg-success-subtle { background: rgba(34, 197, 94, 0.1); }

.stat-info {
    display: flex;
    flex-direction: column;
}

.stat-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-color);
    line-height: 1.2;
}

.stat-label {
    font-size: 0.8125rem;
    color: var(--text-muted);
}

.settings-section {
    margin-bottom: 2rem;
}

.settings-section-title {
    font-size: 0.8125rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    margin-bottom: 0.75rem;
    padding-left: 0.25rem;
}

.settings-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.75rem;
}

.settings-link {
    display: flex;
    align-items: center;
    gap: 1rem;
    background: var(--card-bg);
    border-radius: var(--radius-lg);
    padding: 1rem 1.25rem;
    box-shadow: var(--shadow-sm);
    text-decoration: none !important;
    transition: box-shadow 0.2s, transform 0.2s;
}

.settings-link:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-1px);
}

.settings-link-icon {
    width: 44px;
    height: 44px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.125rem;
    flex-shrink: 0;
}

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

.settings-link-body h3 {
    font-size: 0.9375rem;
    font-weight: 600;
    color: var(--text-color);
    margin-bottom: 0.125rem;
}

.settings-link-body p {
    font-size: 0.8125rem;
    color: var(--text-muted);
    margin: 0;
}

.settings-link-arrow {
    color: var(--gray-400);
    font-size: 0.75rem;
    flex-shrink: 0;
}

@media (max-width: 767.98px) {
    .settings-stats {
        grid-template-columns: 1fr;
    }
}

/* ============================================
   Profile — Avatars
   ============================================ */

.user-avatar-large {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    background: var(--primary);
    color: white;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 2rem;
}

.user-avatar-img {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    object-fit: cover;
}

.badge-lg {
    font-size: 0.8125rem;
    padding: 0.4em 0.8em;
}

.info-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.375rem 0;
    font-size: 0.875rem;
}

.info-row:not(:last-child) {
    border-bottom: 1px solid var(--gray-100);
}

/* Кнопка-аватар (кликабельная) */
.avatar-edit-btn {
    position: relative;
    background: none;
    border: none;
    padding: 0;
    cursor: pointer;
    border-radius: 50%;
    display: inline-block;
    line-height: 0;
}

.avatar-edit-overlay {
    position: absolute;
    inset: 0;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.45);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.2s;
    color: white;
    font-size: 1.25rem;
}

.avatar-edit-btn:hover .avatar-edit-overlay {
    opacity: 1;
}

/* Сетка аватаров в модалке */
.avatar-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(52px, 1fr));
    gap: 0.5rem;
    max-height: 60vh;
    overflow-y: auto;
    padding: 0.25rem;
}

.avatar-option {
    width: 52px;
    height: 52px;
    border-radius: 50%;
    border: 2px solid var(--gray-200);
    background: var(--white);
    padding: 0;
    cursor: pointer;
    transition: border-color 0.2s, transform 0.15s;
    overflow: hidden;
}

.avatar-option img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 50%;
}

.avatar-option:hover {
    border-color: var(--primary);
    transform: scale(1.1);
}

.avatar-option.selected {
    border-color: var(--primary);
    box-shadow: 0 0 0 2px var(--primary-light);
}

/* ============================================
   Warehouse — Склад
   ============================================ */

/* Табы складов */
.warehouse-tabs {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1rem;
    flex-wrap: wrap;
}

.warehouse-tab {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.625rem 1rem;
    border: 1px solid var(--gray-200);
    border-radius: 8px;
    background: var(--white);
    color: var(--gray-600);
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.warehouse-tab:hover {
    border-color: var(--primary);
    color: var(--primary);
    background: var(--primary-light);
}

.warehouse-tab.active {
    border-color: var(--primary);
    background: var(--primary);
    color: var(--white);
}

.warehouse-tab i {
    font-size: 0.9rem;
}

.tab-count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 20px;
    height: 20px;
    padding: 0 6px;
    border-radius: 10px;
    background: var(--gray-200);
    color: var(--gray-600);
    font-size: 0.75rem;
    font-weight: 600;
}

.warehouse-tab.active .tab-count {
    background: rgba(255, 255, 255, 0.25);
    color: var(--white);
}

/* Цвета остатков */
.stock-ok {
    color: var(--success);
    font-weight: 600;
}

.stock-warning {
    color: var(--warning);
    font-weight: 600;
}

.stock-critical {
    color: var(--danger);
    font-weight: 700;
}

/* Бейджи типов движений */
.badge-success {
    background: var(--success);
    color: var(--white);
}

.badge-danger {
    background: var(--danger);
    color: var(--white);
}

.badge-info {
    background: var(--info);
    color: var(--white);
}

.badge-warning {
    background: var(--warning);
    color: var(--white);
}

.badge-primary {
    background: var(--primary);
    color: var(--white);
}

.badge-secondary {
    background: var(--secondary);
    color: var(--white);
}

/* Поиск ингредиентов в модалках */
.search-results-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--white);
    border: 1px solid var(--gray-200);
    border-radius: 0 0 8px 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    max-height: 200px;
    overflow-y: auto;
    z-index: 1000;
}

#portalDropdown {
    position: fixed;
    background: var(--white);
    border: 1px solid var(--gray-200);
    border-radius: 0 0 8px 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    max-height: 200px;
    overflow-y: auto;
    z-index: 10050;
}

.search-result-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.5rem 0.75rem;
    cursor: pointer;
    transition: background 0.15s;
}

.search-result-item:hover {
    background: var(--gray-100);
}

.result-name {
    font-weight: 500;
    color: var(--gray-800);
}

.result-stock {
    font-size: 0.8rem;
    color: var(--gray-500);
}

/* Выбранный ингредиент */
.selected-ingredient {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.5rem 0.75rem;
    background: var(--primary-light);
    border: 1px solid var(--primary);
    border-radius: 6px;
    margin-top: 0.5rem;
}

.selected-ingredient .selected-name {
    font-weight: 500;
    color: var(--primary);
    font-size: 0.875rem;
}

/* ============================================
   Warehouse Dashboard — Карточки складов
   ============================================ */

.warehouse-cards {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 1rem;
}

.warehouse-card {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1.25rem;
    background: var(--white);
    border: 1px solid var(--gray-200);
    border-radius: 12px;
    text-decoration: none;
    color: inherit;
    transition: all 0.2s;
}

.warehouse-card:hover {
    border-color: var(--primary);
    box-shadow: 0 4px 12px rgba(79, 70, 229, 0.1);
    transform: translateY(-2px);
}

.warehouse-card-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    flex-shrink: 0;
}

.warehouse-card-icon.raw { background: #dbeafe; color: #2563eb; }
.warehouse-card-icon.workshop { background: #fef3c7; color: #d97706; }
.warehouse-card-icon.production { background: #e0e7ff; color: #4f46e5; }
.warehouse-card-icon.finished { background: #d1fae5; color: #059669; }
.warehouse-card-icon.packaging { background: #cffafe; color: #0891b2; }
.warehouse-card-icon.history { background: var(--gray-100); color: var(--gray-600); }

.warehouse-card-info {
    flex: 1;
    min-width: 0;
}

.warehouse-card-info h3 {
    margin: 0;
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--gray-800);
}

.warehouse-card-count {
    font-size: 0.8rem;
    color: var(--gray-500);
}

.warehouse-card-alert {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    font-size: 0.75rem;
    color: var(--danger);
    font-weight: 500;
}

.warehouse-card-arrow {
    color: var(--gray-400);
    font-size: 0.8rem;
}

/* --- Import Dropzone --- */
.import-dropzone {
    transition: border-color 0.2s, background-color 0.2s;
}

.import-dropzone:hover {
    border-color: var(--color-primary, #0d6efd) !important;
    background-color: var(--color-bg-secondary, #f8f9fa);
}

.import-dropzone.dragover {
    border-color: var(--color-primary, #0d6efd) !important;
    background-color: var(--color-bg-secondary, #f8f9fa);
}
