:root {
    /* Color Palette - Modern & Sophisticated */
    --color-bg: #fafbfc;
    --color-surface: #ffffff;
    --color-surface-muted: #f6f8fa;
    --color-surface-elevated: #ffffff;
    
    --color-text-primary: #0f1419;
    --color-text-secondary: #536471;
    --color-text-tertiary: #8b98a5;
    --color-text-inverse: #ffffff;
    
    --color-primary: #5b5fc7; /* Modern indigo */
    --color-primary-hover: #4a4db8;
    --color-primary-light: #e6e7ff;
    --color-primary-subtle: #f4f4ff;
    
    --color-danger: #e5484d;
    --color-danger-hover: #dc3e42;
    --color-danger-light: #ffe5e5;
    
    --color-success: #30a46c;
    --color-success-light: #ddf3e4;
    
    --color-warning: #f5a623;
    --color-warning-light: #ffefd2;
    
    --color-info: #0091ff;
    --color-info-light: #e0f2ff;
    --color-info-subtle: #f0f9ff;
    
    --color-success-hover: #2b9a5f;
    
    --color-border: #e8ecef;
    --color-border-medium: #d0d7de;
    --color-border-strong: #8b98a5;
    
    /* Spacing Scale */
    --spacing-xs: 4px;
    --spacing-sm: 8px;
    --spacing-md: 16px;
    --spacing-lg: 24px;
    --spacing-xl: 32px;
    --spacing-2xl: 48px;
    --spacing-3xl: 64px;
    
    /* Radius Scale */
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 14px;
    --radius-xl: 18px;
    --radius-2xl: 24px;
    --radius-full: 9999px;
    
    /* Shadows */
    --shadow-xs: 0 1px 2px 0 rgb(0 0 0 / 0.03);
    --shadow-sm: 0 1px 3px 0 rgb(0 0 0 / 0.05), 0 1px 2px -1px rgb(0 0 0 / 0.05);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.06), 0 2px 4px -2px rgb(0 0 0 / 0.06);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.08), 0 4px 6px -4px rgb(0 0 0 / 0.08);
    --shadow-xl: 0 20px 25px -5px rgb(0 0 0 / 0.08), 0 8px 10px -6px rgb(0 0 0 / 0.08);
    
    /* Transitions */
    --transition-fast: 150ms cubic-bezier(0.4, 0, 0.2, 1);
    --transition-base: 200ms cubic-bezier(0.4, 0, 0.2, 1);
    --transition-slow: 300ms cubic-bezier(0.4, 0, 0.2, 1);
    
    /* Typography */
    --font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    --font-size-xs: 0.75rem;
    --font-size-sm: 0.875rem;
    --font-size-base: 0.9375rem;
    --font-size-lg: 1.125rem;
    --font-size-xl: 1.25rem;
    --font-size-2xl: 1.5rem;
    
    --line-height-tight: 1.25;
    --line-height-normal: 1.5;
    --line-height-relaxed: 1.75;
}

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

body {
    font-family: var(--font-family);
    font-size: var(--font-size-base);
    line-height: var(--line-height-normal);
    background-color: var(--color-bg);
    color: var(--color-text-primary);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

h1, h2, h3, h4, h5, h6 {
    font-weight: 600;
    line-height: var(--line-height-tight);
    color: var(--color-text-primary);
    margin: 0;
}

h1 { font-size: var(--font-size-2xl); }
h2 { font-size: var(--font-size-xl); }
h3 { font-size: var(--font-size-lg); }

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

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

/* SVG Icons */
svg {
    display: inline-block;
    vertical-align: middle;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
    fill: none;
    stroke: currentColor;
}

/* Icon Buttons */
.icon-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    padding: 0;
    border: 1px solid var(--color-border);
    background: var(--color-surface);
    color: var(--color-text-secondary);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all var(--transition-base);
    position: relative;
}

.icon-button:hover {
    background-color: var(--color-surface-muted);
    color: var(--color-text-primary);
    border-color: var(--color-border-medium);
}

.icon-button:active {
    transform: scale(0.96);
}

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

/* Header */
.main-header {
    border-bottom: 1px solid var(--color-border);
    padding: var(--spacing-md) 0;
    position: sticky;
    top: 0;
    z-index: 100;
    backdrop-filter: blur(12px);
    background: rgba(255, 255, 255, 0.95);
}

.header-content {
    max-width: 1280px;
    margin: 0 auto;
    padding: 0 var(--spacing-lg);
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: var(--spacing-lg);
}

.header-brand {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
}

.header-logo {
    color: var(--color-primary);
    flex-shrink: 0;
}

.header-content h1 {
    font-size: var(--font-size-lg);
    font-weight: 600;
    color: var(--color-text-primary);
    white-space: nowrap;
}

/* Adaptive header title */
.header-title-short {
    display: none;
}

@media (max-width: 1280px) {
    .header-title-full {
        display: none;
    }
    
    .header-title-short {
        display: inline;
    }
}

.header-actions {
    display: flex;
    align-items: center;
    gap: var(--spacing-md);
}

/* Navigation */
.main-nav {
    border-bottom: 1px solid var(--color-border);
    margin-bottom: var(--spacing-xl);
    position: sticky;
    top: 73px;
    z-index: 80;
    backdrop-filter: blur(12px);
    background: rgba(255, 255, 255, 0.95);
}

.nav-content {
    max-width: 1280px;
    margin: 0 auto;
    padding: var(--spacing-sm) var(--spacing-lg);
    display: flex;
    gap: var(--spacing-xs);
    overflow-x: auto;
    scrollbar-width: none;
}

.nav-content::-webkit-scrollbar {
    display: none;
}

.nav-item {
    display: inline-flex;
    align-items: center;
    gap: var(--spacing-sm);
    padding: var(--spacing-md) var(--spacing-md);
    color: var(--color-text-secondary);
    font-weight: 500;
    font-size: var(--font-size-sm);
    border-bottom: 2px solid transparent;
    transition: all var(--transition-base);
    white-space: nowrap;
    position: relative;
}

.nav-item svg {
    width: 18px;
    height: 18px;
    transition: transform var(--transition-base);
}

.nav-item:hover {
    color: var(--color-primary);
    background: transparent;
}

.nav-item:hover svg {
    transform: translateY(-1px);
}

.nav-item.active {
    color: var(--color-primary);
    border-bottom-color: var(--color-primary);
    background: transparent;
}

/* Nav Item Group для элементов с подменю */
.nav-item-group {
    display: inline-flex;
    align-items: center;
    gap: var(--spacing-xs);
    position: relative;
}

.nav-item-group .nav-item {
    border-bottom: 2px solid transparent;
}

/* Подпункт меню */
.nav-item-sub {
    font-size: var(--font-size-xs);
    padding: var(--spacing-sm) var(--spacing-md);
    color: var(--color-text-tertiary);
    opacity: 0.8;
}

.nav-item-sub svg {
    width: 14px;
    height: 14px;
}

.nav-item-sub:hover {
    opacity: 1;
    color: var(--color-primary);
}

.nav-item-sub.active {
    opacity: 1;
    color: var(--color-primary);
    border-bottom-color: var(--color-primary);
}

/* Navigation Dropdown */
/* Main Content */
.main-content {
    max-width: 1280px;
    margin: 0 auto;
    padding: 0 var(--spacing-lg) var(--spacing-3xl);
    min-height: calc(100vh - 200px);
}

.content, .content-wrapper {
    max-width: 100%;
}

/* Page Header */
.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--spacing-md);
    margin-bottom: var(--spacing-xl);
    flex-wrap: wrap;
}

.page-title {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
}

.page-title h2 {
    font-size: var(--font-size-xl);
    font-weight: 600;
}

.page-actions {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    flex-wrap: wrap;
    flex-shrink: 0;
}

/* Buttons */
button, .btn, .main-btn, .action-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--spacing-sm);
    padding: 0.625rem 1.125rem;
    font-family: inherit;
    font-weight: 500;
    font-size: var(--font-size-sm);
    line-height: 1;
    border-radius: var(--radius-md);
    border: 1px solid transparent;
    cursor: pointer;
    transition: all var(--transition-base);
    text-decoration: none;
    white-space: nowrap;
}

button svg, .btn svg, .main-btn svg, .action-btn svg {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
}

/* Primary Button */
.main-btn, .btn-primary, button[type="submit"] {
    background: linear-gradient(135deg, #5b5fc7 0%, #5158ba 100%);
    color: #ffffff !important;
    border: 1px solid rgba(91, 95, 199, 0.2);
    box-shadow: 0 1px 3px 0 rgba(91, 95, 199, 0.15), 
                0 1px 2px 0 rgba(0, 0, 0, 0.05);
    transition: all var(--transition-base);
}

.main-btn:hover, .btn-primary:hover, button[type="submit"]:hover {
    background: linear-gradient(135deg, #4a4db8 0%, #4249a8 100%);
    color: #ffffff !important;
    box-shadow: 0 4px 8px 0 rgba(91, 95, 199, 0.25),
                0 2px 4px 0 rgba(0, 0, 0, 0.05);
    transform: translateY(-1px);
}

.main-btn:active, .btn-primary:active, button[type="submit"]:active {
    transform: translateY(0);
    background: linear-gradient(135deg, #4249a8 0%, #3a419a 100%);
    color: #ffffff !important;
    box-shadow: 0 1px 2px 0 rgba(91, 95, 199, 0.2);
}

.main-btn:focus-visible, .btn-primary:focus-visible, button[type="submit"]:focus-visible {
    outline: 2px solid var(--color-primary);
    outline-offset: 2px;
}

/* Secondary/Default Button */
.btn, .action-btn {
    background-color: var(--color-surface);
    color: var(--color-text-primary);
    border: 1px solid var(--color-border);
    box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.03);
}

.btn:not(.btn-primary):not(.btn-danger):not(.btn-success):not(.btn-warning):not(.btn-info):hover,
.action-btn:hover {
    background: var(--color-surface-muted);
    border-color: var(--color-border-medium);
    box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.05);
    transform: translateY(-1px);
}

.btn:active, .action-btn:active {
    transform: translateY(0);
    box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.03);
}

.btn:focus-visible, .action-btn:focus-visible {
    outline: 2px solid var(--color-primary);
    outline-offset: 2px;
}

/* Danger Button */
.btn-danger {
    background-color: var(--color-surface);
    color: var(--color-danger);
    border: 1px solid var(--color-danger-light);
    box-shadow: 0 1px 2px 0 rgba(229, 72, 77, 0.05);
}

.btn-danger:hover {
    background-color: var(--color-danger);
    color: var(--color-text-inverse);
    border-color: var(--color-danger-hover);
    box-shadow: 0 2px 4px 0 rgba(229, 72, 77, 0.15);
    transform: translateY(-1px);
}

.btn-danger:active {
    transform: translateY(0);
    box-shadow: 0 1px 2px 0 rgba(229, 72, 77, 0.1);
}

/* Info/Warning/Success Buttons */
.btn-info {
    color: var(--color-info);
    background: var(--color-info-light);
    border-color: transparent;
}

.btn-info:hover {
    background: var(--color-info);
    color: var(--color-text-inverse);
}

.btn-warning {
    color: var(--color-warning);
    background: var(--color-warning-light);
    border-color: transparent;
}

.btn-warning:hover {
    background: var(--color-warning);
    color: var(--color-text-inverse);
}

.btn-success {
    color: var(--color-success);
    background: var(--color-success-light);
    border-color: transparent;
}

.btn-success:hover {
    background: var(--color-success);
    color: var(--color-text-inverse);
}

.btn-secondary {
    background: var(--color-surface);
    color: var(--color-text-primary);
    border: 1px solid var(--color-border);
    box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.03);
}

.btn-secondary:hover {
    background: var(--color-surface-muted);
    border-color: var(--color-border-medium);
    box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.05);
}

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

/* Button Variants */
.btn-icon {
    width: 36px;
    height: 36px;
    padding: 0;
}

.btn-sm {
    padding: 0.5rem 0.875rem;
    font-size: var(--font-size-xs);
}

.btn-block {
    width: 100%;
}

.btn-text {
    background: transparent;
    border: none;
    color: var(--color-primary);
    padding: 0.5rem 0.75rem;
    box-shadow: none;
}

.btn-text:hover {
    background: var(--color-primary-subtle);
    box-shadow: none;
}

/* Modern Action Buttons */
.btn-action {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--spacing-xs);
    padding: 0.625rem 1rem;
    font-family: inherit;
    font-weight: 500;
    font-size: var(--font-size-sm);
    line-height: 1.2;
    border-radius: var(--radius-md);
    border: 1px solid transparent;
    cursor: pointer;
    transition: all var(--transition-base);
    text-decoration: none;
    white-space: nowrap;
    box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
}

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

.btn-action span {
    display: inline-block;
}

.btn-action-primary {
    background: linear-gradient(135deg, #5b5fc7 0%, #5158ba 100%);
    color: #ffffff;
    border: 1px solid rgba(91, 95, 199, 0.2);
    box-shadow: 0 1px 3px 0 rgba(91, 95, 199, 0.2), 
                0 1px 2px 0 rgba(0, 0, 0, 0.05);
}

.btn-action-primary:hover {
    background: linear-gradient(135deg, #4a4db8 0%, #4249a8 100%);
    color: #ffffff;
    box-shadow: 0 4px 8px 0 rgba(91, 95, 199, 0.3),
                0 2px 4px 0 rgba(0, 0, 0, 0.05);
    transform: translateY(-1px);
}

.btn-action-primary:active {
    transform: translateY(0);
    box-shadow: 0 1px 2px 0 rgba(91, 95, 199, 0.2);
}

.btn-action-secondary {
    background: var(--color-surface);
    color: var(--color-text-primary);
    border: 1px solid var(--color-border);
    box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.03);
}

.btn-action-secondary:hover {
    background: var(--color-surface-muted);
    border-color: var(--color-border-medium);
    box-shadow: 0 2px 4px 0 rgba(0, 0, 0, 0.06);
    transform: translateY(-1px);
}

.btn-action-secondary:active {
    transform: translateY(0);
    box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.03);
}

.btn-action-success {
    background: var(--color-success);
    color: white;
    border: 1px solid var(--color-success);
    box-shadow: 0 1px 3px 0 rgba(48, 164, 108, 0.2);
}

.btn-action-success:hover {
    background: var(--color-success-hover);
    border-color: var(--color-success-hover);
    box-shadow: 0 4px 8px 0 rgba(48, 164, 108, 0.3);
    transform: translateY(-1px);
}

.btn-action-success:active {
    transform: translateY(0);
    box-shadow: 0 1px 2px 0 rgba(48, 164, 108, 0.2);
}

.btn-action-danger {
    background: var(--color-danger);
    color: white;
    border: 1px solid var(--color-danger);
    box-shadow: 0 1px 3px 0 rgba(229, 72, 77, 0.2);
}

.btn-action-danger:hover {
    background: var(--color-danger-hover);
    border-color: var(--color-danger-hover);
    box-shadow: 0 4px 8px 0 rgba(229, 72, 77, 0.3);
    transform: translateY(-1px);
}

.btn-action-danger:active {
    transform: translateY(0);
    box-shadow: 0 1px 2px 0 rgba(229, 72, 77, 0.2);
}

.btn-action-warning {
    background: var(--color-warning);
    color: white;
    border: 1px solid var(--color-warning);
    box-shadow: 0 1px 3px 0 rgba(245, 166, 35, 0.2);
}

.btn-action-warning:hover {
    background: #e09520;
    border-color: #e09520;
    box-shadow: 0 4px 8px 0 rgba(245, 166, 35, 0.3);
    transform: translateY(-1px);
}

.btn-action-warning:active {
    transform: translateY(0);
    box-shadow: 0 1px 2px 0 rgba(245, 166, 35, 0.2);
}

/* Compact icon-only variant of btn-action for table rows */
.btn-action-icon {
    width: 32px;
    height: 32px;
    padding: 0;
    flex-shrink: 0;
}

.btn-action-icon.btn-action-primary,
.btn-action-icon.btn-action-secondary,
.btn-action-icon.btn-action-success,
.btn-action-icon.btn-action-danger,
.btn-action-icon.btn-action-warning {
    background: transparent;
    border-color: var(--color-border);
    color: var(--color-text-primary);
    box-shadow: none;
}

.btn-action-icon.btn-action-primary {
    background: var(--color-primary-subtle);
    border-color: var(--color-primary-light);
}

.btn-action-icon.btn-action-success {
    background: var(--color-success-light);
    border-color: rgba(48, 164, 108, 0.35);
}

.btn-action-icon.btn-action-danger {
    background: var(--color-danger-light);
    border-color: rgba(229, 72, 77, 0.35);
}

.btn-action-icon.btn-action-warning {
    background: var(--color-warning-light);
    border-color: rgba(245, 166, 35, 0.35);
}

.btn-action-icon.btn-action-primary:hover {
    background: var(--color-primary-subtle);
    border-color: var(--color-primary);
    color: var(--color-text-primary);
    box-shadow: none;
}

.btn-action-icon.btn-action-secondary:hover {
    background: var(--color-surface-muted);
    border-color: var(--color-border-medium);
    color: var(--color-text-primary);
    box-shadow: none;
}

.btn-action-icon.btn-action-success:hover {
    background: var(--color-success-light);
    border-color: var(--color-success);
    color: var(--color-text-primary);
    box-shadow: none;
}

.btn-action-icon.btn-action-danger:hover {
    background: var(--color-danger-light);
    border-color: var(--color-danger);
    color: var(--color-text-primary);
    box-shadow: none;
}

.btn-action-icon.btn-action-warning:hover {
    background: var(--color-warning-light);
    border-color: var(--color-warning);
    color: var(--color-text-primary);
    box-shadow: none;
}

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

/* Forms */
form {
    max-width: 100%;
}

.form-group {
    margin-bottom: var(--spacing-lg);
}

label {
    display: block;
    margin-bottom: var(--spacing-sm);
    font-weight: 500;
    color: var(--color-text-secondary);
    font-size: var(--font-size-sm);
}

input[type="text"],
input[type="password"],
input[type="email"],
input[type="number"],
input[type="date"],
select,
textarea {
    width: 100%;
    padding: 0.625rem 0.875rem;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    background-color: var(--color-surface);
    color: var(--color-text-primary);
    font-family: inherit;
    font-size: var(--font-size-sm);
    line-height: var(--line-height-normal);
    transition: all var(--transition-base);
    outline: none;
}

input::placeholder,
textarea::placeholder {
    color: var(--color-text-tertiary);
}

input:hover,
select:hover,
textarea:hover {
    border-color: var(--color-border-medium);
}

input:focus,
select:focus,
textarea:focus {
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px var(--color-primary-subtle);
}

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

textarea {
    resize: vertical;
    min-height: 80px;
}

select {
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg width='12' height='12' viewBox='0 0 12 12' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M3 5L6 8L9 5' stroke='%23536471' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.75rem center;
    padding-right: 2.5rem;
    min-height: 42px;
}

/* Form Select — единый стиль выпадающих списков */
.form-select {
    width: 100%;
    padding: 0.75rem 2.75rem 0.75rem 1rem;
    font-size: var(--font-size-sm);
    font-family: var(--font-family);
    color: var(--color-text-primary);
    background-color: var(--color-surface);
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%235B5FC7' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 1rem center;
    background-size: 16px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    transition: border-color var(--transition-base), box-shadow var(--transition-base);
    outline: none;
    appearance: none;
    cursor: pointer;
    line-height: 1.45;
    min-height: 46px;
    box-sizing: border-box;
}

.form-select:hover {
    border-color: var(--color-border-medium);
}

.form-select:focus {
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px var(--color-primary-subtle);
}

.form-select:disabled {
    background-color: var(--color-surface-muted);
    color: var(--color-text-tertiary);
    cursor: not-allowed;
    border-color: var(--color-border);
    opacity: 0.6;
}

.form-select.form-select-sm {
    padding: 0.6875rem 2.5rem 0.6875rem 0.875rem;
    font-size: var(--font-size-sm);
    line-height: 1.45;
    background-size: 14px;
    background-position: right 0.875rem center;
}

/* Modern Form Enhancements */
.form-modern {
    max-width: 100%;
}

.form-container {
    max-width: 800px;
    margin: 0 auto;
}

.form-section {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-xl);
    padding: var(--spacing-xl);
    margin-bottom: var(--spacing-lg);
    box-shadow: var(--shadow-sm);
    transition: box-shadow var(--transition-base);
}

.form-section:hover {
    box-shadow: var(--shadow-md);
}

.form-section-header {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    margin-bottom: var(--spacing-lg);
    padding-bottom: var(--spacing-md);
    border-bottom: 1px solid var(--color-border);
}

.form-section-header svg {
    color: var(--color-primary);
    flex-shrink: 0;
}

.form-section-title {
    font-size: var(--font-size-lg);
    font-weight: 600;
    color: var(--color-text-primary);
    margin: 0;
}

.form-label {
    display: block;
    margin-bottom: var(--spacing-sm);
    font-weight: 500;
    color: var(--color-text-secondary);
    font-size: var(--font-size-sm);
}

.form-required {
    color: var(--color-danger);
    margin-left: 2px;
}

.form-hint {
    display: block;
    margin-top: var(--spacing-xs);
    font-size: var(--font-size-xs);
    color: var(--color-text-tertiary);
    font-style: italic;
}

.form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: var(--spacing-md);
}

.form-input-mono {
    font-family: 'SF Mono', 'Monaco', 'Menlo', 'Courier New', monospace;
    font-size: 0.9em;
    letter-spacing: 0.02em;
    font-weight: 500;
}

.checkbox-wrapper {
    display: flex;
    align-items: flex-start;
    gap: var(--spacing-sm);
    cursor: pointer;
    padding: var(--spacing-md);
    border-radius: var(--radius-md);
    transition: background-color var(--transition-base);
}

.checkbox-wrapper:hover {
    background-color: var(--color-surface-muted);
}

.form-checkbox {
    margin-top: 4px;
    width: 18px;
    height: 18px;
    cursor: pointer;
    accent-color: var(--color-primary);
}

.checkbox-label {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-xs);
    flex: 1;
}

.checkbox-text {
    font-weight: 500;
    color: var(--color-text-primary);
    font-size: var(--font-size-sm);
}

/* Cards & Containers */
.card, .section, .welcome-section, .auth-box, .dashboard-card {
    background: var(--color-surface);
    border-radius: var(--radius-xl);
    border: 1px solid var(--color-border);
    box-shadow: var(--shadow-sm);
    padding: var(--spacing-lg);
    margin-bottom: var(--spacing-lg);
    transition: box-shadow var(--transition-base);
}

.card:hover {
    box-shadow: var(--shadow-md);
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--spacing-sm);
    padding-bottom: var(--spacing-md);
    margin-bottom: var(--spacing-md);
    border-bottom: 1px solid var(--color-border);
}

.card-body {
    color: var(--color-text-secondary);
    font-size: var(--font-size-sm);
}

.card-footer {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: var(--spacing-sm);
    margin-top: var(--spacing-md);
    padding-top: var(--spacing-md);
    border-top: 1px solid var(--color-border);
}

.section h3, .welcome-section h2 {
    margin-bottom: var(--spacing-lg);
    font-weight: 600;
}

.section h3 {
    font-size: var(--font-size-lg);
    border-bottom: none;
}

.card-muted {
    background: var(--color-surface-muted);
}

.card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: var(--spacing-lg);
}

/* Filters */
.modern-filters {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-xl);
    padding: var(--spacing-xl);
    margin-bottom: var(--spacing-xl);
    box-shadow: var(--shadow-sm);
}

.filters-form {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: var(--spacing-lg);
    align-items: flex-end;
    padding: 0 var(--spacing-lg) var(--spacing-lg);
}

.filter-group {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-sm);
}

.filter-group label {
    font-size: var(--font-size-xs);
    font-weight: 600;
    color: var(--color-text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0;
}

.filter-group-dates {
    grid-column: span 2;
}

.date-range {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    border: 0;
    margin: 0;
    padding: 0;
    min-width: 0;
}

.date-range input {
    flex: 1;
}

.date-separator {
    color: var(--color-text-tertiary);
    font-weight: 500;
    font-size: var(--font-size-sm);
}

.search-group {
    grid-column: span 2;
}

.search-input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

.search-icon {
    position: absolute;
    left: 14px;
    color: var(--color-text-tertiary);
    pointer-events: none;
    z-index: 1;
}

.form-control-search {
    padding-left: 40px;
}

.form-control-date,
.form-control-month {
    font-family: var(--font-family);
    font-size: var(--font-size-sm);
    color: var(--color-text-primary);
    padding: 0.75rem 1rem;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    background-color: var(--color-surface);
    transition: all var(--transition-base);
    outline: none;
    width: 100%;
    min-height: 42px;
}

.form-control-date:hover,
.form-control-month:hover {
    border-color: var(--color-border-medium);
}

.form-control-date:focus,
.form-control-month:focus {
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px var(--color-primary-subtle);
}

.form-control-date::-webkit-calendar-picker-indicator,
.form-control-month::-webkit-calendar-picker-indicator {
    cursor: pointer;
    opacity: 0.6;
    transition: opacity var(--transition-base);
    filter: invert(45%) sepia(20%) saturate(1040%) hue-rotate(207deg) brightness(94%) contrast(89%);
}

.form-control-date::-webkit-calendar-picker-indicator:hover,
.form-control-month::-webkit-calendar-picker-indicator:hover {
    opacity: 1;
    filter: invert(35%) sepia(69%) saturate(1545%) hue-rotate(221deg) brightness(95%) contrast(91%);
}

/* Modern Select Wrapper */
.select-wrapper {
    position: relative;
    display: block;
    width: 100%;
}

.filter-actions {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    grid-column: span 2;
}

.btn-filter-submit {
    flex: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--spacing-xs);
    background: linear-gradient(135deg, var(--color-primary) 0%, var(--color-primary-hover) 100%);
    color: var(--color-text-inverse);
    border: none;
    padding: 0.75rem 1.5rem;
    border-radius: var(--radius-md);
    font-weight: 600;
    font-size: var(--font-size-sm);
    cursor: pointer;
    transition: all var(--transition-base);
    box-shadow: 0 2px 4px rgba(91, 95, 199, 0.2);
    min-height: 42px;
}

.btn-filter-submit svg {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
}

.btn-filter-submit:hover {
    background: linear-gradient(135deg, var(--color-primary-hover) 0%, #4249a8 100%);
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(91, 95, 199, 0.3);
}

.btn-filter-submit:active {
    transform: translateY(0);
    box-shadow: 0 1px 2px rgba(91, 95, 199, 0.2);
}

.btn-filter-reset {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--spacing-xs);
    padding: 0.75rem 1.25rem;
    background: var(--color-surface);
    color: var(--color-text-secondary);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    font-weight: 500;
    font-size: var(--font-size-sm);
    cursor: pointer;
    transition: all var(--transition-base);
    white-space: nowrap;
    min-height: 42px;
}

.btn-filter-reset svg {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
}

.btn-filter-reset:hover {
    background: var(--color-surface-muted);
    border-color: var(--color-border-medium);
    color: var(--color-text-primary);
    transform: translateY(-1px);
    box-shadow: var(--shadow-sm);
}

.btn-filter-reset:active {
    transform: translateY(0);
}

/* ============================================
   COLLAPSIBLE FILTERS - Компактные скрываемые фильтры
   ============================================ */

.filters-wrapper {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    margin-bottom: var(--spacing-lg);
    overflow: hidden;
    transition: all var(--transition-base);
}

.filters-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--spacing-md) var(--spacing-lg);
    cursor: pointer;
    user-select: none;
    transition: background var(--transition-base);
}

.filters-header:hover {
    background: var(--color-surface-muted);
}

.filters-title-section {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
}

.filters-icon {
    color: var(--color-primary);
    flex-shrink: 0;
}

.filters-title {
    font-size: var(--font-size-sm);
    font-weight: 600;
    color: var(--color-text-primary);
    margin: 0;
}

.filters-count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 20px;
    height: 20px;
    padding: 0 6px;
    background: var(--color-primary);
    color: var(--color-text-inverse);
    font-size: var(--font-size-xs);
    font-weight: 600;
    border-radius: var(--radius-full);
}

.filters-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    background: transparent;
    border: none;
    color: var(--color-text-secondary);
    cursor: pointer;
    transition: all var(--transition-base);
    border-radius: var(--radius-sm);
    padding: 0;
}

.filters-toggle:hover {
    background: var(--color-surface-muted);
    color: var(--color-text-primary);
}

.filters-toggle svg {
    transition: transform var(--transition-base);
}

.filters-wrapper.filters-expanded .filters-toggle svg {
    transform: rotate(180deg);
}

.filters-content {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.filters-wrapper.filters-expanded .filters-content {
    max-height: 600px;
}

.filters-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: var(--spacing-md);
    margin-bottom: var(--spacing-md);
}

.filter-item {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-xs);
}

.filter-item-wide {
    grid-column: span 2;
}

.filter-label {
    font-size: var(--font-size-xs);
    font-weight: 500;
    color: var(--color-text-secondary);
    margin: 0;
}

.filter-select,
.filter-input {
    width: 100%;
    padding: 0.5rem 0.75rem;
    font-size: var(--font-size-sm);
    font-family: var(--font-family);
    color: var(--color-text-primary);
    background-color: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    transition: all var(--transition-base);
    outline: none;
    min-height: 36px;
}

.filter-select {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%235B5FC7' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.75rem center;
    background-size: 14px;
    padding-right: 2.5rem;
    cursor: pointer;
}

.filter-select:hover,
.filter-input:hover {
    border-color: var(--color-border-medium);
}

.filter-select:focus,
.filter-input:focus {
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px var(--color-primary-subtle);
}

.filter-input::-webkit-calendar-picker-indicator {
    cursor: pointer;
    opacity: 0.5;
    transition: opacity var(--transition-base);
}

.filter-input::-webkit-calendar-picker-indicator:hover {
    opacity: 1;
}

.filter-search-wrapper {
    position: relative;
}

.filter-search-icon {
    position: absolute;
    left: 0.75rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--color-text-tertiary);
    pointer-events: none;
}

.filter-input-search {
    padding-left: 2.5rem;
}

.filters-actions {
    display: flex;
    gap: var(--spacing-sm);
    padding-top: var(--spacing-md);
    border-top: 1px solid var(--color-border);
}

.filter-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--spacing-xs);
    padding: 0.5rem 1rem;
    font-size: var(--font-size-sm);
    font-weight: 500;
    border-radius: var(--radius-sm);
    border: none;
    cursor: pointer;
    transition: all var(--transition-base);
    font-family: var(--font-family);
}

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

.filter-btn-apply {
    flex: 1;
    background: var(--color-primary);
    color: white;
    box-shadow: 0 1px 3px rgba(91, 95, 199, 0.3);
}

.filter-btn-apply:hover {
    background: var(--color-primary-hover);
    box-shadow: 0 2px 4px rgba(91, 95, 199, 0.4);
    transform: translateY(-1px);
}

.filter-btn-apply:active {
    transform: translateY(0);
}

.filter-btn-reset {
    background: var(--color-surface-muted);
    color: var(--color-text-secondary);
    border: 1px solid var(--color-border);
}

.filter-btn-reset:hover {
    background: var(--color-border-medium);
    color: var(--color-text-primary);
}

@media (max-width: 1024px) {
    .filter-item-wide {
        grid-column: span 1;
    }
    
    /* Table responsiveness for small screens */
    .modern-table {
        font-size: var(--font-size-xs);
    }
    
    .modern-table th,
    .modern-table td {
        padding: var(--spacing-sm) var(--spacing-md);
    }
    
    /* Compact action buttons in tables */
    .table-actions-group {
        gap: 4px;
    }
    
    .table-action-btn {
        width: 28px;
        height: 28px;
    }
    
    .table-action-btn svg {
        width: 14px;
        height: 14px;
    }
}

@media (max-width: 768px) {
    .filters-grid {
        grid-template-columns: 1fr;
    }
    
    .filter-item-wide {
        grid-column: span 1;
    }
    
    .filters-actions {
        flex-direction: column;
    }
    
    .filter-btn {
        width: 100%;
    }
    
    /* Make tables scrollable horizontally */
    .table-container {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    /* Set minimum width for tables to prevent crushing */
    .modern-table {
        min-width: 650px;
    }
    
    /* Stack table cells vertically on very small screens */
    .table-actions-group {
        flex-wrap: wrap;
        justify-content: flex-start;
    }
}

/* Tables */
.table-container, .table-wrapper {
    overflow-x: auto;
    border-radius: var(--radius-lg);
    border: 1px solid var(--color-border);
    background: var(--color-surface);
}

table, .data-table {
    width: 100%;
    border-collapse: collapse;
    background: var(--color-surface);
}

th {
    background: var(--color-surface-muted);
    color: var(--color-text-secondary);
    font-weight: 600;
    text-transform: uppercase;
    font-size: var(--font-size-xs);
    letter-spacing: 0.05em;
    padding: var(--spacing-md);
    text-align: left;
    border-bottom: 1px solid var(--color-border);
}

th.table-actions {
    text-align: center;
    width: 120px;
}

td {
    padding: var(--spacing-md);
    border-bottom: 1px solid var(--color-border);
    color: var(--color-text-primary);
    font-size: var(--font-size-sm);
    vertical-align: middle;
}

tbody tr {
    transition: background-color var(--transition-base);
}

tbody tr:hover {
    background-color: var(--color-surface-muted);
}

tbody tr.row-inactive {
    opacity: 0.6;
}

tr:last-child td {
    border-bottom: none;
}

.table-cell-top {
    vertical-align: top;
}

.table-empty {
    padding: var(--spacing-3xl) var(--spacing-lg);
    text-align: center;
}

.text-medium {
    font-weight: 600;
    color: var(--color-text-primary);
}

.text-secondary {
    color: var(--color-text-secondary);
}

.text-mono {
    font-family: 'SF Mono', 'Monaco', 'Menlo', 'Courier New', monospace;
    font-size: 0.9em;
    font-weight: 500;
    letter-spacing: 0.01em;
    color: var(--color-text-secondary);
}

/* Таблицы: длинный текст в ячейках не раздувает колонки */
.table-container > table,
.table-wrapper > table {
    max-width: 100%;
}

.table-layout-fixed,
.table-container .data-table,
.table-wrapper .data-table,
.table-container .settings-entities-table,
.table-container .modern-table,
.table-container .purchase-format-rules-table,
.table-container .purchase-items-table,
.table-container .supplier-active-purchases-table,
.table-container .supplier-history-purchases-table,
.table-container .dashboard-recent-purchases,
.table-container .repair-rows-table,
.table-container .recurring-rows-table,
.table-container .shipment-rows-table {
    table-layout: fixed;
    width: 100%;
}

.table-layout-fixed th,
.table-layout-fixed td,
.table-container .data-table th,
.table-container .data-table td,
.table-wrapper .data-table th,
.table-wrapper .data-table td,
.table-container .settings-entities-table th,
.table-container .settings-entities-table td,
.table-container .modern-table th,
.table-container .modern-table td,
.table-container .purchase-format-rules-table th,
.table-container .purchase-format-rules-table td,
.table-container .purchase-items-table th,
.table-container .purchase-items-table td,
.table-container .supplier-active-purchases-table th,
.table-container .supplier-active-purchases-table td,
.table-container .supplier-history-purchases-table th,
.table-container .supplier-history-purchases-table td,
.table-container .dashboard-recent-purchases th,
.table-container .dashboard-recent-purchases td,
.table-container .repair-rows-table th,
.table-container .repair-rows-table td,
.table-container .recurring-rows-table th,
.table-container .recurring-rows-table td,
.table-container .shipment-rows-table th,
.table-container .shipment-rows-table td {
    overflow-wrap: break-word;
    word-break: break-word;
}

.table-cell-wrap,
td.text-wrap {
    white-space: normal;
    vertical-align: top;
    overflow-wrap: break-word;
    word-break: break-word;
    line-height: var(--line-height-relaxed);
    font-size: var(--font-size-sm);
    color: var(--color-text-secondary);
}

.table-cell-mono-wrap {
    font-family: 'SF Mono', 'Monaco', 'Menlo', 'Courier New', monospace;
    font-size: var(--font-size-xs);
    font-weight: 500;
    letter-spacing: 0.01em;
    color: var(--color-text-secondary);
    word-break: break-all;
    overflow-wrap: anywhere;
    white-space: normal;
    vertical-align: top;
    line-height: 1.55;
    hyphens: none;
}

.table-container th.table-actions,
.table-wrapper th.table-actions,
.table-container td.table-col-actions,
.table-wrapper td.table-col-actions,
.table-container td:has(> .table-actions-group),
.table-wrapper td:has(> .table-actions-group) {
    width: 5.5rem;
    white-space: nowrap;
    vertical-align: top;
    text-align: right;
}

.table-container td:has(> .table-actions-group) .table-actions-group,
.table-wrapper td:has(> .table-actions-group) .table-actions-group,
.table-container td.table-col-actions .table-actions-group,
.table-wrapper td.table-col-actions .table-actions-group {
    justify-content: flex-end;
}

@media (max-width: 768px) {
    .table-container .purchase-format-rules-table {
        min-width: 1120px;
    }

    .table-layout-fixed,
    .table-container .data-table,
    .table-wrapper .data-table,
    .table-container .settings-entities-table,
    .table-container .modern-table,
    .table-container .purchase-items-table,
    .table-container .supplier-active-purchases-table,
    .table-container .supplier-history-purchases-table,
    .table-container .dashboard-recent-purchases,
    .table-container .repair-rows-table,
    .table-container .recurring-rows-table,
    .table-container .shipment-rows-table {
        min-width: 640px;
    }
}

.table-actions-group {
    display: flex;
    align-items: center;
    gap: var(--spacing-xs);
    justify-content: center;
}

.modern-table .table-actions-group {
    justify-content: flex-end;
}

/* Кнопки действий в строках таблиц — как в «Типы активов» (/settings/inventory) */
.table-action-btn {
    width: 32px;
    height: 32px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    background: transparent;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    color: var(--color-text-secondary);
    cursor: pointer;
    transition: all var(--transition-fast);
    text-decoration: none;
    flex-shrink: 0;
}

.table-action-btn:hover {
    background: var(--color-surface-muted);
    border-color: var(--color-border-medium);
}

.table-action-btn:focus-visible {
    outline: 2px solid var(--color-primary);
    outline-offset: 2px;
}

.table-action-btn svg {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
}

.table-action-edit:hover {
    background: var(--color-primary-subtle);
    border-color: var(--color-primary);
    color: var(--color-primary);
}

.table-action-delete:hover {
    background: var(--color-danger-light);
    border-color: var(--color-danger);
    color: var(--color-danger);
}

.table-action-success:hover {
    background: var(--color-success-light);
    border-color: var(--color-success);
    color: var(--color-success);
}

.table-action-warning:hover {
    background: var(--color-warning-light);
    border-color: var(--color-warning);
    color: var(--color-warning);
}

.action-buttons {
    display: flex;
    align-items: center;
    gap: var(--spacing-xs);
    justify-content: flex-start;
    flex-wrap: nowrap;
}

.page-actions .action-buttons {
    justify-content: flex-end;
}

.icon-button-danger {
    color: var(--color-danger);
    border-color: var(--color-border);
    background: var(--color-surface);
}

.icon-button-danger:hover {
    background: var(--color-danger);
    color: var(--color-text-inverse);
    border-color: var(--color-danger);
    transform: translateY(-1px);
    box-shadow: 0 2px 4px 0 rgba(229, 72, 77, 0.2);
}

/* Purchase Items Preview */
.purchase-items-preview {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
}

.purchase-items-preview .item-name {
    color: var(--color-text-primary);
    font-weight: 500;
    font-size: var(--font-size-sm);
}

.purchase-items-preview .items-count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 2px 6px;
    background-color: var(--color-primary-light);
    color: var(--color-primary-hover);
    font-size: var(--font-size-xs);
    font-weight: 600;
    border-radius: var(--radius-full);
    line-height: 1;
}

/* Badges & Status */
.status-badge, .badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    border-radius: var(--radius-full);
    font-size: var(--font-size-xs);
    font-weight: 500;
    line-height: 1;
    letter-spacing: 0.01em;
}

.status-pending, .badge-pending {
    background-color: var(--color-warning-light);
    color: #9f5a00;
}

.status-processing, .status-in_progress, .status-assigned, .badge-in_progress {
    background-color: var(--color-info-light);
    color: #0072ce;
}

.status-completed, .status-ready, .status-delivered, .status-partially_received, .badge-success {
    background-color: var(--color-success-light);
    color: #1a7f51;
}

.status-cancelled, .badge-danger {
    background-color: var(--color-danger-light);
    color: #c7343b;
}

/* Alerts & Messages */
.messages {
    margin-bottom: var(--spacing-lg);
}

/*
 * Страницы входа / 2FA: flash не должен сдвигать центрированную карточку в потоке документа.
 * Уведомление показывается под шапкой и навигацией (см. sticky top у .main-nav).
 */
.main-content:has(.auth-container) .messages {
    position: fixed;
    left: 50%;
    transform: translateX(-50%);
    top: calc(env(safe-area-inset-top, 0px) + 73px + 3.25rem);
    z-index: 110;
    width: min(420px, calc(100vw - 2 * var(--spacing-lg)));
    margin-bottom: 0;
    pointer-events: none;
}

.main-content:has(.auth-container) .messages .alert {
    pointer-events: auto;
}

.alert {
    display: flex;
    align-items: flex-start;
    gap: var(--spacing-sm);
    padding: var(--spacing-md) var(--spacing-lg);
    padding-right: calc(var(--spacing-lg) + 28px);
    border-radius: var(--radius-lg);
    margin-bottom: var(--spacing-md);
    border: 1px solid transparent;
    font-size: 0.9375rem;
    font-weight: 500;
    line-height: 1.5;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    animation: slideIn 0.4s cubic-bezier(0.16, 1, 0.3, 1);
    position: relative;
}

.alert-text {
    flex: 1;
    min-width: 0;
}

.alert-dismiss {
    position: absolute;
    top: var(--spacing-sm);
    right: var(--spacing-sm);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    padding: 0;
    border: none;
    border-radius: var(--radius-sm);
    background: transparent;
    color: inherit;
    opacity: 0.55;
    cursor: pointer;
    transition: opacity var(--transition-base), background-color var(--transition-base);
}

.alert-dismiss:hover {
    opacity: 1;
    background: rgba(0, 0, 0, 0.06);
}

.alert-dismiss:focus-visible {
    outline: 2px solid currentColor;
    outline-offset: 2px;
    opacity: 1;
}

.page-flash-messages {
    max-width: 920px;
    margin: 0 auto var(--spacing-lg);
    padding: 0 var(--spacing-lg);
}

.alert-icon {
    flex-shrink: 0;
    width: 20px;
    height: 20px;
    margin-top: 2px;
    stroke: currentColor;
    fill: none;
    stroke-width: 2;
}

.alert-success {
    background-color: #f0fdf4;
    color: #15803d;
    border-color: #86efac;
}

.alert-success .alert-icon {
    stroke: #22c55e;
}

.alert-error, .alert-danger {
    background-color: #fef2f2;
    color: #b91c1c;
    border-color: #fecaca;
}

.alert-error .alert-icon,
.alert-danger .alert-icon {
    stroke: #ef4444;
}

.alert-warning {
    background-color: #fffbeb;
    color: #b45309;
    border-color: #fde68a;
}

.alert-warning .alert-icon {
    stroke: #f59e0b;
}

.alert-info {
    background-color: #f0f9ff;
    color: #0369a1;
    border-color: #bae6fd;
}

.alert-info .alert-icon {
    stroke: #0ea5e9;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(-12px) scale(0.98);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

@keyframes slideOut {
    from {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
    to {
        opacity: 0;
        transform: translateY(-12px) scale(0.98);
    }
}

/* Notifications */
.notification-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    background: var(--color-danger);
    color: var(--color-text-inverse);
    border-radius: var(--radius-full);
    padding: 0 5px;
    min-width: 18px;
    height: 18px;
    font-size: var(--font-size-xs);
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid var(--color-surface);
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.1);
    }
}

.notifications-panel {
    position: fixed;
    top: 72px;
    right: var(--spacing-lg);
    width: 380px;
    max-width: calc(100vw - 2 * var(--spacing-lg));
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-xl);
    z-index: 1000;
    overflow: hidden;
    animation: slideDown 0.2s ease-out;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.notifications-header {
    padding: var(--spacing-md) var(--spacing-lg);
    border-bottom: 1px solid var(--color-border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--color-surface-muted);
}

.notifications-header h3 {
    font-size: var(--font-size-base);
    font-weight: 600;
}

.notifications-list {
    max-height: 420px;
    overflow-y: auto;
}

.notification-item {
    display: flex;
    align-items: center;
    gap: var(--spacing-md);
    padding: var(--spacing-md) var(--spacing-lg);
    border-bottom: 1px solid var(--color-border);
    transition: background var(--transition-base), transform var(--transition-base);
    animation: slideInNotification 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes slideInNotification {
    from {
        opacity: 0;
        transform: translateX(20px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.notification-item-clickable {
    cursor: pointer;
}

.notification-item-clickable:hover {
    background: var(--color-surface-muted);
    transform: translateX(-2px);
}

.notification-item-clickable:active {
    transform: translateX(-1px);
}

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

.notification-arrow {
    flex-shrink: 0;
    color: var(--color-text-tertiary);
    transition: transform var(--transition-base), color var(--transition-base);
}

.notification-item-clickable:hover .notification-arrow {
    color: var(--color-primary);
    transform: translateX(3px);
}

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

.notification-item:hover {
    background: var(--color-surface-muted);
}

.notification-item.unread {
    background: linear-gradient(135deg, var(--color-primary-subtle) 0%, rgba(91, 95, 199, 0.05) 100%);
    font-weight: 500;
    border-left: 3px solid var(--color-primary);
}

.notification-item.unread:hover {
    background: linear-gradient(135deg, var(--color-primary-light) 0%, rgba(91, 95, 199, 0.08) 100%);
}

.notification-item.read {
    opacity: 0.7;
}

.notification-content {
    font-size: var(--font-size-sm);
    color: var(--color-text-primary);
    line-height: var(--line-height-normal);
    margin-bottom: var(--spacing-xs);
}

.notification-time {
    display: inline-flex;
    align-items: center;
    gap: var(--spacing-xs);
    font-size: var(--font-size-xs);
    color: var(--color-text-tertiary);
    padding: 2px 8px;
    background: var(--color-surface-muted);
    border-radius: var(--radius-sm);
    font-weight: 500;
}

.notification-empty {
    padding: var(--spacing-3xl) var(--spacing-lg);
    text-align: center;
    color: var(--color-text-tertiary);
}

.notification-empty svg {
    margin-bottom: var(--spacing-sm);
    color: var(--color-text-tertiary);
}

.notification-empty p {
    font-size: var(--font-size-sm);
    margin: 0;
}

/* Auth Pages */
.auth-container {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: calc(100vh - 240px);
    padding: var(--spacing-lg);
}

.auth-box {
    width: 100%;
    max-width: 420px;
    padding: var(--spacing-2xl);
    background: var(--color-surface);
    border-radius: var(--radius-2xl);
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--color-border);
}

.auth-box h2 {
    text-align: center;
    margin-bottom: var(--spacing-xl);
    font-size: var(--font-size-2xl);
}

.auth-form .form-group:last-of-type {
    margin-bottom: var(--spacing-xl);
}

.auth-links {
    margin-top: var(--spacing-lg);
    text-align: center;
    font-size: var(--font-size-sm);
    color: var(--color-text-secondary);
}

.auth-links a {
    color: var(--color-primary);
    font-weight: 500;
}

.auth-links a:hover {
    text-decoration: underline;
}

/* Dashboard */
.dashboard {
    max-width: 100%;
}

.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: var(--spacing-lg);
    padding: 0;
}

.dashboard-card {
    background: var(--color-surface);
    border-radius: var(--radius-xl);
    border: 1px solid var(--color-border);
    box-shadow: var(--shadow-sm);
    padding: 0;
    overflow: hidden;
    transition: box-shadow var(--transition-base);
}

.dashboard-card:hover {
    box-shadow: var(--shadow-md);
}

.welcome-section {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    padding: var(--spacing-3xl) var(--spacing-2xl);
}

.welcome-section h2 {
    font-size: var(--font-size-2xl);
    margin-bottom: var(--spacing-md);
}

.welcome-subtitle {
    color: var(--color-text-secondary);
    font-size: var(--font-size-base);
    margin: 0 0 var(--spacing-xl) 0;
    max-width: 600px;
}

.quick-actions {
    display: flex;
    gap: var(--spacing-md);
    flex-wrap: wrap;
    justify-content: center;
    margin-top: var(--spacing-lg);
}

.auth-actions {
    display: flex;
    gap: var(--spacing-md);
    justify-content: center;
    margin-top: var(--spacing-lg);
}

.dashboard-sections {
    display: grid;
    grid-template-columns: 1fr;
    gap: var(--spacing-lg);
    margin-top: var(--spacing-xl);
}

.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: var(--spacing-3xl) var(--spacing-xl);
    color: var(--color-text-tertiary);
    background: var(--color-surface);
    border-radius: var(--radius-xl);
    border: 1px solid var(--color-border);
    gap: var(--spacing-md);
}

.empty-state svg {
    color: var(--color-text-tertiary);
    opacity: 0.4;
    margin-bottom: 0;
    flex-shrink: 0;
}

.empty-state h3 {
    margin: 0;
    font-size: var(--font-size-lg);
    font-weight: 600;
    color: var(--color-text-primary);
}

.empty-state-text {
    font-size: var(--font-size-base);
    margin: 0 0 var(--spacing-sm) 0;
    color: var(--color-text-secondary);
    font-weight: 600;
}

.empty-state-hint {
    font-size: var(--font-size-sm);
    margin: 0;
    color: var(--color-text-tertiary);
}

.empty-state p {
    font-size: var(--font-size-base);
    margin: 0 0 var(--spacing-lg) 0;
    color: var(--color-text-secondary);
    font-weight: 500;
}

/* Dropdowns */
.dropdown {
    position: relative;
    display: inline-block;
}

.dropdown-toggle {
    background-color: transparent;
    color: var(--color-text-secondary);
    border: 1px solid var(--color-border);
    padding: 0.5rem 1rem;
    border-radius: var(--radius-md);
    cursor: pointer;
    font-size: var(--font-size-sm);
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    transition: all var(--transition-base);
}

.dropdown-toggle svg {
    width: 18px;
    height: 18px;
}

.dropdown-toggle:hover {
    background-color: var(--color-surface-muted);
    color: var(--color-text-primary);
    border-color: var(--color-border-medium);
}

.dropdown-menu {
    display: none;
    position: absolute;
    right: 0;
    top: calc(100% + 4px);
    background-color: var(--color-surface);
    min-width: 220px;
    box-shadow: var(--shadow-xl);
    border-radius: var(--radius-lg);
    border: 1px solid var(--color-border);
    z-index: 1000;
    padding: var(--spacing-sm) 0;
    animation: dropdownSlide 0.2s ease-out;
}

@keyframes dropdownSlide {
    from {
        opacity: 0;
        transform: translateY(-8px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.dropdown:hover .dropdown-menu,
.dropdown:focus-within .dropdown-menu {
    display: block;
}

.dropdown-item {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    padding: 0.625rem var(--spacing-md);
    color: var(--color-text-primary);
    font-size: var(--font-size-sm);
    text-decoration: none;
    transition: background var(--transition-fast);
}

.dropdown-item svg {
    width: 16px;
    height: 16px;
}

.dropdown-item:hover {
    background-color: var(--color-surface-muted);
    color: var(--color-primary);
}

.dropdown-divider {
    height: 1px;
    background-color: var(--color-border);
    margin: var(--spacing-sm) 0;
}

.dropdown-item-danger {
    color: var(--color-danger);
}

.dropdown-item-danger:hover {
    background-color: var(--color-danger-light);
    color: var(--color-danger-hover);
}

.debug-info {
    font-size: var(--font-size-xs);
    color: var(--color-text-tertiary);
    padding: var(--spacing-sm) var(--spacing-md);
    background-color: var(--color-surface-muted);
    cursor: default;
}

.debug-info:hover {
    background-color: var(--color-surface-muted);
    color: var(--color-text-tertiary);
}

.dropdown-caret {
    margin-left: auto;
    transition: transform var(--transition-base);
}

.dropdown:hover .dropdown-caret {
    transform: rotate(180deg);
}

/* Utilities */
.text-center { text-align: center; }
.text-muted {
    color: var(--color-text-tertiary);
    font-style: italic;
    font-size: var(--font-size-xs);
}
.mt-4 { margin-top: var(--spacing-md); }
.mb-4 { margin-bottom: var(--spacing-md); }

.stack-sm { display: flex; flex-direction: column; gap: var(--spacing-sm); }
.stack-md { display: flex; flex-direction: column; gap: var(--spacing-md); }
.inline-sm { 
    display: inline-flex; 
    align-items: center; 
    gap: var(--spacing-sm);
    vertical-align: middle;
}

.is-hidden { 
    display: none !important; 
}

.inline-form {
    display: inline-flex;
    margin: 0;
}

/* Purchase Form */
.purchase-form {
    max-width: 900px;
    margin: 0 auto;
}

.item-card {
    position: relative;
    padding: var(--spacing-lg);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    background: var(--color-surface);
    margin-bottom: var(--spacing-lg);
    transition: border-color var(--transition-base);
}

.item-card:hover {
    border-color: var(--color-border-medium);
}

.item-remove {
    position: absolute;
    top: var(--spacing-md);
    right: var(--spacing-md);
}

.form-actions {
    display: flex;
    gap: var(--spacing-sm);
    margin-top: var(--spacing-xl);
    padding-top: var(--spacing-lg);
    border-top: 1px solid var(--color-border);
}

.total-amount {
    font-size: var(--font-size-xl);
    color: var(--color-primary);
    font-weight: 600;
}

/* Purchase View */
.purchase-header {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-lg);
}

.purchase-meta {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: var(--spacing-md) var(--spacing-lg);
    font-size: var(--font-size-sm);
}

.purchase-meta > div {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.purchase-meta strong {
    color: var(--color-text-secondary);
    font-weight: 500;
    font-size: var(--font-size-xs);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.supplier-info, .supplier-fields {
    margin-top: var(--spacing-md);
}

.codes-section {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--spacing-lg);
    text-align: center;
}

.qr-code img {
    max-width: 200px;
    border-radius: var(--radius-lg);
    border: 1px solid var(--color-border);
    padding: var(--spacing-sm);
    background: var(--color-surface);
}

.access-code {
    font-size: var(--font-size-xl);
    font-weight: 600;
    font-family: 'SF Mono', Monaco, 'Cascadia Code', monospace;
    background: var(--color-surface-muted);
    padding: var(--spacing-md) var(--spacing-xl);
    border-radius: var(--radius-lg);
    border: 2px dashed var(--color-border-medium);
    letter-spacing: 0.1em;
}

.notes-section pre {
    background: var(--color-surface-muted);
    padding: var(--spacing-md);
    border-radius: var(--radius-lg);
    border: 1px solid var(--color-border);
    white-space: pre-wrap;
    color: var(--color-text-secondary);
    font-size: var(--font-size-sm);
    line-height: var(--line-height-relaxed);
}

/* Profile */
.profile-container {
    max-width: 1000px;
    margin: 0 auto;
}

.user-role-badge {
    background: var(--color-primary-light);
    color: var(--color-primary);
    padding: 6px 14px;
    border-radius: var(--radius-full);
    font-size: var(--font-size-xs);
    text-transform: capitalize;
    font-weight: 600;
    letter-spacing: 0.025em;
}

.profile-sections {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
    gap: var(--spacing-lg);
}

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

.activity-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: var(--spacing-md);
}

.stat-item {
    text-align: center;
    padding: var(--spacing-lg);
    background: var(--color-surface-muted);
    border-radius: var(--radius-lg);
    border: 1px solid var(--color-border);
    transition: transform var(--transition-base), box-shadow var(--transition-base);
}

.stat-item:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.stat-value {
    font-size: var(--font-size-2xl);
    font-weight: 700;
    color: var(--color-primary);
    line-height: 1;
}

.stat-label {
    color: var(--color-text-secondary);
    margin-top: var(--spacing-sm);
    font-size: var(--font-size-sm);
}

/* Modal */
.modal {
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: rgba(15, 23, 42, 0.5);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--spacing-lg);
    animation: fadeInModal 0.2s ease-out;
}

@keyframes fadeInModal {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

.modal-content {
    background-color: var(--color-surface);
    padding: var(--spacing-xl);
    border: 1px solid var(--color-border);
    width: 100%;
    max-width: 540px;
    border-radius: var(--radius-2xl);
    box-shadow: var(--shadow-xl);
    position: relative;
    animation: slideUpModal 0.3s ease-out;
}

@keyframes slideUpModal {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.modal-content h3 {
    margin-bottom: var(--spacing-lg);
}

.modal-close {
    position: absolute;
    top: var(--spacing-md);
    right: var(--spacing-md);
    background: var(--color-surface-muted);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-full);
    width: 32px;
    height: 32px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all var(--transition-base);
    padding: 0;
}

.modal-close svg {
    width: 16px;
    height: 16px;
}

.modal-close:hover {
    background: var(--color-border);
    transform: rotate(90deg);
}

/* Office Selection Component */
.office-selection-container {
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    padding: var(--spacing-md);
    background: var(--color-surface-muted);
}

.office-selection-grid {
    display: grid;
    gap: var(--spacing-sm);
}

.office-option {
    position: relative;
    display: block;
    cursor: pointer;
    border-radius: var(--radius-md);
    transition: all var(--transition-base);
    background: var(--color-surface);
    border: 1px solid var(--color-border);
}

.office-option:hover {
    background: var(--color-surface-muted);
    border-color: var(--color-border-medium);
    transform: translateY(-1px);
    box-shadow: var(--shadow-sm);
}

.office-checkbox {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}

.office-option-content {
    padding: var(--spacing-md);
}

.office-option-header {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
}

.office-option-icon {
    flex-shrink: 0;
    color: var(--color-text-tertiary);
    transition: color var(--transition-base);
}

.office-option-name {
    flex: 1;
    font-weight: 500;
    font-size: var(--font-size-sm);
    color: var(--color-text-primary);
}

.office-option-checkmark {
    flex-shrink: 0;
    color: var(--color-primary);
    opacity: 0;
    transform: scale(0.8);
    transition: all var(--transition-base);
}

.office-option-address {
    font-size: var(--font-size-xs);
    color: var(--color-text-secondary);
    margin-top: var(--spacing-xs);
    margin-left: calc(16px + var(--spacing-sm));
    line-height: var(--line-height-normal);
}

/* Checked state */
.office-checkbox:checked + .office-option-content {
    background: transparent;
}

.office-checkbox:checked ~ .office-option-content .office-option-icon {
    color: var(--color-primary);
}

.office-checkbox:checked ~ .office-option-content .office-option-checkmark {
    opacity: 1;
    transform: scale(1);
}

.office-option:has(.office-checkbox:checked) {
    background: var(--color-primary-subtle);
    border-color: var(--color-primary);
    outline: 3px solid var(--color-primary-light);
    outline-offset: 1px;
}

.office-option:has(.office-checkbox:checked):hover {
    background: var(--color-primary-light);
    border-color: var(--color-primary);
    outline: 3px solid var(--color-primary-light);
    outline-offset: 1px;
}

/* Focus state for accessibility */
.office-checkbox:focus + .office-option-content {
    outline: 2px solid var(--color-primary);
    outline-offset: 2px;
}

/* Module Selection Component */
.module-selection-container {
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    padding: var(--spacing-md);
    background: var(--color-surface-muted);
}

.module-selection-grid {
    display: grid;
    gap: var(--spacing-sm);
}

.module-option {
    position: relative;
    display: block;
    cursor: pointer;
    border-radius: var(--radius-md);
    transition: all var(--transition-base);
    background: var(--color-surface);
    border: 1px solid var(--color-border);
}

.module-option:hover {
    background: var(--color-surface-muted);
    border-color: var(--color-border-medium);
    transform: translateY(-1px);
    box-shadow: var(--shadow-sm);
}

.module-checkbox {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}

.module-option-content {
    padding: var(--spacing-md);
}

.module-option-header {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    margin-bottom: var(--spacing-xs);
}

.module-option-icon {
    flex-shrink: 0;
    color: var(--color-text-tertiary);
    transition: color var(--transition-base);
}

.module-option-name {
    flex: 1;
    font-weight: 500;
    font-size: var(--font-size-sm);
    color: var(--color-text-primary);
}

.module-option-checkmark {
    flex-shrink: 0;
    color: var(--color-primary);
    opacity: 0;
    transform: scale(0.8);
    transition: all var(--transition-base);
}

.module-option-description {
    font-size: var(--font-size-xs);
    color: var(--color-text-secondary);
    margin-left: calc(18px + var(--spacing-sm));
    line-height: var(--line-height-normal);
}

/* Checked state */
.module-checkbox:checked + .module-option-content {
    background: transparent;
}

.module-checkbox:checked ~ .module-option-content .module-option-icon {
    color: var(--color-primary);
}

.module-checkbox:checked ~ .module-option-content .module-option-checkmark {
    opacity: 1;
    transform: scale(1);
}

.module-option:has(.module-checkbox:checked) {
    background: var(--color-primary-subtle);
    border-color: var(--color-primary);
    outline: 3px solid var(--color-primary-light);
    outline-offset: 1px;
}

.module-option:has(.module-checkbox:checked):hover {
    background: var(--color-primary-light);
    border-color: var(--color-primary);
    outline: 3px solid var(--color-primary-light);
    outline-offset: 1px;
}

/* Focus state for accessibility */
.module-checkbox:focus + .module-option-content {
    outline: 2px solid var(--color-primary);
    outline-offset: 2px;
}

/* Error Pages */
.error-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: calc(100vh - 300px);
    padding: var(--spacing-3xl) var(--spacing-lg);
}

.error-container {
    max-width: 560px;
    width: 100%;
    text-align: center;
}

.error-icon-wrapper {
    display: flex;
    justify-content: center;
    margin-bottom: var(--spacing-xl);
    animation: fadeInScale 0.5s ease-out;
}

@keyframes fadeInScale {
    from {
        opacity: 0;
        transform: scale(0.9);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

.error-icon {
    color: var(--color-text-tertiary);
    animation: float 3s ease-in-out infinite;
}

@keyframes float {
    0%, 100% {
        transform: translateY(0);
    }
    50% {
        transform: translateY(-10px);
    }
}

.error-icon.access-denied {
    color: var(--color-danger);
}

.error-icon.not-found {
    color: var(--color-warning);
}

.error-icon.server-error {
    color: var(--color-danger);
}

.error-icon.no-access {
    color: var(--color-primary);
}

.error-content {
    margin-bottom: var(--spacing-xl);
}

.error-title {
    font-size: var(--font-size-2xl);
    font-weight: 600;
    color: var(--color-text-primary);
    margin-bottom: var(--spacing-md);
}

.error-message {
    font-size: var(--font-size-base);
    color: var(--color-text-secondary);
    line-height: var(--line-height-relaxed);
    margin: 0;
}

.error-info-box {
    background: var(--color-surface-muted);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    padding: var(--spacing-md) var(--spacing-lg);
    margin-bottom: var(--spacing-xl);
}

.error-info-label {
    font-size: var(--font-size-xs);
    font-weight: 500;
    color: var(--color-text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: var(--spacing-xs);
}

.error-info-value {
    font-size: var(--font-size-base);
    font-weight: 600;
    color: var(--color-text-primary);
}

.error-actions {
    display: flex;
    gap: var(--spacing-md);
    justify-content: center;
    flex-wrap: wrap;
    margin-bottom: var(--spacing-lg);
}

.error-details {
    margin-top: var(--spacing-xl);
    padding-top: var(--spacing-lg);
    border-top: 1px solid var(--color-border);
}

.error-code {
    font-size: var(--font-size-sm);
    font-weight: 500;
    color: var(--color-text-tertiary);
    margin: 0;
    letter-spacing: 0.05em;
}

.error-hint {
    font-size: var(--font-size-sm);
    color: var(--color-text-tertiary);
    margin: 0;
}

/* Responsive */

/* Small Laptop & Tablet Landscape (1024px - 1440px) */
@media (max-width: 1440px) {
    /* Reduce max-width for smaller screens */
    .header-content,
    .nav-content,
    .main-content {
        max-width: 100%;
        padding-left: var(--spacing-md);
        padding-right: var(--spacing-md);
    }
    
    /* Smaller font sizes */
    .header-brand h1 {
        font-size: var(--font-size-base);
    }
    
    /* Compact navigation */
    .nav-item {
        padding: var(--spacing-sm) var(--spacing-md);
        font-size: var(--font-size-xs);
        gap: 6px;
    }
    
    .nav-item svg {
        width: 16px;
        height: 16px;
    }
    
    /* Compact grid layouts */
    .filters-grid {
        grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    }
    
    .dashboard-grid {
        grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    }
    
    .card-grid {
        grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    }
    
    /* Reduce table padding */
    th, td {
        padding: var(--spacing-sm) var(--spacing-md);
    }
    
    /* Compact modals */
    .modal-dialog {
        max-width: 90vw;
        margin: var(--spacing-md);
    }
    
    .modal-dialog-lg {
        max-width: 95vw;
    }
    
    /* Reduce spacing in forms */
    .form-group {
        margin-bottom: var(--spacing-md);
    }
}

/* Tablet Portrait (768px - 1024px) */
@media (max-width: 1024px) {
    /* More compact spacing */
    .page-header,
    .page-header-with-tabs {
        gap: var(--spacing-md);
    }
    
    /* Navigation adjustments */
    .nav-item {
        padding: var(--spacing-sm) var(--spacing-md);
        font-size: var(--font-size-xs);
    }
    
    .nav-item svg {
        width: 16px;
        height: 16px;
    }
    
    /* Single column layouts */
    .profile-sections {
        grid-template-columns: 1fr;
    }
    
    .form-row {
        grid-template-columns: 1fr;
    }
    
    /* Table responsiveness */
    .table-container {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    /* Smaller buttons */
    .btn, .action-btn {
        padding: 0.5rem 0.875rem;
        font-size: var(--font-size-xs);
    }
}

/* Mobile & Small Tablets (max 768px) */
@media (max-width: 768px) {
    .header-content {
        flex-wrap: wrap;
        padding: 0 var(--spacing-sm);
    }
    
    .header-brand h1 {
        font-size: var(--font-size-sm);
    }
    
    .nav-content {
        padding: var(--spacing-xs) var(--spacing-sm);
    }
    
    .nav-item span {
        display: none;
    }
    
    .nav-item {
        padding: var(--spacing-md);
    }
    
    .page-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .form-actions {
        flex-direction: column;
    }

    .profile-sections {
        grid-template-columns: 1fr;
    }

    .notifications-panel {
        right: var(--spacing-sm);
        left: var(--spacing-sm);
        width: auto;
    }
    
    .card-grid {
        grid-template-columns: 1fr;
    }
    
    .error-page {
        min-height: calc(100vh - 200px);
        padding: var(--spacing-xl) var(--spacing-md);
    }
    
    .error-icon-wrapper svg {
        width: 80px;
        height: 80px;
    }
    
    .error-title {
        font-size: var(--font-size-xl);
    }
    
    .error-actions {
        flex-direction: column;
    }
    
    .error-actions .btn,
    .error-actions .main-btn {
        width: 100%;
    }
    
    /* Hide less important content on mobile */
    .table-cell-hide-mobile {
        display: none;
    }
}

/* Inline Error/Warning Boxes */
.inline-error,
.inline-warning,
.inline-info,
.inline-no-access {
    display: flex;
    align-items: flex-start;
    gap: var(--spacing-md);
    padding: var(--spacing-lg);
    border-radius: var(--radius-lg);
    border: 1px solid;
    margin-bottom: var(--spacing-lg);
    animation: slideIn 0.3s ease-out;
}

.inline-error {
    background: var(--color-danger-light);
    border-color: var(--color-danger);
    color: #c7343b;
}

.inline-warning {
    background: var(--color-warning-light);
    border-color: var(--color-warning);
    color: #9f5a00;
}

.inline-info {
    background: var(--color-info-light);
    border-color: var(--color-info);
    color: #0072ce;
}

.inline-no-access {
    background: var(--color-primary-light);
    border-color: var(--color-primary);
    color: var(--color-primary);
}

.inline-error-icon,
.inline-warning-icon,
.inline-info-icon,
.inline-no-access-icon {
    flex-shrink: 0;
    width: 24px;
    height: 24px;
}

.inline-error-content,
.inline-warning-content,
.inline-info-content,
.inline-no-access-content {
    flex: 1;
}

.inline-error-title,
.inline-warning-title,
.inline-info-title,
.inline-no-access-title {
    font-weight: 600;
    font-size: var(--font-size-base);
    margin-bottom: var(--spacing-xs);
}

.inline-error-message,
.inline-warning-message,
.inline-info-message,
.inline-no-access-message {
    font-size: var(--font-size-sm);
    line-height: var(--line-height-relaxed);
    margin: 0;
}

.inline-error-actions,
.inline-warning-actions,
.inline-info-actions,
.inline-no-access-actions {
    display: flex;
    gap: var(--spacing-sm);
    margin-top: var(--spacing-md);
    flex-wrap: wrap;
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* ==========================
   Recurring Purchases & Archive Subtabs Styles
   ========================== */

/* Page Header with Tabs */
.page-header-with-tabs {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    margin-bottom: var(--spacing-xl);
    gap: var(--spacing-lg);
}

.page-title-section {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-md);
    flex: 1;
}

.page-title-section h2 {
    margin: 0;
    font-size: var(--font-size-2xl);
    font-weight: 700;
    color: var(--color-text-primary);
}

/* Page Tabs */
.page-tabs {
    display: flex;
    align-items: center;
    gap: var(--spacing-xs);
    border-bottom: 2px solid var(--color-border);
    padding-bottom: 2px;
}

.page-tab {
    display: inline-flex;
    align-items: center;
    gap: var(--spacing-xs);
    padding: var(--spacing-sm) var(--spacing-md);
    color: var(--color-text-secondary);
    font-weight: 500;
    font-size: var(--font-size-sm);
    text-decoration: none;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    transition: all var(--transition-base);
    white-space: nowrap;
    border-radius: var(--radius-sm) var(--radius-sm) 0 0;
}

.page-tab svg {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
}

.page-tab:hover {
    color: var(--color-primary);
    background: var(--color-surface-muted);
}

.page-tab.active {
    color: var(--color-primary);
    border-bottom-color: var(--color-primary);
    background: var(--color-primary-subtle);
    font-weight: 600;
}

/* Page Header with Back Button (Legacy - keeping for compatibility) */
.back-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: var(--radius-md);
    color: var(--color-text-secondary);
    transition: all var(--transition-base);
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    text-decoration: none;
}

.back-button:hover {
    background: var(--color-surface-muted);
    color: var(--color-primary);
    transform: translateX(-2px);
    border-color: var(--color-border-medium);
}

/* Info Banner */
.info-banner {
    display: flex;
    align-items: flex-start;
    gap: var(--spacing-md);
    padding: var(--spacing-lg);
    background: var(--color-info-subtle);
    border: 1px solid var(--color-info-light);
    border-radius: var(--radius-lg);
    margin-bottom: var(--spacing-xl);
}

.info-banner svg {
    flex-shrink: 0;
    color: var(--color-info);
    margin-top: 2px;
}

.info-banner strong {
    color: var(--color-text-primary);
    font-weight: 600;
}

/* Strict purchase field format: compact info + hover/focus popover */
.purchase-field-strict-hint {
    position: relative;
    display: inline-flex;
    align-self: flex-start;
    margin-bottom: var(--spacing-sm);
    z-index: 20;
}

.purchase-field-strict-hint__trigger {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0;
    width: 2rem;
    height: 2rem;
    min-width: 2rem;
    min-height: 2rem;
    padding: 0;
    margin: 0;
    white-space: normal;
    border: 1px solid var(--color-info-light);
    border-radius: var(--radius-full);
    background: var(--color-info-subtle);
    color: var(--color-info);
    cursor: help;
    transition: background-color 0.2s ease, border-color 0.2s ease, color 0.2s ease, box-shadow 0.2s ease;
}

.purchase-field-strict-hint__trigger:hover {
    background: var(--color-surface);
    border-color: var(--color-info);
    color: var(--color-info);
    box-shadow: var(--shadow-sm);
    outline: none;
}

.purchase-field-strict-hint__trigger:focus-visible {
    background: var(--color-surface);
    border-color: var(--color-info);
    color: var(--color-info);
    outline: none;
    box-shadow: 0 0 0 2px var(--color-surface), 0 0 0 4px var(--color-info-light);
}

.purchase-field-strict-hint__icon {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
}

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

.purchase-field-strict-hint__popover {
    position: absolute;
    left: 0;
    bottom: calc(100% + 0.5rem);
    width: min(22rem, calc(100vw - 2rem));
    max-width: none;
    padding: var(--spacing-md) var(--spacing-lg);
    border: 1px solid var(--color-border-medium);
    border-radius: var(--radius-lg);
    background: var(--color-surface);
    color: var(--color-text-primary);
    box-shadow: var(--shadow-md);
    font-size: var(--font-size-sm);
    line-height: 1.5;
    text-align: left;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transform: translateY(0.25rem);
    transition: opacity 0.18s ease, visibility 0.18s ease, transform 0.18s ease;
}

@media (prefers-reduced-motion: reduce) {
    .purchase-field-strict-hint__popover,
    .purchase-field-strict-hint__trigger {
        transition: none;
    }

    .purchase-field-strict-hint__popover {
        transform: none;
    }
}

.purchase-field-strict-hint:hover .purchase-field-strict-hint__popover,
.purchase-field-strict-hint:focus-within .purchase-field-strict-hint__popover {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    transform: translateY(0);
}

.purchase-field-strict-hint__popover::after {
    content: "";
    position: absolute;
    top: 100%;
    left: 1rem;
    margin-top: -1px;
    border: 7px solid transparent;
    border-top-color: var(--color-surface);
    filter: drop-shadow(0 1px 0 var(--color-border-medium));
}

.purchase-field-strict-hint__title {
    margin: 0 0 var(--spacing-xs);
    font-weight: 600;
    font-size: var(--font-size-sm);
    color: var(--color-text-primary);
}

.purchase-field-strict-hint__body {
    margin: 0;
    color: var(--color-text-secondary);
    font-size: var(--font-size-sm);
    line-height: 1.55;
}

.field-format-invalid,
.form-input.field-format-invalid,
.form-textarea.field-format-invalid {
    border-color: var(--color-danger) !important;
    box-shadow: 0 0 0 1px rgba(199, 52, 59, 0.25);
}

.field-format-invalid:focus,
.form-input.field-format-invalid:focus,
.form-textarea.field-format-invalid:focus {
    border-color: var(--color-danger) !important;
    box-shadow: 0 0 0 2px rgba(199, 52, 59, 0.2);
}

.field-format-error-msg {
    margin: var(--spacing-xs) 0 0;
    font-size: var(--font-size-sm);
    line-height: 1.45;
    color: var(--color-danger);
    font-weight: 500;
}

.field-format-fallback-alert {
    max-width: 42rem;
    margin-bottom: var(--spacing-md);
}

/* Table Container */
.table-container {
    background: var(--color-surface);
    border-radius: var(--radius-xl);
    border: 1px solid var(--color-border);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
}

/* Modern Table */
.modern-table {
    width: 100%;
    border-collapse: collapse;
    font-size: var(--font-size-sm);
}

.modern-table thead {
    background: var(--color-surface-muted);
    border-bottom: 2px solid var(--color-border-medium);
}

.modern-table th {
    padding: var(--spacing-md) var(--spacing-lg);
    text-align: left;
    font-weight: 600;
    color: var(--color-text-primary);
    font-size: var(--font-size-xs);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.modern-table td {
    padding: var(--spacing-md) var(--spacing-lg);
    border-top: 1px solid var(--color-border);
    color: var(--color-text-secondary);
    vertical-align: middle;
}

.modern-table tbody tr {
    transition: all var(--transition-base);
    background: var(--color-surface);
}

.modern-table tbody tr:hover {
    background: var(--color-surface-muted);
}

/* In-table navigation: linked titles (repairs-style) and purchase item rows */
.table-link {
    color: var(--color-primary);
    font-weight: 500;
    text-decoration: none;
    border-bottom: 1px solid var(--color-primary-light);
    transition: color var(--transition-fast), border-color var(--transition-fast);
}

.table-link:hover {
    color: var(--color-primary-hover);
    border-bottom-color: var(--color-primary-hover);
}

.table-link:focus-visible {
    outline: 2px solid var(--color-primary);
    outline-offset: 2px;
    border-radius: var(--radius-sm);
}

tr.dashboard-recent-purchase-row {
    cursor: pointer;
}

tr.dashboard-recent-purchase-row:hover > td {
    background: var(--color-surface-muted);
}

tr.repair-row {
    cursor: pointer;
}

tr.repair-row:hover > td {
    background: var(--color-surface-muted);
}

tr.recurring-purchase-row {
    cursor: pointer;
}

tr.recurring-purchase-row:hover > td {
    background: var(--color-surface-muted);
}

tr.supplier-purchase-row {
    cursor: pointer;
}

tr.supplier-purchase-row:hover > td {
    background: var(--color-surface-muted);
}

tr.settings-entity-row {
    cursor: pointer;
}

tr.settings-entity-row:hover > td {
    background: var(--color-surface-muted);
}

tr.shipment-row {
    cursor: pointer;
}

tr.shipment-row:hover > td {
    background: var(--color-surface-muted);
}


tr.purchase-item-row {
    cursor: pointer;
}

tr.purchase-item-row:hover > td {
    background: var(--color-surface-muted);
}

[id^="purchase-item-"] {
    scroll-margin-top: var(--spacing-xl);
}

tr.purchase-item-anchor:target > td {
    background: var(--color-primary-subtle);
}

/* Поставщик: доля позиции в отправках со склада (не «подготовка») */
.supplier-shipped-meter {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-xs);
    min-width: 9rem;
    max-width: 14rem;
}

.supplier-shipped-meter--compact {
    min-width: 7rem;
    max-width: 11rem;
    margin-top: var(--spacing-xs);
}

.supplier-shipped-meter__track {
    height: 8px;
    border-radius: var(--radius-full);
    background: var(--color-surface-muted);
    border: 1px solid var(--color-border);
    overflow: hidden;
}

.supplier-shipped-meter--compact .supplier-shipped-meter__track {
    height: 6px;
}

.supplier-shipped-meter__fill {
    display: block;
    height: 100%;
    border-radius: var(--radius-full);
    transition: width var(--transition-base), background-color var(--transition-base);
}

.supplier-shipped-meter__fill--empty {
    width: 0 !important;
    min-width: 0;
}

.supplier-shipped-meter__fill--partial {
    background: linear-gradient(90deg, var(--color-warning) 0%, #e8940a 100%);
}

.supplier-shipped-meter__fill--complete {
    background: linear-gradient(90deg, var(--color-success) 0%, var(--color-success-hover) 100%);
}

.supplier-shipped-meter__text {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 0.15rem 0.35rem;
    font-size: var(--font-size-xs);
    color: var(--color-text-secondary);
    line-height: var(--line-height-tight);
}

.supplier-shipped-meter__k {
    color: var(--color-text-tertiary);
    font-weight: 500;
}

.supplier-shipped-meter__sep {
    color: var(--color-border-strong);
    font-weight: 400;
}

.purchase-qty-cell .supplier-shipped-meter {
    max-width: none;
}

.shipment-item-open-purchase {
    cursor: pointer;
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.shipment-item-open-purchase:hover {
    box-shadow: var(--shadow-sm);
}

.table-actions-header {
    text-align: right;
}

/* Recurring Purchases Specific Rows */
.recurring-row-inactive {
    opacity: 0.6;
}

.recurring-row-inactive:hover {
    opacity: 0.8;
}

/* Archive Specific Rows */
.archive-row {
    opacity: 0.85;
}

.archive-row:hover {
    opacity: 1;
}

/* Purchase ID */
.purchase-id {
    display: inline-flex;
    font-weight: 600;
    color: var(--color-primary);
    font-family: 'SF Mono', Monaco, 'Cascadia Code', monospace;
    font-size: var(--font-size-sm);
}

/* Recurring Name & Description */
.recurring-name {
    font-weight: 500;
    color: var(--color-text-primary);
    margin-bottom: 2px;
}

.recurring-description {
    font-size: var(--font-size-xs);
    color: var(--color-text-tertiary);
    margin-top: 4px;
    line-height: 1.4;
}

/* Company List */
.company-list {
    font-size: var(--font-size-sm);
    color: var(--color-text-secondary);
}

/* Office Badge */
.office-badge {
    display: inline-flex;
    align-items: center;
    gap: var(--spacing-xs);
    padding: var(--spacing-xs) var(--spacing-sm);
    background: var(--color-primary-subtle);
    border-radius: var(--radius-md);
    font-size: var(--font-size-xs);
    color: var(--color-primary);
    font-weight: 500;
}

.office-badge svg {
    width: 14px;
    height: 14px;
    flex-shrink: 0;
}

/* Frequency Info */
.frequency-info {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.frequency-main {
    font-weight: 500;
    color: var(--color-text-primary);
    font-size: var(--font-size-sm);
}

.frequency-detail {
    font-size: var(--font-size-xs);
    color: var(--color-text-tertiary);
}

/* Date Badges */
.date-badge {
    display: inline-flex;
    padding: var(--spacing-xs) var(--spacing-sm);
    background: var(--color-surface-muted);
    border-radius: var(--radius-sm);
    font-size: var(--font-size-xs);
    font-family: 'SF Mono', Monaco, 'Cascadia Code', monospace;
    color: var(--color-text-secondary);
    font-weight: 500;
}

.date-badge-next {
    background: var(--color-primary-subtle);
    color: var(--color-primary);
}

/* Expiry Info (Archive) */
.expiry-info {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-xs);
}

.expiry-badge {
    display: inline-flex;
    padding: var(--spacing-xs) var(--spacing-sm);
    background: var(--color-danger-light);
    border-radius: var(--radius-sm);
    font-size: var(--font-size-xs);
    font-family: 'SF Mono', Monaco, 'Cascadia Code', monospace;
    color: var(--color-danger);
    font-weight: 500;
}

.expiry-hint {
    font-size: var(--font-size-xs);
    color: var(--color-text-tertiary);
    font-style: italic;
}

.expiry-hint.expiry-overdue {
    color: var(--color-danger);
    font-weight: 600;
    font-style: normal;
}

/* User Info */
.user-info {
    font-size: var(--font-size-sm);
    color: var(--color-text-secondary);
}

/* Modern Status Badge */
.modern-status-badge {
    display: inline-flex;
    align-items: center;
    gap: var(--spacing-xs);
    padding: 6px 12px;
    border-radius: var(--radius-full);
    font-size: var(--font-size-xs);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    transition: all var(--transition-base);
}

.modern-status-badge svg {
    width: 12px;
    height: 12px;
    flex-shrink: 0;
}

.status-active {
    background: var(--color-success-light);
    color: var(--color-success);
}

.status-active svg {
    fill: var(--color-success);
}

.status-inactive {
    background: var(--color-surface-muted);
    color: var(--color-text-tertiary);
}

.status-inactive svg {
    fill: var(--color-text-tertiary);
}

/* Action Icon Buttons */
.action-icon-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    padding: 0;
    border: 1px solid var(--color-border);
    background: var(--color-surface);
    color: var(--color-text-secondary);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all var(--transition-base);
    position: relative;
}

.action-icon-button:hover {
    transform: translateY(-1px);
    box-shadow: var(--shadow-sm);
}

.action-icon-button:active {
    transform: translateY(0);
}

.action-icon-button:focus-visible {
    outline: 2px solid var(--color-primary);
    outline-offset: 2px;
}

.action-icon-button svg {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
}

/* Action Button Variants */
.action-success {
    color: var(--color-success);
    border-color: var(--color-success-light);
    background: var(--color-success-light);
}

.action-success:hover {
    background: var(--color-success);
    border-color: var(--color-success);
    color: var(--color-text-inverse);
}

.action-pause {
    color: var(--color-warning);
    border-color: var(--color-warning-light);
    background: var(--color-warning-light);
}

.action-pause:hover {
    background: var(--color-warning);
    border-color: var(--color-warning);
    color: var(--color-text-inverse);
}

.action-play {
    color: var(--color-success);
    border-color: var(--color-success-light);
    background: var(--color-success-light);
}

.action-play:hover {
    background: var(--color-success);
    border-color: var(--color-success);
    color: var(--color-text-inverse);
}

.action-delete {
    color: var(--color-danger);
    border-color: var(--color-danger-light);
    background: var(--color-danger-light);
}

.action-delete:hover {
    background: var(--color-danger);
    border-color: var(--color-danger);
    color: var(--color-text-inverse);
}

/* Responsive Adjustments for Subtabs */
@media (max-width: 1024px) {
    .modern-table {
        font-size: var(--font-size-xs);
    }
    
    .modern-table th,
    .modern-table td {
        padding: var(--spacing-sm) var(--spacing-md);
    }
    
    .page-header-with-tabs {
        flex-direction: column;
        align-items: flex-start;
    }
    
    .page-actions {
        width: 100%;
        justify-content: flex-start;
    }
    
    /* Modal optimizations for smaller laptops */
    .modal-dialog {
        max-width: 90vw;
    }
    
    .modal-dialog-lg {
        max-width: 95vw;
    }
    
    .modal-header {
        padding: var(--spacing-lg) var(--spacing-lg) var(--spacing-md);
    }
    
    .modal-body-inner {
        padding: var(--spacing-lg);
    }
    
    .form-actions-modal {
        padding: var(--spacing-md) var(--spacing-lg);
    }
}

@media (max-width: 768px) {
    .table-container {
        overflow-x: auto;
    }
    
    .modern-table {
        min-width: 900px;
    }
    
    .table-actions-group {
        flex-wrap: wrap;
    }
    
    .info-banner {
        flex-direction: column;
        gap: var(--spacing-sm);
    }
    
    .page-tabs {
        overflow-x: auto;
        scrollbar-width: none;
        -webkit-overflow-scrolling: touch;
    }
    
    .page-tabs::-webkit-scrollbar {
        display: none;
    }
    
    .page-tab {
        font-size: var(--font-size-xs);
        padding: var(--spacing-xs) var(--spacing-sm);
    }
    
    .page-title-section h2 {
        font-size: var(--font-size-xl);
    }
    
    /* Modal responsive for mobile */
    .modal-dialog-lg,
    .modal-dialog {
        max-width: 100%;
        max-height: 95vh;
        margin: var(--spacing-xs);
    }
    
    .modal-body-inner {
        padding: var(--spacing-md);
    }
    
    .modal-header {
        padding: var(--spacing-md);
    }
    
    .modal-footer,
    .form-actions-modal {
        padding: var(--spacing-md);
        flex-direction: column;
        gap: var(--spacing-sm);
    }
    
    .modal-footer .btn-primary,
    .modal-footer .btn-secondary,
    .form-actions-modal .btn-primary,
    .form-actions-modal .btn-secondary {
        width: 100%;
    }
    
    .modern-checkbox-modal {
        padding: var(--spacing-sm) var(--spacing-md);
    }
    
    .modal-title {
        font-size: var(--font-size-lg);
    }
    
    .form-section-modal {
        gap: var(--spacing-sm);
    }
}

/* ============================================
   MODERN MODAL STYLES
   ============================================ */

/* Modal Overlay & Container */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: var(--spacing-lg);
    opacity: 0;
    transition: opacity 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    overflow-y: auto;
}

.modal-overlay.modal-open {
    opacity: 1;
}

.modal-dialog {
    background: var(--color-surface);
    border-radius: var(--radius-2xl);
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    max-width: 600px;
    width: 100%;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    transform: scale(0.9) translateY(20px);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    overflow: hidden; /* Чтобы контент не вылезал за скругления */
}

.modal-form {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0; /* Важно для flex-контейнеров с прокруткой */
}

.modal-open .modal-dialog {
    transform: scale(1) translateY(0);
}

.modal-dialog-lg {
    max-width: 800px;
}

.modal-dialog-md {
    max-width: 560px;
}

/* Modal Header */
.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--spacing-xl) var(--spacing-xl) var(--spacing-lg);
    border-bottom: 1px solid var(--color-border);
    flex-shrink: 0;
}

.modal-header-content {
    display: flex;
    align-items: center;
    gap: var(--spacing-md);
    flex: 1;
}

.modal-icon {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--color-primary-subtle);
    border-radius: var(--radius-lg);
    color: var(--color-primary);
    flex-shrink: 0;
}

.modal-icon svg {
    width: 20px;
    height: 20px;
    stroke-width: 2;
}

.modal-title {
    font-size: var(--font-size-xl);
    font-weight: 600;
    color: var(--color-text-primary);
    margin: 0;
}

.modal-close-btn {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    border-radius: var(--radius-md);
    color: var(--color-text-secondary);
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    flex-shrink: 0;
}

.modal-close-btn:hover {
    background: var(--color-surface-muted);
    color: var(--color-text-primary);
    transform: rotate(90deg);
}

/* Modal Body */
.modal-body {
    padding: 0;
    overflow: hidden;
    flex: 1;
    display: flex;
    flex-direction: column;
}

.modal-body-inner {
    flex: 1;
    overflow-y: auto;
    padding: var(--spacing-xl);
}

.modal-body-inner::-webkit-scrollbar {
    width: 6px;
}

.modal-body-inner::-webkit-scrollbar-track {
    background: var(--color-surface-muted);
    border-radius: var(--radius-full);
}

.modal-body-inner::-webkit-scrollbar-thumb {
    background: var(--color-border-medium);
    border-radius: var(--radius-full);
}

.modal-body-inner::-webkit-scrollbar-thumb:hover {
    background: var(--color-border-strong);
}

/* Form Actions Modal - закрепленные кнопки */
.form-actions-modal {
    display: flex;
    gap: var(--spacing-md);
    padding: var(--spacing-lg) var(--spacing-xl);
    border-top: 1px solid var(--color-border);
    background: var(--color-surface);
    flex-shrink: 0;
}

.form-actions-modal .btn-secondary,
.form-actions-modal .btn-primary {
    flex: 1;
}

/* Form Label Required */
.label-required {
    color: var(--color-danger);
    margin-left: 2px;
}

/* Modal Footer */
.modal-footer {
    display: flex;
    gap: var(--spacing-md);
    padding: var(--spacing-lg) var(--spacing-xl) var(--spacing-xl);
    border-top: 1px solid var(--color-border);
    background: var(--color-surface-muted);
    flex-shrink: 0;
}

.modal-footer .btn-secondary,
.modal-footer .btn-primary {
    flex: 1;
}

/* Modal Form Sections */
.form-section-modal {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-md);
}

.form-section-header-modal {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    margin-bottom: var(--spacing-sm);
}

.form-section-header-modal svg {
    width: 16px;
    height: 16px;
    color: var(--color-primary);
    flex-shrink: 0;
}

.form-section-title-modal {
    font-size: var(--font-size-base);
    font-weight: 600;
    color: var(--color-text-primary);
    margin: 0;
}

/* Modern Checkbox for Modal */
.modern-checkbox-group-modal {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-sm);
}

.modern-checkbox-modal {
    display: flex;
    align-items: flex-start;
    gap: var(--spacing-md);
    padding: var(--spacing-md) var(--spacing-lg);
    border-radius: var(--radius-lg);
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    border: 1.5px solid var(--color-border);
    background: var(--color-surface);
}

.modern-checkbox-modal:hover {
    background: var(--color-surface-muted);
    border-color: var(--color-primary);
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.modern-checkbox-input-modal {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}

.modern-checkbox-box-modal {
    position: relative;
    width: 22px;
    height: 22px;
    min-width: 22px;
    border: 2px solid var(--color-border-medium);
    border-radius: var(--radius-md);
    background: var(--color-surface);
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    align-items: center;
    justify-content: center;
    margin-top: 2px;
}

.modern-checkbox-check-modal {
    opacity: 0;
    transform: scale(0.5);
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    color: var(--color-surface);
}

.modern-checkbox-input-modal:checked ~ .modern-checkbox-box-modal {
    background: var(--color-primary);
    border-color: var(--color-primary);
    transform: scale(1.05);
}

.modern-checkbox-input-modal:checked ~ .modern-checkbox-box-modal .modern-checkbox-check-modal {
    opacity: 1;
    transform: scale(1);
}

.modern-checkbox-modal:hover .modern-checkbox-box-modal {
    border-color: var(--color-primary);
    box-shadow: 0 0 0 4px var(--color-primary-subtle);
}

.modern-checkbox-input-modal:focus ~ .modern-checkbox-box-modal {
    outline: 2px solid var(--color-primary);
    outline-offset: 2px;
}

.modern-checkbox-label-modal {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: var(--spacing-xs);
}

.modern-checkbox-title-modal {
    font-size: var(--font-size-sm);
    font-weight: 600;
    color: var(--color-text-primary);
    line-height: 1.4;
}

.modern-checkbox-description-modal {
    font-size: var(--font-size-xs);
    color: var(--color-text-secondary);
    line-height: 1.5;
}

/* Modal Form Styling */
.modal-form .form-textarea {
    width: 100%;
    padding: 0.875rem 1rem;
    font-size: var(--font-size-sm);
    font-family: var(--font-family);
    color: var(--color-text-primary);
    background: var(--color-surface);
    border: 1.5px solid var(--color-border);
    border-radius: var(--radius-lg);
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    outline: none;
    resize: vertical;
    min-height: 80px;
    line-height: 1.6;
}

.modal-form .form-textarea:hover {
    border-color: var(--color-border-medium);
}

.modal-form .form-textarea:focus {
    border-color: var(--color-primary);
    box-shadow: 0 0 0 4px var(--color-primary-subtle);
}

.modal-form .form-input {
    padding: 0.875rem 1rem;
    font-size: var(--font-size-sm);
    border: 1.5px solid var(--color-border);
    border-radius: var(--radius-lg);
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.modal-form .form-input:focus {
    border-color: var(--color-primary);
    box-shadow: 0 0 0 4px var(--color-primary-subtle);
}

.modal-form .form-select {
    padding: 0.875rem 2.75rem 0.875rem 1rem;
    border: 1.5px solid var(--color-border);
    border-radius: var(--radius-lg);
}

.modal-form .form-select:hover {
    background-color: var(--color-surface-muted);
}

/* Form Divider */
.form-divider {
    height: 1px;
    background: linear-gradient(90deg, transparent, var(--color-border) 50%, transparent);
    margin: var(--spacing-xl) 0;
}

/* Modal Animations */
@keyframes fadeInContent {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.modal-open .modal-body > * {
    animation: fadeInContent 0.4s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

.modal-open .modal-body > *:nth-child(1) { animation-delay: 0.05s; }
.modal-open .modal-body > *:nth-child(2) { animation-delay: 0.1s; }
.modal-open .modal-body > *:nth-child(3) { animation-delay: 0.15s; }
.modal-open .modal-body > *:nth-child(4) { animation-delay: 0.2s; }
.modal-open .modal-body > *:nth-child(5) { animation-delay: 0.25s; }

/* Loading Indicator */
.loading-indicator {
    display: flex;
    align-items: center;
    gap: var(--spacing-md);
    padding: var(--spacing-lg) var(--spacing-xl);
    background: linear-gradient(135deg, var(--color-info-subtle) 0%, rgba(91, 95, 199, 0.05) 100%);
    border: 1.5px solid var(--color-info-light);
    border-radius: var(--radius-lg);
    color: var(--color-info);
    font-size: var(--font-size-sm);
    font-weight: 500;
    box-shadow: 0 2px 8px rgba(91, 95, 199, 0.1);
}

.loading-spinner {
    width: 20px;
    height: 20px;
    border: 3px solid var(--color-info-light);
    border-top-color: var(--color-primary);
    border-radius: 50%;
    animation: spinLoader 0.8s linear infinite;
}

@keyframes spinLoader {
    to {
        transform: rotate(360deg);
    }
}

/* Modal Responsive */
@media (max-width: 768px) {
    .modal-dialog-lg,
    .modal-dialog {
        max-width: 100%;
        max-height: 95vh;
        margin: var(--spacing-xs);
    }
    
    .modal-body-inner {
        padding: var(--spacing-md);
    }
    
    .modal-header {
        padding: var(--spacing-md);
    }
    
    .modal-footer,
    .form-actions-modal {
        padding: var(--spacing-md);
        flex-direction: column;
        gap: var(--spacing-sm);
    }
    
    .modal-footer .btn-primary,
    .modal-footer .btn-secondary,
    .form-actions-modal .btn-primary,
    .form-actions-modal .btn-secondary {
        width: 100%;
    }
    
    .modern-checkbox-modal {
        padding: var(--spacing-sm) var(--spacing-md);
    }
    
    .modal-title {
        font-size: var(--font-size-lg);
    }
}

/* ============================================
   SNIPE-IT COMPANY MAPPING STYLES
   ============================================ */

/* Connection Actions */
.snipeit-connection-actions {
    display: flex;
    gap: var(--spacing-md);
    margin-top: var(--spacing-md);
    align-items: center;
    flex-wrap: wrap;
}

.snipeit-connection-actions .btn-sm {
    padding: 0.625rem 1.25rem;
    font-size: var(--font-size-sm);
}

/* Badge count indicator */
.badge-count {
    display: inline-flex;
    align-items: center;
    padding: 0.5rem 1rem;
    background: var(--color-surface-muted);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-full);
    font-size: var(--font-size-sm);
    font-weight: 600;
    color: var(--color-text-secondary);
}

/* Inline hint with icon */
.form-hint-inline {
    display: inline-flex;
    align-items: center;
    gap: var(--spacing-xs);
    color: var(--color-text-tertiary);
    font-size: var(--font-size-xs);
    font-style: normal;
}

.form-hint-inline svg {
    width: 14px;
    height: 14px;
    flex-shrink: 0;
}

/* Success flash animation for button */
.btn-success-flash {
    animation: successFlash 0.6s ease-out;
}

@keyframes successFlash {
    0% {
        background-color: var(--color-success);
        color: white;
        transform: scale(1);
    }
    50% {
        transform: scale(1.02);
    }
    100% {
        transform: scale(1);
    }
}

/* Spinner animation for loading states */
.spinner {
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* Company select wrapper */
.snipeit-company-wrapper {
    position: relative;
}

/* Company select in Snipe-IT section uses .form-select globally */

/* Loading Indicator for Company Selection */
#snipeit_companies_loading {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    padding: var(--spacing-md);
    margin-top: var(--spacing-md);
    background: var(--color-info-subtle);
    border: 1px solid var(--color-info-light);
    border-radius: var(--radius-lg);
    color: var(--color-text-secondary);
    font-size: var(--font-size-sm);
}

#snipeit_companies_loading .loading-spinner {
    width: 16px;
    height: 16px;
    border-width: 2px;
}

/* ============================================
   DELIVERY RESPONSES CARD
   Modern design for delivery request responses
   ============================================ */

.delivery-responses-card {
    background: var(--color-surface, #ffffff);
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    margin-bottom: 2rem;
    overflow: hidden;
}

.delivery-responses-card .card-header {
    padding: 1.5rem;
    background: linear-gradient(135deg, #ecfdf5 0%, #d1fae5 100%);
    border-bottom: 1px solid #a7f3d0;
}

.delivery-responses-card .header-content {
    display: flex;
    align-items: flex-start;
    gap: 1rem;
}

.delivery-responses-card .icon-wrapper {
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #ffffff;
    border-radius: 12px;
    flex-shrink: 0;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.delivery-responses-card .icon-wrapper.success svg {
    stroke: #059669;
}

.delivery-responses-card .header-text h3 {
    margin: 0 0 0.25rem 0;
    font-size: 1.25rem;
    font-weight: 600;
    color: #065f46;
}

.delivery-responses-card .header-text .subtitle {
    margin: 0;
    font-size: 0.9375rem;
    color: #047857;
    font-weight: 500;
}

.delivery-responses-card .responses-list {
    padding: 0;
}

.delivery-responses-card .response-item {
    display: flex;
    align-items: flex-start;
    gap: 1rem;
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid #f3f4f6;
    transition: background-color 150ms ease;
}

.delivery-responses-card .response-item:last-child {
    border-bottom: none;
}

.delivery-responses-card .response-item:hover {
    background: #f9fafb;
}

.delivery-responses-card .response-content {
    flex: 1;
    min-width: 0;
}

.delivery-responses-card .response-header {
    display: flex;
    justify-content: space-between;
    align-items: start;
    gap: 1rem;
    margin-bottom: 0.75rem;
}

.delivery-responses-card .item-name-link {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.delivery-responses-card .item-name-link svg {
    flex-shrink: 0;
    color: #6b7280;
}

.delivery-responses-card .item-name {
    font-size: 1rem;
    font-weight: 600;
    color: #111827;
    text-decoration: none;
    transition: color 150ms ease;
}

.delivery-responses-card .item-name:hover {
    color: #0091ff;
}

.delivery-responses-card .response-meta {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-shrink: 0;
}

.delivery-responses-card .response-date {
    font-size: 0.8125rem;
    color: #9ca3af;
    font-weight: 500;
    white-space: nowrap;
}

.delivery-responses-card .response-message {
    margin-bottom: 0.75rem;
}

.delivery-responses-card .response-message p {
    margin: 0;
    font-size: 0.9375rem;
    line-height: 1.6;
    color: #4b5563;
}

.delivery-responses-card .response-footer {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.delivery-responses-card .estimated-date {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.375rem 0.875rem;
    background: #dbeafe;
    border-radius: 6px;
    font-size: 0.8125rem;
    font-weight: 500;
    color: #1e40af;
}

.delivery-responses-card .estimated-date svg {
    flex-shrink: 0;
}

.delivery-responses-card .response-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-shrink: 0;
}

.delivery-responses-card .icon-button-dismiss {
    color: var(--color-text-primary);
    border-color: var(--color-border);
    background: var(--color-surface);
}

.delivery-responses-card .icon-button-dismiss svg {
    color: var(--color-text-primary);
    transition: color 150ms ease;
}

.delivery-responses-card .icon-button-dismiss:hover {
    background: var(--color-danger);
    color: var(--color-text-inverse);
    border-color: var(--color-danger);
    transform: translateY(-1px);
    box-shadow: 0 2px 4px 0 rgba(229, 72, 77, 0.2);
}

.delivery-responses-card .icon-button-dismiss:hover svg {
    color: var(--color-text-inverse);
}

.delivery-responses-card .show-more-hint {
    padding: 1rem 1.5rem;
    text-align: center;
    font-size: 0.875rem;
    color: #6b7280;
    background: #f9fafb;
    border-top: 1px solid #f3f4f6;
    font-weight: 500;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .delivery-responses-card .response-item {
        flex-direction: column;
        gap: 0.75rem;
    }
    
    .delivery-responses-card .response-actions {
        align-self: flex-end;
    }
    
    .delivery-responses-card .response-header {
        flex-direction: column;
        gap: 0.5rem;
    }
    
    .delivery-responses-card .response-meta {
        align-self: flex-start;
    }
}

/* ============================================
   Custom select — единый стиль с формами закупок
   (div.custom-select + скрытый input; не нативный <select>)
   ============================================ */

.custom-select {
    position: relative;
    width: 100%;
}

.custom-select-trigger {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--spacing-md);
    padding: 0.75rem 1rem;
    background: var(--color-surface);
    border: 1.5px solid var(--color-border);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: border-color var(--transition-base), box-shadow var(--transition-base);
    user-select: none;
    min-height: 46px;
    line-height: 1.45;
    box-sizing: border-box;
}

.custom-select-trigger:hover {
    border-color: var(--color-border-medium);
}

.custom-select.active .custom-select-trigger {
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px var(--color-primary-subtle);
}

.custom-select-placeholder {
    font-size: var(--font-size-sm);
    line-height: 1.45;
    color: var(--color-text-tertiary);
    flex: 1;
    text-align: left;
}

.custom-select-placeholder.selected {
    color: var(--color-text-primary);
    font-weight: 500;
}

.custom-select-arrow {
    width: 20px;
    height: 20px;
    color: var(--color-text-secondary);
    transition: transform var(--transition-base);
    flex-shrink: 0;
}

.custom-select.active .custom-select-arrow {
    transform: rotate(180deg);
}

.custom-select-dropdown {
    list-style: none;
    margin: 0;
    padding: 0;
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    right: 0;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    z-index: 1000;
    max-height: 280px;
    overflow-y: auto;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-8px);
    transition: opacity var(--transition-base), visibility var(--transition-base), transform var(--transition-base);
}

.custom-select.active .custom-select-dropdown {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.custom-select-option {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    padding: 0.75rem 1rem;
    min-height: 44px;
    line-height: 1.45;
    cursor: pointer;
    transition: background-color var(--transition-fast);
    border-bottom: 1px solid var(--color-border);
    position: relative;
}

.custom-select-option:last-child {
    border-bottom: none;
}

.custom-select-option:hover {
    background: var(--color-surface-muted);
}

.custom-select-option.selected {
    background: var(--color-primary-subtle);
}

.custom-select-option.last-used-office::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 3px;
    background: linear-gradient(180deg, var(--color-primary), var(--color-primary-light, var(--color-primary)));
    border-radius: 0 2px 2px 0;
}

.custom-select-option.last-used-office {
    padding-left: calc(1rem + 6px);
}

.custom-select-option.last-used-office .office-name::after {
    content: 'Недавний';
    display: inline-flex;
    margin-left: var(--spacing-sm);
    padding: 2px 6px;
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    background: var(--color-primary);
    color: white;
    border-radius: 3px;
    line-height: 1;
}

.office-icon {
    width: 18px;
    height: 18px;
    color: var(--color-text-secondary);
    flex-shrink: 0;
    transition: color var(--transition-base);
}

.custom-select-option.selected .office-icon {
    color: var(--color-primary);
}

.office-name {
    flex: 1;
    font-size: var(--font-size-sm);
    color: var(--color-text-primary);
    transition: font-weight var(--transition-base), color var(--transition-base);
}

.custom-select-option.selected .office-name {
    font-weight: 600;
    color: var(--color-primary);
}

.priority-label {
    flex: 1;
    font-size: var(--font-size-sm);
    color: var(--color-text-primary);
    transition: font-weight var(--transition-base), color var(--transition-base);
}

.custom-select-option.selected .priority-label {
    font-weight: 600;
    color: var(--color-primary);
}

.office-check-icon {
    width: 18px;
    height: 18px;
    color: var(--color-primary);
    opacity: 0;
    transform: scale(0.8);
    transition: opacity var(--transition-base), transform var(--transition-base);
    flex-shrink: 0;
}

.custom-select-option.selected .office-check-icon {
    opacity: 1;
    transform: scale(1);
}

.custom-select-dropdown::-webkit-scrollbar {
    width: 8px;
}

.custom-select-dropdown::-webkit-scrollbar-track {
    background: var(--color-surface-muted);
    border-radius: 4px;
}

.custom-select-dropdown::-webkit-scrollbar-thumb {
    background: var(--color-border-medium);
    border-radius: 4px;
}

.custom-select-dropdown::-webkit-scrollbar-thumb:hover {
    background: var(--color-border-strong);
}

@media (prefers-reduced-motion: reduce) {
    .custom-select-arrow,
    .custom-select-dropdown,
    .custom-select-option,
    .office-check-icon {
        transition: none;
    }

    .custom-select.active .custom-select-dropdown {
        transform: translateY(0);
    }
}

/* --------------------------------------------------------------------------
   Logs page — выгрузки (ZIP / Excel) и фильтр журнала
   -------------------------------------------------------------------------- */

.card-header.logs-page-toolbar {
    flex-direction: column;
    align-items: stretch;
    gap: var(--spacing-lg);
}

.logs-exports-layout {
    display: grid;
    grid-template-columns: 1fr;
    gap: var(--spacing-md);
    width: 100%;
}

@media (min-width: 900px) {
    .logs-exports-layout {
        grid-template-columns: minmax(240px, 320px) minmax(0, 1fr);
        gap: var(--spacing-lg);
        align-items: stretch;
    }
}

.logs-export-tile {
    position: relative;
    display: flex;
    gap: var(--spacing-md);
    padding: var(--spacing-lg);
    border-radius: var(--radius-lg);
    border: 1px solid var(--color-border);
    background: var(--color-surface-muted);
    box-shadow: var(--shadow-xs);
    transition:
        border-color var(--transition-base),
        box-shadow var(--transition-base),
        background-color var(--transition-base);
}

@media (prefers-reduced-motion: reduce) {
    .logs-export-tile {
        transition: none;
    }
}

.logs-export-tile:hover {
    border-color: var(--color-border-medium);
    box-shadow: var(--shadow-sm);
}

.logs-export-tile--archive {
    flex-direction: row;
    align-items: flex-start;
}

.logs-export-tile--excel {
    flex-direction: column;
    padding-left: calc(var(--spacing-lg) + 6px);
    overflow: visible;
    background: linear-gradient(
        135deg,
        var(--color-surface) 0%,
        var(--color-primary-subtle) 100%
    );
    border-color: var(--color-border-medium);
    box-shadow: var(--shadow-sm);
}

.logs-export-tile--excel::before {
    content: "";
    position: absolute;
    left: 0;
    top: var(--spacing-md);
    bottom: var(--spacing-md);
    width: 4px;
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
    background: linear-gradient(
        180deg,
        var(--color-primary),
        var(--color-primary-hover)
    );
    pointer-events: none;
}

.logs-export-tile__visual {
    flex-shrink: 0;
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-md);
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    color: var(--color-text-secondary);
}

.logs-export-tile__visual--accent {
    background: var(--color-primary-subtle);
    border-color: var(--color-primary-light);
    color: var(--color-primary);
}

.logs-export-tile__visual-icon {
    flex-shrink: 0;
}

.logs-export-tile__body {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: var(--spacing-xs);
}

.logs-export-tile__head {
    display: flex;
    gap: var(--spacing-md);
    align-items: flex-start;
}

.logs-export-tile__head-text {
    flex: 1;
    min-width: 0;
}

.logs-export-tile__eyebrow {
    display: block;
    font-size: var(--font-size-xs);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--color-text-tertiary);
    margin-bottom: 2px;
}

.logs-export-tile__title {
    font-size: var(--font-size-base);
    font-weight: 600;
    color: var(--color-text-primary);
    margin: 0;
    line-height: var(--line-height-tight);
}

.logs-export-tile__text {
    margin: 0;
    font-size: var(--font-size-sm);
    color: var(--color-text-secondary);
    line-height: var(--line-height-relaxed);
    max-width: 52ch;
}

.logs-export-tile__action {
    margin-top: var(--spacing-sm);
    align-self: flex-start;
    display: inline-flex;
    align-items: center;
    gap: var(--spacing-sm);
}

.logs-excel-form {
    width: 100%;
}

.logs-excel-form__grid {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-lg);
    margin-top: var(--spacing-md);
}

.logs-excel-fieldset {
    margin: 0;
    padding: 0;
    border: none;
    min-width: 0;
}

.logs-excel-legend {
    float: left;
    width: 100%;
    padding: 0;
    margin: 0 0 var(--spacing-sm);
    font-size: var(--font-size-xs);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--color-text-tertiary);
}

.logs-excel-fields-row {
    display: grid;
    grid-template-columns: 1fr;
    gap: var(--spacing-md);
    clear: left;
}

@media (min-width: 640px) {
    .logs-excel-fields-row {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (min-width: 960px) {
    .logs-excel-fields-row {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }

    .logs-excel-fields-row--period {
        grid-template-columns: minmax(0, 220px) minmax(0, 1fr);
    }
}

.logs-excel-form .form-group {
    margin-bottom: 0;
}

.logs-excel-form .form-label {
    margin-bottom: var(--spacing-xs);
    font-size: var(--font-size-xs);
    font-weight: 600;
    color: var(--color-text-secondary);
}

.logs-excel-field--full {
    grid-column: 1 / -1;
}

/* Отключённый кастомный селект (статус при «только доставленные») */
.custom-select-wrapper.custom-select-wrapper--disabled {
    opacity: 0.72;
}

.custom-select-wrapper.custom-select-wrapper--disabled .custom-select-trigger {
    cursor: not-allowed;
    pointer-events: none;
}

.logs-excel-form .form-hint {
    margin-top: var(--spacing-xs);
    font-style: normal;
    line-height: var(--line-height-normal);
}

.logs-excel-date-range .date-range {
    margin-top: 2px;
}

.logs-excel-fieldset--search .search-input-wrapper {
    margin-top: 2px;
}

.logs-excel-fieldset--search input[type="search"] {
    width: 100%;
    min-height: 42px;
    padding: 0.75rem 1rem 0.75rem 2.5rem;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    background-color: var(--color-surface);
    font-family: var(--font-family);
    font-size: var(--font-size-sm);
    transition: border-color var(--transition-base), box-shadow var(--transition-base);
}

.logs-excel-fieldset--search input[type="search"]:hover {
    border-color: var(--color-border-medium);
}

.logs-excel-fieldset--search input[type="search"]:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px var(--color-primary-subtle);
}

.logs-excel-actions {
    margin-top: var(--spacing-lg);
    padding-top: var(--spacing-md);
    border-top: 1px solid var(--color-border);
}

.logs-excel-submit {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--spacing-sm);
    min-width: min(100%, 220px);
    padding: 0.75rem 1.25rem;
    font-weight: 600;
}

.logs-export-footnote {
    margin: var(--spacing-md) 0 0;
    font-size: var(--font-size-xs);
    color: var(--color-text-tertiary);
    line-height: var(--line-height-relaxed);
    max-width: 72ch;
}

.logs-journal-panel {
    padding-top: var(--spacing-md);
    border-top: 1px solid var(--color-border);
}

.logs-journal-panel__title {
    font-size: var(--font-size-sm);
    font-weight: 600;
    color: var(--color-text-primary);
    margin: 0 0 var(--spacing-xs);
}

.logs-journal-panel__subtitle {
    margin: 0 0 var(--spacing-md);
    font-size: var(--font-size-xs);
    color: var(--color-text-tertiary);
    line-height: var(--line-height-normal);
    max-width: 60ch;
}

.logs-page-toolbar .logs-journal-filters.filters-form {
    display: flex;
    flex-wrap: wrap;
    gap: var(--spacing-md);
    align-items: flex-end;
    width: 100%;
}

.logs-page-toolbar .logs-journal-filters .form-group {
    flex: 1;
    min-width: 200px;
    margin-bottom: 0;
}

.logs-page-toolbar .form-actions-inline {
    margin-bottom: 2px;
}

td.text-wrap {
    white-space: pre-wrap;
}

/* Настройки: поля закупок (строгая проверка и JSON-правила) */
.content-section.purchase-field-format-page {
    max-width: min(100%, 1280px);
    margin: 0 auto;
    padding: 0 var(--spacing-lg) var(--spacing-2xl);
}

.settings-section-header.section-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: var(--spacing-lg);
    gap: var(--spacing-lg);
}

.settings-section-header .section-header-content {
    flex: 1;
    min-width: 0;
}

.settings-section-header h3 {
    margin: 0 0 var(--spacing-xs);
    font-size: var(--font-size-xl);
    font-weight: 600;
    color: var(--color-text-primary);
}

.settings-section-header .text-secondary {
    margin: 0;
    font-size: var(--font-size-sm);
    line-height: var(--line-height-relaxed);
    max-width: 65ch;
}

.purchase-format-guide {
    margin-bottom: var(--spacing-xl);
}

.purchase-format-guide .card-header.purchase-format-guide-header {
    flex-direction: column;
    align-items: flex-start;
    gap: var(--spacing-sm);
    border-bottom: 1px solid var(--color-border);
    padding-bottom: var(--spacing-md);
    margin-bottom: var(--spacing-md);
}

.purchase-format-guide-title-wrap {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
}

.purchase-format-guide-icon {
    display: inline-flex;
    color: var(--color-primary);
    flex-shrink: 0;
}

.purchase-format-guide-heading {
    margin: 0;
    font-size: var(--font-size-lg);
    font-weight: 600;
    color: var(--color-text-primary);
}

.purchase-format-guide-lead {
    margin: 0;
    font-size: var(--font-size-sm);
    line-height: var(--line-height-relaxed);
    color: var(--color-text-secondary);
    max-width: 72ch;
}

.purchase-format-guide-body {
    padding-top: 0;
}

.purchase-format-flow {
    margin: 0 0 var(--spacing-xl);
    padding-left: 1.25rem;
    display: flex;
    flex-direction: column;
    gap: var(--spacing-md);
    color: var(--color-text-secondary);
    font-size: var(--font-size-sm);
    line-height: var(--line-height-relaxed);
}

.purchase-format-flow > li::marker {
    color: var(--color-primary);
    font-weight: 600;
}

.purchase-format-flow-title {
    display: block;
    font-weight: 600;
    color: var(--color-text-primary);
    margin-bottom: var(--spacing-xs);
}

.purchase-format-flow-text {
    display: block;
}

.purchase-format-split {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: var(--spacing-xl);
    margin-bottom: var(--spacing-lg);
}

.purchase-format-subheading {
    margin: 0 0 var(--spacing-sm);
    font-size: var(--font-size-base);
    font-weight: 600;
    color: var(--color-text-primary);
}

.purchase-format-panel-hint {
    margin: 0 0 var(--spacing-md);
    font-size: var(--font-size-xs);
    color: var(--color-text-tertiary);
    line-height: var(--line-height-normal);
}

.table-scroll {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    border-radius: var(--radius-md);
    border: 1px solid var(--color-border);
}

.purchase-format-keys-table {
    width: 100%;
    border-collapse: collapse;
    font-size: var(--font-size-sm);
    background: var(--color-surface);
}

.purchase-format-keys-table th,
.purchase-format-keys-table td {
    padding: var(--spacing-sm) var(--spacing-md);
    text-align: left;
    border-bottom: 1px solid var(--color-border);
    vertical-align: top;
}

.purchase-format-keys-table thead th {
    font-size: var(--font-size-xs);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--color-text-tertiary);
    background: var(--color-surface-muted);
}

.purchase-format-keys-table tbody tr:last-child td {
    border-bottom: none;
}

.purchase-format-keys-table tbody tr:hover {
    background: var(--color-surface-muted);
}

.purchase-format-prop-list {
    margin: 0;
}

.purchase-format-prop-row {
    display: grid;
    grid-template-columns: minmax(7rem, auto) 1fr;
    gap: var(--spacing-sm) var(--spacing-md);
    padding: var(--spacing-sm) 0;
    border-bottom: 1px solid var(--color-border);
    font-size: var(--font-size-sm);
    line-height: var(--line-height-relaxed);
}

.purchase-format-prop-row:last-child {
    border-bottom: none;
    padding-bottom: 0;
}

.purchase-format-prop-row dt {
    margin: 0;
    font-weight: 500;
    color: var(--color-text-primary);
}

.purchase-format-prop-row dd {
    margin: 0;
    color: var(--color-text-secondary);
}

@media (max-width: 520px) {
    .purchase-format-prop-row {
        grid-template-columns: 1fr;
    }
}

.purchase-format-details {
    margin: var(--spacing-lg) 0;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    background: var(--color-surface-muted);
    transition: border-color var(--transition-base), box-shadow var(--transition-base);
}

.purchase-format-details[open] {
    border-color: var(--color-border-medium);
    box-shadow: var(--shadow-xs);
}

.purchase-format-details-summary {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--spacing-md);
    cursor: pointer;
    list-style: none;
    padding: var(--spacing-md) var(--spacing-lg);
    font-size: var(--font-size-sm);
    font-weight: 600;
    color: var(--color-text-primary);
    user-select: none;
}

.purchase-format-details-summary::-webkit-details-marker {
    display: none;
}

.purchase-format-details-summary::after {
    content: "";
    flex-shrink: 0;
    width: 0.5rem;
    height: 0.5rem;
    border-right: 2px solid var(--color-text-tertiary);
    border-bottom: 2px solid var(--color-text-tertiary);
    transform: rotate(45deg);
    transition: transform var(--transition-base);
}

.purchase-format-details[open] .purchase-format-details-summary::after {
    transform: rotate(-135deg);
}

.purchase-format-details-body {
    padding: 0 var(--spacing-lg) var(--spacing-md);
    border-top: 1px solid var(--color-border);
    background: var(--color-surface);
    border-radius: 0 0 var(--radius-md) var(--radius-md);
}

.purchase-format-details-list {
    margin: var(--spacing-md) 0 0;
    padding-left: 1.25rem;
    color: var(--color-text-secondary);
    font-size: var(--font-size-sm);
    line-height: var(--line-height-relaxed);
}

.purchase-format-details-list li + li {
    margin-top: var(--spacing-sm);
}

.purchase-format-example {
    margin-top: var(--spacing-lg);
    padding-top: var(--spacing-lg);
    border-top: 1px solid var(--color-border);
}

.purchase-format-json-sample {
    margin: var(--spacing-sm) 0 0;
    padding: var(--spacing-md) var(--spacing-lg);
    font-family: 'SF Mono', 'Monaco', 'Menlo', 'Courier New', monospace;
    font-size: var(--font-size-xs);
    line-height: 1.6;
    white-space: pre-wrap;
    word-break: break-word;
    color: var(--color-text-primary);
    background: var(--color-surface-muted);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    overflow-x: auto;
}

.purchase-field-format-form .form-section:last-of-type {
    margin-bottom: var(--spacing-md);
}

.purchase-field-format-form .checkbox-label {
    flex-direction: row;
    align-items: flex-start;
    gap: var(--spacing-sm);
}

.purchase-field-format-form .checkbox-label input[type="checkbox"] {
    margin-top: 0.2rem;
    flex-shrink: 0;
    width: 18px;
    height: 18px;
    accent-color: var(--color-primary);
    cursor: pointer;
}

.purchase-format-hint-plain {
    font-style: normal;
    color: var(--color-text-secondary);
    max-width: 70ch;
}

.purchase-format-json-input {
    min-height: 200px;
    line-height: 1.5;
}

.form-group-tight-bottom {
    margin-bottom: 0;
}

.purchase-format-rules-toolbar.section-header {
    margin-top: var(--spacing-xl);
}

.purchase-format-rules-toolbar h4 {
    margin: 0;
    font-size: var(--font-size-lg);
    font-weight: 600;
    color: var(--color-text-primary);
}

.purchase-format-rules-table-wrap {
    max-width: 100%;
}

.table-container.purchase-format-rules-table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.table-container .purchase-format-rules-table {
    min-width: 1120px;
}

/* Доли колонок в сумме 100% — без смешения rem и %, иначе fixed-layout сжимает ячейки */
.purchase-format-rules-table .col-drag {
    width: 3%;
}

.purchase-format-rules-table .col-field {
    width: 15%;
}

.purchase-format-rules-table .col-pattern {
    width: 27%;
    max-width: 0;
}

.purchase-format-rules-table .col-length {
    width: 8%;
}

.purchase-format-rules-table .col-message {
    width: 21%;
    word-break: normal;
    overflow-wrap: break-word;
}

.purchase-format-rules-table .col-empty {
    width: 8%;
    text-align: center;
}

.purchase-format-rules-table .col-status {
    width: 9%;
}

.purchase-format-rules-table .col-actions {
    width: 9%;
    text-align: right;
}

.purchase-format-rules-table thead th {
    vertical-align: bottom;
    line-height: 1.35;
    hyphens: manual;
}

.purchase-format-rules-table th.col-empty,
.purchase-format-rules-table th.col-actions {
    text-align: center;
}

.purchase-format-rules-table th.col-actions {
    text-align: right;
}

.purchase-format-rules-table .col-length,
.purchase-format-rules-table .col-empty,
.purchase-format-rules-table .col-status,
.purchase-format-rules-table .col-actions {
    white-space: nowrap;
    word-break: normal;
    overflow-wrap: normal;
}

.purchase-format-rules-table .col-field {
    word-break: normal;
    overflow-wrap: break-word;
}

.purchase-format-rules-table .col-pattern.table-cell-mono-wrap {
    vertical-align: top;
}

.purchase-format-rules-table .purchase-format-rule-pattern-text {
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 4;
    line-clamp: 4;
    overflow: hidden;
    max-height: 5.5em;
    word-break: break-all;
    overflow-wrap: anywhere;
}

.purchase-format-rules-table .cell-drag {
    color: var(--color-text-tertiary);
    cursor: grab;
    vertical-align: top;
}

.purchase-format-rules-table .col-field,
.purchase-format-rules-table .col-status,
.purchase-format-rules-table .col-actions,
.purchase-format-rules-table .cell-empty {
    vertical-align: top;
}

.purchase-format-rules-table .cell-empty {
    text-align: center;
}

.purchase-format-rules-toolbar .section-actions .btn-primary {
    display: inline-flex;
    align-items: center;
    gap: var(--spacing-sm);
}

.purchase-rule-modal.modal {
    padding: var(--spacing-md);
    align-items: safe center;
}

.purchase-rule-modal .modal-dialog.modal-content--rule-editor {
    width: 100%;
    max-width: min(640px, calc(100vw - 2 * var(--spacing-md)));
    max-height: min(90dvh, 920px);
    margin: auto;
    padding: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    border: 1px solid var(--color-border);
    box-shadow: var(--shadow-xl);
    transform: none;
    animation: slideUpModal 0.3s ease-out;
}

.purchase-rule-modal .modal-header {
    padding: var(--spacing-lg) var(--spacing-xl);
    margin: 0;
    flex-shrink: 0;
}

.purchase-rule-modal .modal-header .modal-title {
    margin: 0;
    font-size: var(--font-size-lg);
    font-weight: 600;
}

.purchase-rule-modal form.modal-form {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
}

.purchase-rule-modal .modal-body {
    flex: 1;
    min-height: 0;
    overflow: hidden;
}

.purchase-rule-modal .modal-body-inner.purchase-rule-modal-body {
    padding: var(--spacing-lg) var(--spacing-xl);
    overflow-y: auto;
    overflow-x: hidden;
    max-height: min(calc(90dvh - 11rem), 720px);
    -webkit-overflow-scrolling: touch;
}

.purchase-rule-modal .modal-body-inner .form-group {
    margin-bottom: var(--spacing-md);
}

.purchase-rule-modal .modal-body-inner .form-group:last-child {
    margin-bottom: 0;
}

.purchase-rule-modal .modal-body-inner .form-label {
    display: block;
    margin-bottom: var(--spacing-sm);
    font-weight: 500;
    color: var(--color-text-secondary);
    font-size: var(--font-size-sm);
}

.purchase-rule-modal .custom-select-wrapper[data-open="true"] {
    position: relative;
    z-index: 30;
}

.purchase-rule-modal .custom-select-wrapper[data-open="true"] .custom-select-dropdown {
    z-index: 1100;
}

.purchase-rule-modal .form-input {
    padding: 0.75rem 1rem;
    font-size: var(--font-size-sm);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    transition: border-color var(--transition-base), box-shadow var(--transition-base);
}

.purchase-rule-modal .form-input:focus {
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px var(--color-primary-subtle);
}

.purchase-rule-modal .purchase-rule-checkbox-row {
    margin-bottom: var(--spacing-sm);
}

.purchase-rule-modal .purchase-rule-checkbox-label {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: var(--spacing-md);
    margin: 0;
    padding: var(--spacing-sm) 0;
    cursor: pointer;
    font-weight: 500;
    color: var(--color-text-primary);
}

.purchase-rule-modal .purchase-rule-checkbox-label .form-checkbox {
    margin: 0;
    flex-shrink: 0;
}

.purchase-rule-modal .purchase-rule-checkbox-hint {
    margin: 0 0 var(--spacing-md) calc(18px + var(--spacing-md));
}

.purchase-rule-field-keys {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: var(--spacing-xs) var(--spacing-md);
}

.purchase-rule-field-key-option {
    margin: 0;
    padding: var(--spacing-xs) 0;
}

.purchase-rule-length-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: var(--spacing-md);
    margin-bottom: var(--spacing-sm);
}

.purchase-rule-length-field label {
    display: block;
    margin-bottom: var(--spacing-xs);
    font-size: var(--font-size-sm);
    font-weight: 500;
    color: var(--color-text-secondary);
}

.purchase-rule-length-hint {
    margin-top: 0;
    margin-bottom: var(--spacing-md);
}

.purchase-rule-modal .purchase-rule-modal-footer {
    flex-shrink: 0;
    margin-top: 0;
    padding: var(--spacing-md) var(--spacing-xl) var(--spacing-xl);
    border-top: 1px solid var(--color-border);
    display: flex;
    flex-wrap: wrap;
    gap: var(--spacing-sm);
    justify-content: flex-end;
}

@media (max-width: 520px) {
    .purchase-rule-modal.modal {
        padding: 0;
        align-items: stretch;
    }

    .purchase-rule-modal .modal-dialog.modal-content--rule-editor {
        max-width: none;
        max-height: 100dvh;
        min-height: 100dvh;
        border-radius: 0;
        border-left: none;
        border-right: none;
    }

    .purchase-rule-modal .modal-body-inner.purchase-rule-modal-body {
        max-height: none;
        flex: 1;
    }

    .purchase-rule-modal .purchase-rule-modal-footer {
        flex-direction: column-reverse;
        padding: var(--spacing-md);
    }

    .purchase-rule-modal .purchase-rule-modal-footer .btn-secondary,
    .purchase-rule-modal .purchase-rule-modal-footer .btn-primary {
        width: 100%;
    }

    .purchase-rule-modal .purchase-rule-checkbox-hint {
        margin-left: 0;
    }
}

.purchase-rule-simple-wrap {
    margin-bottom: var(--spacing-md);
}

.purchase-rule-simple-wrap > .purchase-rule-simple-card {
    margin-bottom: 0;
}

.purchase-rule-simple-card {
    padding: var(--spacing-md) var(--spacing-lg);
    background: var(--color-primary-subtle);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
}

.purchase-rule-simple-card-head {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    margin-bottom: var(--spacing-sm);
}

.purchase-rule-simple-icon {
    display: inline-flex;
    color: var(--color-primary);
    flex-shrink: 0;
}

.purchase-rule-simple-title {
    margin: 0;
    font-size: var(--font-size-base);
    font-weight: 600;
    color: var(--color-text-primary);
}

.purchase-rule-simple-lead {
    margin: 0 0 var(--spacing-md);
    font-size: var(--font-size-sm);
    line-height: var(--line-height-relaxed);
    color: var(--color-text-secondary);
}

.purchase-rule-simple-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: var(--spacing-md);
}

.purchase-rule-simple-field {
    margin-bottom: 0;
}

.purchase-rule-simple-field label {
    display: block;
    margin-bottom: var(--spacing-xs);
    font-size: var(--font-size-sm);
    font-weight: 500;
    color: var(--color-text-secondary);
}

.purchase-rule-optional {
    font-weight: 400;
    font-size: var(--font-size-xs);
    color: var(--color-text-tertiary);
}

.purchase-rule-simple-actions {
    margin-top: var(--spacing-md);
}

.purchase-rule-simple-actions .btn-secondary {
    width: 100%;
}

@media (min-width: 480px) {
    .purchase-rule-simple-actions .btn-secondary {
        width: auto;
    }
}

.purchase-rule-advanced-details {
    margin-top: var(--spacing-sm);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    background: var(--color-surface-muted);
}

.purchase-rule-advanced-summary {
    cursor: pointer;
    list-style: none;
    padding: var(--spacing-sm) var(--spacing-md);
    font-size: var(--font-size-sm);
    font-weight: 500;
    color: var(--color-text-secondary);
    user-select: none;
}

.purchase-rule-advanced-summary::-webkit-details-marker {
    display: none;
}

.purchase-rule-advanced-body {
    padding: 0 var(--spacing-md) var(--spacing-md);
    border-top: 1px solid var(--color-border);
    background: var(--color-surface);
    border-radius: 0 0 var(--radius-md) var(--radius-md);
}


@media (prefers-reduced-motion: reduce) {
    .purchase-format-details-summary::after {
        transition: none;
    }
}

/* Настройки: напоминания о счетах */
.invoice-reminders-page {
    max-width: 920px;
    margin: 0 auto;
    padding: 0 var(--spacing-lg) var(--spacing-2xl);
}

.invoice-reminders-page .content-section {
    margin-bottom: var(--spacing-xl);
}

.invoice-reminders-page .form-layout {
    max-width: 100%;
}

.invoice-reminders-page .form-row {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: var(--spacing-lg);
}

.invoice-reminders-page .form-group .checkbox-label {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: var(--spacing-md);
    margin-bottom: 0;
    padding: var(--spacing-md);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    background: var(--color-surface);
    cursor: pointer;
    font-weight: 500;
    color: var(--color-text-primary);
    line-height: var(--line-height-normal);
    transition: border-color var(--transition-base), background-color var(--transition-base);
}

.invoice-reminders-page .form-group .checkbox-label > span {
    flex: 1;
    min-width: 0;
}

.invoice-reminders-page .form-group .checkbox-label:hover {
    background: var(--color-surface-muted);
    border-color: var(--color-border-medium);
}

.invoice-reminders-page .form-group .checkbox-label input[type="checkbox"] {
    width: 18px;
    height: 18px;
    min-width: 18px;
    margin: 0;
    flex-shrink: 0;
    accent-color: var(--color-primary);
    cursor: pointer;
}

.invoice-reminders-page .form-label {
    display: block;
    margin-bottom: var(--spacing-sm);
    font-weight: 500;
    color: var(--color-text-secondary);
    font-size: var(--font-size-sm);
}

.invoice-reminders-page .weekday-picker {
    display: flex;
    flex-wrap: wrap;
    gap: var(--spacing-sm);
    padding: var(--spacing-md);
    background: var(--color-surface-muted);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
}

.invoice-reminders-page .weekday-chip {
    flex: 1 1 0;
    min-width: 2.75rem;
    cursor: pointer;
}

.invoice-reminders-page .weekday-chip-input {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.invoice-reminders-page .weekday-chip-face {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 42px;
    padding: var(--spacing-sm) var(--spacing-md);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    background: var(--color-surface);
    color: var(--color-text-secondary);
    font-size: var(--font-size-sm);
    font-weight: 600;
    letter-spacing: 0.02em;
    user-select: none;
    transition:
        color var(--transition-base),
        background-color var(--transition-base),
        border-color var(--transition-base),
        box-shadow var(--transition-base);
}

.invoice-reminders-page .weekday-chip:hover .weekday-chip-face {
    border-color: var(--color-border-medium);
    color: var(--color-text-primary);
}

.invoice-reminders-page .weekday-chip-input:focus-visible + .weekday-chip-face {
    outline: 2px solid var(--color-primary);
    outline-offset: 2px;
}

.invoice-reminders-page .weekday-chip-input:checked + .weekday-chip-face {
    background: var(--color-primary);
    border-color: var(--color-primary);
    color: var(--color-text-inverse);
    box-shadow: var(--shadow-sm);
}

.invoice-reminders-page .stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: var(--spacing-lg);
    margin-top: var(--spacing-lg);
}

.invoice-reminders-page .stat-card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    padding: var(--spacing-xl) var(--spacing-lg);
    text-align: center;
    transition: border-color var(--transition-base), box-shadow var(--transition-base);
}

.invoice-reminders-page .stat-card:hover {
    border-color: var(--color-border-medium);
    box-shadow: var(--shadow-sm);
}

.invoice-reminders-page .stat-value {
    font-size: var(--font-size-2xl);
    font-weight: 600;
    color: var(--color-primary);
    margin-bottom: var(--spacing-sm);
    line-height: var(--line-height-tight);
}

.invoice-reminders-page .stat-label {
    color: var(--color-text-secondary);
    font-size: var(--font-size-sm);
    font-weight: 500;
}

.invoice-reminders-page .section-actions {
    display: flex;
    gap: var(--spacing-sm);
    flex-shrink: 0;
    flex-wrap: wrap;
}

.invoice-reminders-page .table-container h4 {
    margin: 0 0 var(--spacing-md);
    font-size: var(--font-size-lg);
    font-weight: 600;
    color: var(--color-text-primary);
}

.invoice-reminders-page .text-link {
    color: var(--color-primary);
    text-decoration: none;
    font-weight: 500;
    transition: color var(--transition-base);
}

.invoice-reminders-page .text-link:hover {
    color: var(--color-primary-hover);
    text-decoration: underline;
}


@media (max-width: 640px) {
    .invoice-reminders-page .form-row {
        grid-template-columns: 1fr;
    }

    .invoice-reminders-page .weekday-chip {
        flex: 1 1 calc(25% - var(--spacing-sm));
        min-width: 2.5rem;
    }
}

@media (prefers-reduced-motion: reduce) {
    .invoice-reminders-page .weekday-chip-face,
    .invoice-reminders-page .stat-card {
        transition: none;
    }
}
