/**
 * OrderCom - Специфичные стили приложения
 */

/* =============================================================================
   МАППИНГ ПЕРЕМЕННЫХ (для совместимости с шаблонами)
   ============================================================================= */

:root {
    /* Фоны */
    --bg-primary: #ffffff;
    --bg-secondary: #f4f8f6;
    --bg-tertiary: #f9fafb;
    --bg-hover: rgba(47, 143, 99, 0.04);

    /* Текст */
    --text-primary: #1A1A1A;
    --text-secondary: #666666;
    --text-muted: #9CA3AF;

    /* Цвета */
    --primary-color: #1B5E3B;
    --border-color: #E5E7EB;

    /* Семантические цвета (для шаблонов Flow) */
    --color-primary: #3B82F6;
    --color-success: #22C55E;
    --color-warning: #F59E0B;
    --color-danger: #EF4444;
    --color-info: #06B6D4;

    /* Границы */
    --border-light: #E5E7EB;

    /* Типографика */
    --font-xxs: 0.65rem;
    --font-xs: 0.7rem;
    --font-xs-plus: 0.75rem;
    --font-sm: 0.8rem;
    --font-sm-plus: 0.85rem;
    --font-md: 0.95rem;
    --font-md-plus: 1rem;
    --font-lg: 1.1rem;
    --font-lg-plus: 1.2rem;
    --font-xl: 1.25rem;
    --font-2xl: 1.5rem;
    --font-3xl: 1.75rem;
    --font-4xl: 2rem;
    --font-hero: 3rem;
}

html {
    overflow-y: scroll;
    scrollbar-gutter: stable;
}

body {
    background: var(--bg-primary);
    color: var(--text-primary);
    font-size: var(--font-md);
    line-height: 1.45;
}

body.auth-page .topbar,
body.auth-page .nav-tabs {
    display: none;
}

body.auth-page .app-shell {
    max-width: none;
    padding: 0;
}

.app-shell {
    max-width: 1280px;
    margin: 0 auto;
    padding: 1.5rem 2rem 2.5rem;
}

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 14px;
    padding: 0.75rem 1rem;
}

.brand {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.brand-icon {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    background: var(--primary-color);
    color: #fff;
    font-weight: 700;
    display: grid;
    place-items: center;
    letter-spacing: 0.04em;
}

.brand-title {
    font-size: var(--font-lg);
    font-weight: 700;
}

.brand-sub {
    font-size: var(--font-sm);
    color: var(--text-secondary);
}

.context {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.context-chip {
    padding: 0.45rem 0.75rem;
    border-radius: 999px;
    background: #fff;
    border: 1px solid var(--border-color);
    font-size: var(--font-xs);
    color: var(--text-secondary);
}

.top-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.action-pill {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.35rem;
    min-width: 40px;
    height: 40px;
    padding: 0 0.6rem;
    border-radius: 10px;
    border: 1px solid var(--border-color);
    background: #fff;
    color: var(--primary-color);
    text-decoration: none;
    font-size: var(--font-sm-plus);
}

.notification-pill {
    position: relative;
}

.user-pill {
    padding-right: 0.75rem;
}

.action-pill:hover {
    background: var(--bg-hover);
}

.nav-tabs {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    margin-top: 1rem;
    padding-bottom: 0.25rem;
}

.nav-tab {
    padding: 0.45rem 0.9rem;
    border-radius: 999px;
    border: 1px solid var(--border-color);
    background: var(--bg-secondary);
    color: var(--text-secondary);
    font-size: var(--font-sm-plus);
    text-decoration: none;
    white-space: nowrap;
}

.nav-tab:hover {
    color: var(--text-primary);
}

.nav-tab.active {
    background: var(--primary-color);
    border-color: var(--primary-color);
    color: #fff;
}

.profile-btn {
    padding: 0 0.5rem;
}

.profile-name {
    font-weight: 600;
    color: var(--text-primary);
    max-width: 140px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.page-content {
    max-width: none;
    margin: 0;
    padding: 0 0 2.5rem;
}

@media (max-width: 960px) {
    .app-shell {
        padding: 1rem 1.25rem 2rem;
    }

    .nav-tabs {
        flex-wrap: nowrap;
        overflow-x: auto;
    }
}

@media (max-width: 720px) {
    .topbar {
        flex-direction: column;
        align-items: flex-start;
    }

    .top-actions {
        width: 100%;
        justify-content: space-between;
    }

    .profile-name {
        display: none;
    }
}

/* =============================================================================
   UI-КОНЦЕПТ: СТРУКТУРА СТРАНИЦ (Header / Info / Grid / Summary / Footer)
   ============================================================================= */

.ui-page {
    max-width: calc(1200px + 4rem);
    margin: 0 auto;
    padding-left: 2rem;
    padding-right: 2rem;
}

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

.ui-header-main {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    min-width: 0;
}

.ui-header-title {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.ui-header-title h1 {
    margin: 0;
    font-size: var(--font-xl);
    color: var(--text-primary);
}

.ui-header-meta {
    font-size: var(--font-sm);
    color: var(--text-secondary);
}

.ui-header-actions {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.ui-infobar {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-left: 4px solid var(--primary-color);
    border-radius: 10px;
    padding: 0.75rem;
    margin-bottom: 0.75rem;
}

.ui-infobar-title {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-secondary);
}

.ui-infobar-text {
    margin-top: 0.25rem;
    font-size: 0.9rem;
    color: var(--text-primary);
}

.ui-infobar-actions {
    margin-top: 0.5rem;
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.ui-grid {
    display: grid;
    grid-template-columns: minmax(0, 2.2fr) minmax(260px, 1fr);
    gap: 0.75rem;
    align-items: start;
}

.ui-panel {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 0.75rem;
}

.ui-panel-title {
    margin: 0 0 0.6rem 0;
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-secondary);
}

.ui-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    margin-bottom: 0.6rem;
}

.ui-panel-header .ui-panel-title {
    margin: 0;
}

.ui-panel-title-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.ui-panel-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.ui-panel.panel-locked {
    background: rgba(148, 163, 184, 0.08);
}

.ui-panel.panel-locked select,
.ui-panel.panel-locked input[type="text"],
.ui-panel.panel-locked input[type="date"] {
    opacity: 0.6;
}

.lock-indicator {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: 999px;
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.sales-control-header {
    align-items: flex-start;
}

.sales-control-heading {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
}

.sales-control-metrics {
    margin-top: 12px;
}

.sales-control-alerts {
    margin-top: 12px;
}

.sales-control-table {
    margin-top: 12px;
}

.ui-panel--spaced {
    margin-top: 18px;
}

.ui-actions {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.ui-actions .btn {
    width: 100%;
    justify-content: center;
}

.ui-summary {
    margin-top: 0.75rem;
    background: var(--bg-secondary);
    border: 1px dashed var(--border-color);
    border-left: 4px solid var(--primary-color);
    border-radius: 10px;
    padding: 0.75rem;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 0.75rem 1rem;
}

.ui-summary--compact {
    margin-top: 0.5rem;
    padding: 0.5rem;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 0.5rem 0.75rem;
}

.ui-summary-item {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
    padding: 0.65rem 0.75rem;
    border-radius: 8px;
    border: 1px solid transparent;
    border-left: 3px solid var(--summary-accent, var(--primary-color));
    background: var(--summary-bg, transparent);
}

.risk-revenue {
    display: inline-flex;
    align-items: center;
    justify-content: flex-end;
    gap: 0.35rem;
    flex-wrap: wrap;
}

.ui-summary-label {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-secondary);
}

.ui-summary-value {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-primary);
}

.ui-summary-item--primary {
    --summary-accent: var(--primary-color);
    --summary-bg: rgba(27, 94, 59, 0.08);
}

.ui-summary-item--accent {
    --summary-accent: #0f766e;
    --summary-bg: rgba(15, 118, 110, 0.08);
}

.ui-summary-item--info {
    --summary-accent: #2563eb;
    --summary-bg: rgba(37, 99, 235, 0.08);
}

.ui-summary-item--warning {
    --summary-accent: #d97706;
    --summary-bg: rgba(217, 119, 6, 0.08);
}

.ui-summary-item--danger {
    --summary-accent: #dc2626;
    --summary-bg: rgba(220, 38, 38, 0.08);
}

.ui-summary-item--primary .ui-summary-value { color: var(--primary-color); }
.ui-summary-item--accent .ui-summary-value { color: #0f766e; }
.ui-summary-item--info .ui-summary-value { color: #1d4ed8; }
.ui-summary-item--warning .ui-summary-value { color: #b45309; }
.ui-summary-item--danger .ui-summary-value { color: #b91c1c; }

.shift-template-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    margin: 0.6rem 0;
}

.shift-template-presets {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 0.5rem;
    margin: 0.6rem 0 0.8rem;
}

.shift-template-preset {
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 0.6rem 0.7rem;
    background: var(--bg-secondary);
    text-align: left;
    cursor: pointer;
    transition: border-color 0.2s ease, box-shadow 0.2s ease, transform 0.2s ease;
}

.shift-template-preset:hover {
    border-color: color-mix(in srgb, var(--primary-color) 45%, transparent);
    box-shadow: 0 10px 18px rgba(15, 23, 42, 0.08);
    transform: translateY(-1px);
}

.shift-template-preset.is-active {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 2px color-mix(in srgb, var(--primary-color) 35%, transparent);
}

.shift-template-preset-title {
    display: block;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-primary);
}

.shift-template-preset-desc {
    display: block;
    margin-top: 0.2rem;
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.shift-template-time-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 0.6rem;
    margin-bottom: 0.6rem;
}

.shift-slot-row--off {
    background: var(--bg-tertiary);
    opacity: 0.7;
}

.shift-slot-badges {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
}

.shift-slot-badge {
    font-size: 0.72rem;
    font-weight: 600;
    padding: 0.2rem 0.45rem;
    border-radius: 999px;
    background: color-mix(in srgb, var(--primary-color) 15%, transparent);
    color: var(--text-primary);
    border: 1px solid color-mix(in srgb, var(--primary-color) 35%, transparent);
    white-space: nowrap;
}

.shift-slot-badge--off {
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    border-color: var(--border-color);
}

.ui-footer {
    position: sticky;
    bottom: 0;
    margin-top: 0.75rem;
    padding: 0.75rem 1rem;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    display: flex;
    justify-content: space-between;
    gap: 0.5rem;
    align-items: center;
    box-shadow: 0 -8px 18px rgba(16, 24, 40, 0.08);
    z-index: 10;
}

.ui-footer-actions {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

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

.ui-compact {
    padding: 0.5rem 0.75rem;
}

.btn-compact {
    padding: 0.35rem 0.7rem;
    font-size: var(--font-sm-plus);
}

.btn-sm {
    padding: 0.25rem 0.6rem;
    font-size: var(--font-sm);
}

.btn.is-active {
    box-shadow: 0 0 0 2px color-mix(in srgb, var(--primary-color) 65%, transparent);
}

.mt-sm { margin-top: 0.75rem; }
.mt-md { margin-top: 1rem; }
.mb-sm { margin-bottom: 0.75rem; }
.mb-md { margin-bottom: 1rem; }
.pl-sm { padding-left: 1.2rem; }
.align-end { align-self: end; }
.btn-block { width: 100%; justify-content: center; }
.content-narrow { max-width: 900px; margin: 0 auto; }

@media (max-width: 960px) {
    .ui-grid {
        grid-template-columns: 1fr;
    }

    .ui-footer {
        position: static;
        box-shadow: none;
    }
}

/* =============================================================================
   БЛОКИ ДЕТАЛЕЙ, БЕЙДЖИ, ТАБЛИЦЫ
   ============================================================================= */

.detail-list {
    display: flex;
    flex-direction: column;
    gap: 0.45rem;
}

.detail-row {
    display: grid;
    grid-template-columns: minmax(110px, 140px) 1fr;
    gap: 0.5rem;
    align-items: baseline;
}

.detail-label {
    font-size: var(--font-xs);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-secondary);
}

.detail-value {
    font-size: var(--font-md);
    color: var(--text-primary);
}

.detail-value a {
    color: var(--primary-color);
    text-decoration: none;
}

.detail-value a:hover {
    text-decoration: underline;
}

.section-badge {
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    padding: 0.2rem 0.6rem;
    border-radius: 999px;
    font-size: var(--font-xs-plus);
    color: var(--text-secondary);
}

.section-badge-warning {
    background: #fef3c7;
    border-color: #fde68a;
    color: #b45309;
}

.section-badge-danger {
    background: #fee2e2;
    border-color: #fecaca;
    color: #b91c1c;
}

.section-badge-success {
    background: #dcfce7;
    border-color: #bbf7d0;
    color: #166534;
}

.section-header-right {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    flex-wrap: wrap;
}

.table-responsive {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.data-table {
    font-size: var(--font-sm-plus);
}

.data-table th,
.data-table td {
    padding: 0.6rem 0.75rem;
}

.data-table th {
    font-size: var(--font-xs-plus);
}

.data-table tr.row-risk td {
    background: rgba(245, 158, 11, 0.08);
}

/* Order list cells */
.orders-list-table .availability-cell,
.orders-list-table .forecast-cell {
    min-width: 170px;
}

.orders-list-table .availability-main,
.orders-list-table .forecast-main {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    flex-wrap: wrap;
    line-height: 1.1;
}

.orders-list-table .availability-qty {
    font-size: var(--font-xs);
    color: var(--text-secondary);
}

.orders-list-table .availability-bar {
    height: 6px;
    background: var(--bg-tertiary);
    border-radius: 999px;
    overflow: hidden;
    margin-top: 0.25rem;
}

.orders-list-table .availability-bar-fill {
    display: block;
    height: 100%;
    background: var(--text-muted);
}

.orders-list-table .availability-bar-fill--success { background: #16a34a; }
.orders-list-table .availability-bar-fill--warning { background: #d97706; }
.orders-list-table .availability-bar-fill--danger { background: #dc2626; }

.orders-list-table .availability-shortage {
    font-size: var(--font-xs);
    color: #b91c1c;
    margin-top: 0.25rem;
}

.orders-list-table .forecast-date {
    font-weight: 600;
    font-size: var(--font-sm);
    color: var(--text-primary);
}

.orders-list-table .forecast-reason {
    font-size: var(--font-xs);
    color: var(--text-secondary);
    margin-top: 0.2rem;
    white-space: normal;
    overflow: visible;
}

.orders-list-table tr.row-risk--warning td {
    background: rgba(245, 158, 11, 0.08);
}

.orders-list-table tr.row-risk--danger td {
    background: rgba(239, 68, 68, 0.08);
}

.total-row td {
    background: var(--bg-tertiary);
    border-top: 2px solid var(--border-color);
    font-weight: 600;
    padding-top: 0.75rem;
    padding-bottom: 0.75rem;
}

.total-row .total-label {
    font-size: var(--font-sm-plus);
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.total-row .total-amount {
    font-size: var(--font-lg);
    font-weight: 700;
    color: var(--primary-color);
    white-space: nowrap;
}

.row-warning {
    background: #fef9c3;
}
.row-danger {
    background: #fee2e2;
}

.text-right { text-align: right; }
.text-center { text-align: center; }
.text-muted { color: var(--text-secondary); font-size: var(--font-xs-plus); }
.text-link { color: var(--primary-color); text-decoration: none; font-weight: 500; }
.text-link:hover { text-decoration: underline; }
.text-sm { font-size: var(--font-sm-plus); }
.table-danger { background-color: #fef2f2; }
.table-warning { background-color: #fffbeb; }
.text-small { font-size: var(--font-xs); }
.text-danger { color: #dc2626; font-weight: 600; }
.text-success { color: #16a34a; font-weight: 600; }
.text-warning { color: #d97706; font-weight: 600; }

.empty-message {
    text-align: center;
    color: var(--text-secondary);
    padding: 1.5rem !important;
}

.btn-group {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
}

.ui-inline-form {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
}

.ui-muted-top {
    margin-top: 0.5rem;
}

.ui-muted-bottom {
    margin-bottom: 0.5rem;
}

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

.dropdown-form {
    margin: 0;
}

.dropdown-item-button {
    width: 100%;
    text-align: left;
    background: none;
    border: none;
    cursor: pointer;
    font: inherit;
}

.col-num { width: 40px; }
.col-unit { width: 70px; }
.col-qty { width: 90px; }
.col-price { width: 100px; }
.col-discount { width: 80px; }
.col-amount { width: 130px; }
.col-actions { width: 120px; }
.col-actions-wide { width: 200px; }

.col-5 { width: 5%; }
.col-10 { width: 10%; }
.col-15 { width: 15%; }
.col-20 { width: 20%; }
.col-30 { width: 30%; }
.col-35 { width: 35%; }
.col-40 { width: 40%; }
.col-45 { width: 45%; }
.col-55 { width: 55%; }
.col-60 { width: 60%; }

.col-150 { width: 150px; }

/* =============================================================================
   ФИЛЬТРЫ И ТАБЛИЦЫ СПИСКОВ
   ============================================================================= */

.filters-panel {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 0.75rem;
    margin-bottom: 0.75rem;
}

.filters-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.5rem;
    gap: 0.5rem;
    flex-basis: 100%;
}

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

.filters-form {
    display: flex;
    flex-wrap: wrap;
    gap: 0.6rem 0.8rem;
    align-items: flex-end;
}

.filters-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
}

.filter-group {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.filter-group label {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-secondary);
}

.filter-group.filter-search {
    flex: 1;
    min-width: 200px;
}

.filter-group input,
.filter-group select {
    min-width: 150px;
    padding: 0.45rem 0.6rem;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background: var(--bg-primary);
    color: var(--text-primary);
    font-size: 0.9rem;
}

.filters-summary {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
    margin-top: 0.6rem;
}

.filter-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.25rem 0.5rem;
    background: #eef2ff;
    color: #1e3a8a;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 600;
}

.table-container {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    overflow: hidden;
}

.bulk-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
    padding: 0.6rem 0.75rem;
    background: #f0f9ff;
    border: 1px solid #bae6fd;
    border-radius: 8px;
    margin-bottom: 0.75rem;
}

.bulk-actions.is-hidden {
    display: none;
}

.selected-count {
    font-weight: 600;
    color: #0369a1;
}

.col-checkbox {
    width: 40px;
    text-align: center;
}
.col-xs { width: 60px; }
.col-sm { width: 80px; }
.col-md { width: 100px; }
.col-lg { width: 120px; }

@media (max-width: 768px) {
    .page-content {
        padding: 1rem;
    }

    .ui-page {
        padding-left: 1rem;
        padding-right: 1rem;
    }

    .ui-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .ui-header-actions {
        width: 100%;
    }

    .ui-header-actions .btn {
        width: 100%;
        justify-content: center;
    }

    .filters-form {
        flex-direction: column;
        align-items: stretch;
    }

    .filter-group input,
    .filter-group select {
        width: 100%;
        min-width: 0;
    }
}

/* =============================================================================
   СТАТУСЫ ЗАКАЗОВ
   ============================================================================= */

/* Order statuses */
.badge-draft { background: #f3f4f6; color: #6b7280; }
.badge-new { background: #dbeafe; color: #1d4ed8; }
.badge-confirmed { background: #fef3c7; color: #d97706; }
.badge-paid { background: #dcfce7; color: #166534; }
.badge-in_progress { background: #e0e7ff; color: #4338ca; }
.badge-shipped { background: #cffafe; color: #0891b2; }
.badge-completed { background: #d1fae5; color: #065f46; }
.badge-cancelled { background: #fee2e2; color: #b91c1c; }
.badge-pending { background: #f3f4f6; color: #374151; }
.badge-waiting_client { background: #fef3c7; color: #92400e; }
.badge-waiting_manager { background: #fde68a; color: #92400e; }
.badge-ready_for_review { background: #dbeafe; color: #1d4ed8; }
.badge-overdue { background: #fee2e2; color: #991b1b; }
.badge-processed { background: #d1fae5; color: #065f46; }
.badge-rejected { background: #fee2e2; color: #b91c1c; }
.badge-secondary { background: #e5e7eb; color: #4b5563; }

/* Return statuses */
.badge-approved { background: #fef3c7; color: #d97706; }

/* Purchase order statuses */
.badge-sent { background: #dbeafe; color: #1d4ed8; }
.badge-received { background: #dcfce7; color: #166534; }
.badge-partial { background: #fef3c7; color: #d97706; }

/* Invoice statuses */
.badge-success { background: #dcfce7; color: #166534; }
.badge-warning { background: #fef3c7; color: #d97706; }
.badge-danger { background: #fee2e2; color: #b91c1c; }
.badge-primary { background: #dbeafe; color: #1d4ed8; }
.badge-info { background: #e0f2fe; color: #0369a1; }
.badge-admin { background: #fee2e2; color: #b91c1c; }
.badge-manager { background: #dbeafe; color: #1d4ed8; }
.badge-warehouse { background: #fef3c7; color: #d97706; }
.badge-accountant { background: #e0e7ff; color: #4338ca; }
.badge-viewer { background: #e5e7eb; color: #4b5563; }
.badge-purchase { background: #dbeafe; color: #1d4ed8; }
.badge-production { background: #f3e8ff; color: #7c3aed; }
.badge-receipt { background: #dcfce7; color: #166534; }
.badge-shipment { background: #fee2e2; color: #b91c1c; }
.badge-transfer_in { background: #dbeafe; color: #1d4ed8; }
.badge-transfer_out { background: #fef3c7; color: #d97706; }
.badge-write_off { background: #e5e7eb; color: #4b5563; }
.badge-inventory_plus { background: #d1fae5; color: #065f46; }
.badge-inventory_minus { background: #fecaca; color: #7f1d1d; }
.chain-badges {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    margin-top: 0.6rem;
}

.chain-badges .badge {
    font-size: var(--font-xs-plus);
}

/* =============================================================================
   КНОПКИ СТАТУСОВ
   ============================================================================= */

.btn-status-new {
    background: #dbeafe;
    color: #1d4ed8;
    border: 1px solid #93c5fd;
}
.btn-status-new:hover { background: #bfdbfe; }

.btn-status-confirmed {
    background: #fef3c7;
    color: #d97706;
    border: 1px solid #fcd34d;
}
.btn-status-confirmed:hover { background: #fde68a; }

.btn-status-paid {
    background: #dcfce7;
    color: #166534;
    border: 1px solid #86efac;
}
.btn-status-paid:hover { background: #bbf7d0; }

.btn-status-in_progress {
    background: #e0e7ff;
    color: #4338ca;
    border: 1px solid #a5b4fc;
}
.btn-status-in_progress:hover { background: #c7d2fe; }

.btn-status-shipped {
    background: #cffafe;
    color: #0891b2;
    border: 1px solid #67e8f9;
}
.btn-status-shipped:hover { background: #a5f3fc; }

.btn-status-completed {
    background: #d1fae5;
    color: #065f46;
    border: 1px solid #6ee7b7;
}
.btn-status-completed:hover { background: #a7f3d0; }

.btn-status-cancelled {
    background: #fee2e2;
    color: #b91c1c;
    border: 1px solid #fca5a5;
}
.btn-status-cancelled:hover { background: #fecaca; }

.btn-status-draft {
    background: #f3f4f6;
    color: #6b7280;
    border: 1px solid #d1d5db;
}
.btn-status-draft:hover { background: #e5e7eb; }

.btn-status-approved {
    background: #fef3c7;
    color: #b45309;
    border: 1px solid #fde68a;
}
.btn-status-approved:hover { background: #fde68a; }

.btn-status-processed {
    background: #dcfce7;
    color: #166534;
    border: 1px solid #bbf7d0;
}
.btn-status-processed:hover { background: #bbf7d0; }

.btn-status-rejected {
    background: #fee2e2;
    color: #b91c1c;
    border: 1px solid #fecaca;
}
.btn-status-rejected:hover { background: #fecaca; }

/* =============================================================================
   ДОПОЛНИТЕЛЬНЫЕ КНОПКИ
   ============================================================================= */

.btn-secondary {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.5rem 1rem;
    background: var(--bg-tertiary, #f9fafb);
    border: 1px solid var(--border-color, #e5e7eb);
    border-radius: 6px;
    color: var(--text-primary, #374151);
    font-size: 0.875rem;
    font-weight: 500;
    text-decoration: none;
    cursor: pointer;
    transition: background 0.2s, border-color 0.2s;
}
.btn-secondary:hover {
    background: #e5e7eb;
    border-color: #d1d5db;
}

.btn-focus {
    border: 1px solid rgba(16, 24, 40, 0.12);
    box-shadow: 0 10px 20px rgba(16, 24, 40, 0.12);
}

.btn-focus:hover {
    box-shadow: 0 14px 28px rgba(16, 24, 40, 0.18);
}

.btn-success {
    background: #16a34a;
    border-color: #16a34a;
    color: #ffffff;
}

.btn-success:hover {
    background: #15803d;
}

.btn-danger {
    background: #dc2626;
    border-color: #dc2626;
    color: #ffffff;
}

.btn-danger:hover {
    background: #b91c1c;
}

.btn-warning {
    background: #fef3c7;
    border-color: #fcd34d;
    color: #92400e;
}

.btn-warning:hover {
    background: #fde68a;
}

/* =============================================================================
   ХЛЕБНЫЕ КРОШКИ
   ============================================================================= */

.breadcrumbs {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
    padding: 4px 0;
    margin: 0;
    font-size: 0.85rem;
    color: var(--text-secondary, #6b7280);
}

.breadcrumbs .breadcrumb-item {
    color: var(--text-secondary, #6b7280);
    text-decoration: none;
}

.breadcrumbs .breadcrumb-item:hover,
.breadcrumbs .breadcrumb-item:focus {
    color: var(--text-primary, #111827);
    text-decoration: underline;
    text-underline-offset: 2px;
}

.breadcrumbs .breadcrumb-sep {
    color: var(--border-color, #d1d5db);
}

.breadcrumbs .breadcrumb-current {
    color: var(--text-primary, #111827);
    font-weight: 500;
}

/* =============================================================================
   УЛУЧШЕННЫЕ ФОРМЫ
   ============================================================================= */

.form-card {
    background: var(--bg-secondary, #fff);
    border: 1px solid var(--border-color, #e5e7eb);
    border-radius: 8px;
    padding: 1.5rem;
    margin-bottom: 1.5rem;
}

.form-card h3 {
    margin: 0 0 1rem 0;
    color: var(--text-primary, #111827);
    font-size: 1rem;
    font-weight: 600;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid var(--border-color, #e5e7eb);
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1rem;
}

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

.form-group label {
    display: block;
    margin-bottom: 0.375rem;
    font-weight: 500;
    font-size: var(--font-sm-plus);
    color: var(--text-secondary, #374151);
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 0.625rem 0.75rem;
    font-size: var(--font-md);
    border: 1px solid var(--border-color, #d1d5db);
    border-radius: 6px;
    background: var(--bg-primary, #fff);
    color: var(--text-primary, #111827);
    font-family: inherit;
    transition: border-color 0.15s, box-shadow 0.15s;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--primary-color, #3b82f6);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.form-group input:disabled,
.form-group select:disabled,
.form-group textarea:disabled {
    background: var(--bg-tertiary, #f3f4f6);
    cursor: not-allowed;
}

.comment-compact textarea {
    min-height: 72px;
    resize: vertical;
}

.textarea-compact {
    min-height: 72px;
    resize: vertical;
}

.form-group input[type="file"] {
    padding: 0.45rem;
    border-style: dashed;
}

.form-group input[type="checkbox"] {
    width: auto;
    padding: 0;
    margin-top: 0.35rem;
    border: none;
    accent-color: var(--primary-color);
}

.form-group select[multiple] {
    min-height: 160px;
}

.form-group textarea.code-textarea {
    font-family: "Courier New", monospace;
}

.form-group .help-text {
    margin-top: 0.25rem;
    font-size: var(--font-xs-plus);
    color: var(--text-secondary, #6b7280);
}

.form-group .error-text {
    margin-top: 0.25rem;
    font-size: var(--font-xs-plus);
    color: #dc2626;
}

.form-group.has-error input,
.form-group.has-error select,
.form-group.has-error textarea {
    border-color: #dc2626;
}

/* Django form errors */
.form-group ul.errorlist {
    list-style: none;
    padding: 0;
    margin: 0.25rem 0 0 0;
}

.form-alert {
    margin-top: 0.75rem;
    padding: 0.6rem 0.75rem;
    border-radius: 8px;
    font-size: 0.85rem;
}

.form-alert-danger {
    background: #fef2f2;
    border: 1px solid #fecaca;
    color: #b91c1c;
}

.form-alert ul {
    margin: 0;
    padding-left: 1.1rem;
}

.form-section {
    margin-bottom: 1rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border-color);
}

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

.form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 0.75rem;
}

.supplier-toolbar {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    flex-wrap: wrap;
    margin-bottom: 0.5rem;
}

.supplier-search {
    flex: 1;
    min-width: 240px;
}

.supplier-table-wrap {
    margin-top: 0.5rem;
}

.supplier-table .supplier-actions {
    display: flex;
    gap: 0.35rem;
    justify-content: flex-end;
}

.supplier-table .supplier-priority {
    font-weight: 600;
    color: var(--text-primary);
}

.supplier-col-priority {
    width: 70px;
}

.supplier-col-article {
    width: 100px;
}

.supplier-col-price {
    width: 90px;
}

.supplier-col-moq {
    width: 80px;
}

.supplier-col-lead {
    width: 70px;
}

.supplier-col-actions {
    width: 110px;
}

.supplier-empty {
    padding: 0.5rem 0;
}

.checkbox-group {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.checkbox-group input {
    width: auto;
    margin: 0;
}

.checkbox-group label {
    margin: 0;
    font-weight: 500;
}

.items-table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 0.75rem;
}

.items-table th,
.items-table td {
    padding: 0.45rem 0.55rem;
    border: 1px solid var(--border-color);
    text-align: left;
    font-size: var(--font-sm-plus);
}

.items-table th {
    background: var(--bg-tertiary);
    font-weight: 600;
    color: var(--text-secondary);
}

.items-table input,
.items-table select {
    width: 100%;
    padding: 0.35rem 0.5rem;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    background: var(--bg-primary);
    color: var(--text-primary);
}

.item-row.deleted {
    display: none;
}

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

.item-amount {
    text-align: right;
    font-weight: 600;
}

.items-table .item-row.is-loading td {
    opacity: 0.6;
    position: relative;
}

.items-table .item-row.is-loading td::after {
    content: "";
    position: absolute;
    inset: 0.35rem 0.5rem;
    background: linear-gradient(
        90deg,
        rgba(235, 235, 235, 0.35),
        rgba(220, 220, 220, 0.75),
        rgba(235, 235, 235, 0.35)
    );
    background-size: 200% 100%;
    animation: table-skeleton 1.1s ease-in-out infinite;
    border-radius: 6px;
    pointer-events: none;
}

@keyframes table-skeleton {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

.stock-info {
    text-align: center;
    font-size: 0.8rem;
    font-weight: 600;
    padding: 0.2rem;
}

.stock-ok {
    color: #166534;
    background: #dcfce7;
    border-radius: 6px;
}

.stock-low {
    color: #b91c1c;
    background: #fee2e2;
    border-radius: 6px;
}

.item-forecast {
    min-width: 110px;
}

.item-forecast-date {
    font-weight: 600;
    font-size: 0.8rem;
    color: var(--text-primary);
}

.item-forecast-mode {
    font-size: 0.7rem;
    color: var(--text-secondary);
    margin-top: 0.1rem;
}

.item-forecast--critical .item-forecast-date {
    color: #b91c1c;
}

.btn-delete {
    background: #fee2e2;
    color: #b91c1c;
    border-color: #fecaca;
}

.form-group ul.errorlist li {
    font-size: 0.75rem;
    color: #dc2626;
}

.field-error {
    margin-top: 0.25rem;
    font-size: 0.75rem;
    color: #dc2626;
}

/* =============================================================================
   ДЕЙСТВИЯ ФОРМЫ
   ============================================================================= */

.form-actions {
    display: flex;
    gap: 0.75rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border-color, #e5e7eb);
    margin-top: 1.5rem;
}

.form-actions .btn {
    padding: 0.625rem 1.25rem;
}

.delete-card {
    max-width: 520px;
    width: 100%;
    margin: 0 auto;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 1.5rem;
}

.delete-card h1 {
    margin: 0 0 1rem 0;
}

.delete-warning {
    background: #fef2f2;
    border: 1px solid #fecaca;
    border-radius: 8px;
    padding: 0.75rem 1rem;
    margin: 1rem 0;
    color: #991b1b;
}

.delete-info {
    background: var(--bg-tertiary);
    border-radius: 8px;
    padding: 0.75rem 1rem;
    margin: 1rem 0;
}

.delete-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
}

.role-description {
    margin-top: 1rem;
    padding: 0.75rem;
    background: var(--bg-tertiary);
    border-radius: 8px;
}

.role-description-title {
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-secondary);
    margin-bottom: 0.6rem;
}

.permissions-list {
    list-style: none;
    padding: 0;
    margin: 0;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 0.5rem;
}

.permissions-list li {
    font-size: 0.85rem;
    color: var(--text-primary);
}

.permissions-list li::before {
    content: \"✓ \";
    color: #16a34a;
}

/* =============================================================================
   ДЕТАЛЬНАЯ КАРТОЧКА
   ============================================================================= */

.detail-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
}

.detail-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 1rem;
}

.detail-section {
    margin-bottom: 1rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border-color);
}

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

.detail-section h3 {
    margin: 0 0 0.75rem;
    color: var(--text-primary);
    font-size: 1rem;
}

.detail-item {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.detail-item .label {
    font-size: 0.75rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.detail-item .value {
    font-size: 0.95rem;
    color: var(--text-primary);
}

.detail-item .value.amount {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--primary-color);
}

.detail-comment {
    margin-top: 0.75rem;
}

.detail-comment .label {
    font-size: 0.75rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    display: block;
    margin-bottom: 0.25rem;
}

.detail-comment p {
    margin: 0;
    color: var(--text-primary);
}

.detail-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 1.5rem;
    margin-top: 0.75rem;
    padding-top: 0.75rem;
    border-top: 1px solid var(--border-color);
    color: var(--text-secondary);
    font-size: 0.85rem;
}

.page-nav {
    margin-top: 1rem;
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
}

/* =============================================================================
   ПРОФИЛЬ И ПАНЕЛИ
   ============================================================================= */

.profile-identity {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.profile-avatar {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: var(--primary-color);
    color: #ffffff;
    display: grid;
    place-items: center;
    font-weight: 700;
    font-size: 1.05rem;
}

.profile-name {
    font-size: 1.05rem;
    font-weight: 600;
    color: var(--text-primary);
}

.profile-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

/* =============================================================================
   КАРТОЧКИ АДМИНИСТРИРОВАНИЯ
   ============================================================================= */

.card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 0.75rem;
}

.admin-tile {
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
}

.admin-tile h3 {
    margin: 0;
    font-size: 1rem;
}

.admin-tile p {
    margin: 0;
    color: var(--text-secondary);
}

.admin-tile-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    margin-top: auto;
}

@media (max-width: 768px) {
    .admin-tile-footer {
        flex-direction: column;
        align-items: stretch;
    }

    .admin-tile-footer .btn {
        width: 100%;
        justify-content: center;
    }
}

/* =============================================================================
   LOADING SPINNER
   ============================================================================= */

.spinner {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 2px solid var(--border-color, #e5e7eb);
    border-top-color: var(--primary-color, #3b82f6);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

/* =============================================================================
   ORDER STATUS FLOW MAP (ADMIN)
   ============================================================================= */

.flow-intro {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.flow-intro-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 1rem 1.25rem;
}

.flow-intro-title {
    font-size: 0.85rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-secondary);
}

.flow-intro-text {
    margin-top: 0.5rem;
    font-size: 0.9rem;
    color: var(--text-primary);
}

.order-flow {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.flow-stage-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 14px;
    padding: 1.25rem 1.5rem;
    box-shadow: 0 12px 30px rgba(15, 23, 42, 0.04);
    border-left: 6px solid var(--flow-color, var(--primary-color));
}

.flow-stage-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
}

.flow-stage-title {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.flow-stage-dot {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: var(--flow-color, var(--primary-color));
    box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.12);
}

.flow-stage-name {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text-primary);
}

.flow-stage-code {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.flow-stage-flag {
    font-size: 0.7rem;
    font-weight: 700;
    padding: 0.25rem 0.6rem;
    border-radius: 999px;
    background: rgba(16, 185, 129, 0.15);
    color: #047857;
}

.flow-stage-desc {
    margin-top: 0.4rem;
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.flow-stage-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1rem;
    margin-top: 1rem;
}

.flow-block-title {
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-secondary);
    font-weight: 700;
}

.flow-block-text {
    margin-top: 0.4rem;
    font-size: 0.9rem;
    color: var(--text-primary);
}

.flow-list {
    margin: 0.5rem 0 0;
    padding-left: 1rem;
    color: var(--text-secondary);
    font-size: 0.82rem;
}

.flow-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    margin-top: 0.5rem;
}

.flow-tag {
    font-size: 0.72rem;
    font-weight: 600;
    padding: 0.25rem 0.5rem;
    border-radius: 999px;
    background: rgba(59, 130, 246, 0.1);
    color: #1d4ed8;
}

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

.flow-substatuses {
    margin-top: 1.25rem;
}

.substatus-stack {
    display: flex;
    flex-direction: column;
    gap: 0.7rem;
    margin-top: 0.6rem;
}

.substatus-card {
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 0.85rem 1rem;
    border-left: 4px solid var(--sub-color, var(--primary-color));
}

.substatus-header {
    display: flex;
    align-items: center;
    gap: 0.6rem;
}

.substatus-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--sub-color, var(--primary-color));
}

.substatus-name {
    font-weight: 700;
    color: var(--text-primary);
}

.substatus-code {
    font-size: 0.7rem;
    color: var(--text-secondary);
}

.substatus-text {
    margin-top: 0.35rem;
    color: var(--text-secondary);
    font-size: 0.82rem;
}

.substatus-next {
    margin-top: 0.4rem;
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.substatus-arrow {
    text-align: center;
    color: var(--text-secondary);
    font-size: 1rem;
}

.flow-transitions {
    margin-top: 1.25rem;
}

.flow-transition-list {
    display: grid;
    gap: 0.75rem;
    margin-top: 0.6rem;
}

.flow-transition {
    background: var(--bg-primary);
    border: 1px dashed var(--border-color);
    border-radius: 12px;
    padding: 0.85rem 1rem;
}

.flow-transition-head {
    font-weight: 700;
    color: var(--text-primary);
}

.flow-transition-text {
    margin-top: 0.35rem;
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.flow-transition-conditions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    margin-top: 0.5rem;
}

.flow-condition {
    font-size: 0.7rem;
    padding: 0.2rem 0.45rem;
    border-radius: 6px;
    background: rgba(15, 23, 42, 0.06);
    color: var(--text-secondary);
}

.flow-connector {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin: 0.4rem 0 0.1rem;
    color: var(--text-secondary);
    font-size: 0.78rem;
}

.flow-connector-line {
    flex: 1;
    height: 1px;
    background: var(--border-color);
}

.flow-connector-label {
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-weight: 600;
}

@media (max-width: 768px) {
    .flow-stage-card {
        padding: 1rem;
    }

    .flow-stage-grid {
        grid-template-columns: 1fr;
    }
}

.spinner-lg {
    width: 32px;
    height: 32px;
    border-width: 3px;
}

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

.loading-overlay {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.8);
    z-index: 10;
}

/* =============================================================================
   УЛУЧШЕННЫЕ ТАБЛИЦЫ
   ============================================================================= */

.table-container {
    background: var(--bg-secondary, #fff);
    border: 1px solid var(--border-color, #e5e7eb);
    border-radius: 8px;
    overflow: hidden;
}

.table-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem;
    border-bottom: 1px solid var(--border-color, #e5e7eb);
}

.table-title {
    font-weight: 600;
    color: var(--text-primary, #111827);
}

.table-actions {
    display: flex;
    gap: 0.5rem;
}

.procurement-line {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.procurement-title {
    font-weight: 600;
    color: var(--text-primary, #111827);
}

.procurement-meta {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    color: var(--text-muted, #6b7280);
    font-size: 0.85rem;
}

.procurement-needed {
    font-weight: 600;
    color: var(--text-primary, #111827);
}

.procurement-eta {
    color: var(--text-muted, #6b7280);
    font-size: 0.8rem;
    margin-top: 0.15rem;
}

/* Sortable headers */
.data-table th.sortable {
    cursor: pointer;
    user-select: none;
}

.data-table th.sortable:hover {
    background: var(--bg-hover, #f3f4f6);
}

.data-table th.sort-asc::after {
    content: " ↑";
    opacity: 0.5;
}

.data-table th.sort-desc::after {
    content: " ↓";
    opacity: 0.5;
}

/* =============================================================================
   ПУСТЫЕ СОСТОЯНИЯ
   ============================================================================= */

.empty-state {
    text-align: center;
    padding: 3rem 2rem;
}

.empty-state-icon {
    font-size: 3rem;
    margin-bottom: 1rem;
    opacity: 0.5;
}

.empty-state-title {
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--text-primary, #111827);
    margin-bottom: 0.5rem;
}

.empty-state-text {
    color: var(--text-secondary, #6b7280);
    margin-bottom: 1.5rem;
}

/* =============================================================================
   ФИЛЬТРЫ
   ============================================================================= */

.filters-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    padding: 1rem;
    background: var(--bg-tertiary, #f9fafb);
    border-radius: 8px;
    margin-bottom: 1rem;
}

.filter-group {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.filter-group label {
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--text-secondary, #6b7280);
}

.filter-group input,
.filter-group select {
    padding: 0.5rem 0.75rem;
    font-size: 0.875rem;
    border: 1px solid var(--border-color, #d1d5db);
    border-radius: 6px;
    min-width: 150px;
}

.filters-actions {
    display: flex;
    align-items: flex-end;
    gap: 0.5rem;
}

/* =============================================================================
   МОБИЛЬНАЯ АДАПТАЦИЯ
   ============================================================================= */

@media (max-width: 768px) {
    .form-grid {
        grid-template-columns: 1fr;
    }

    .detail-grid {
        grid-template-columns: 1fr 1fr;
    }

    .filters-bar {
        flex-direction: column;
    }

    .filter-group {
        width: 100%;
    }

    .filter-group input,
    .filter-group select {
        width: 100%;
        min-width: auto;
    }

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

    .form-actions .btn {
        width: 100%;
        justify-content: center;
    }
}

@media (max-width: 480px) {
    .detail-grid {
        grid-template-columns: 1fr;
    }
}

/* =============================================================================
   ПАНЕЛЬ ФИЛЬТРОВ (УЛУЧШЕННАЯ)
   ============================================================================= */

.filters-panel {
    background: var(--bg-secondary, #f9fafb);
    border: 1px solid var(--border-color, #e5e7eb);
    border-radius: 8px;
    padding: 1rem;
    margin-bottom: 1rem;
}

.filters-form {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    align-items: flex-end;
}

.filters-form .filter-group {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.filters-form .filter-group.filter-search {
    flex: 1;
    min-width: 200px;
}

.filters-form .filter-group input,
.filters-form .filter-group select {
    padding: 0.5rem 0.75rem;
    font-size: 0.875rem;
    border: 1px solid var(--border-color, #d1d5db);
    border-radius: 6px;
    background: var(--bg-primary, #fff);
    color: var(--text-primary, #111827);
}

.filters-form .filter-group input:focus,
.filters-form .filter-group select:focus {
    outline: none;
    border-color: var(--primary-color, #1B5E3B);
    box-shadow: 0 0 0 2px rgba(27, 94, 59, 0.1);
}

.filters-form .btn {
    padding: 0.5rem 1rem;
    white-space: nowrap;
}

@media (max-width: 768px) {
    .filters-form {
        flex-direction: column;
    }

    .filters-form .filter-group,
    .filters-form .filter-group.filter-search {
        width: 100%;
        min-width: auto;
    }

    .filters-form .filter-group input,
    .filters-form .filter-group select {
        width: 100%;
    }

    .filters-form .btn {
        width: 100%;
        justify-content: center;
    }
}

/* =============================================================================
   ЗАГОЛОВОК СТРАНИЦЫ С КНОПКАМИ
   ============================================================================= */

.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
    gap: 1rem;
}

.page-header h1 {
    margin: 0;
    color: var(--text-primary, #111827);
}

.page-header-actions {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

@media (max-width: 640px) {
    .page-header {
        flex-direction: column;
        align-items: stretch;
    }

    .page-header-actions {
        justify-content: stretch;
    }

    .page-header-actions .btn {
        flex: 1;
        justify-content: center;
    }
}

/* =============================================================================
   ОТЧЕТЫ И АНАЛИТИКА
   ============================================================================= */

.analysis-list {
    list-style: none;
    margin: 0.5rem 0 0;
    padding: 0;
    display: grid;
    gap: 0.4rem;
    color: var(--text-secondary);
}

.analysis-list li {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.summary-accent {
    border-left: 4px solid transparent;
    padding-left: 0.75rem;
}

.summary-accent-a { border-color: #16a34a; }
.summary-accent-b { border-color: #d97706; }
.summary-accent-c { border-color: #dc2626; }

.summary-sub {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.matrix-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 0.5rem;
}

.matrix-cell {
    padding: 0.75rem;
    border-radius: 8px;
    text-align: center;
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
}

.matrix-cell .cell-cat {
    font-weight: 700;
    font-size: 1.05rem;
}

.matrix-cell .cell-amount {
    font-size: 0.75rem;
}

.matrix-table {
    width: 100%;
    border-collapse: collapse;
}

.matrix-table th,
.matrix-table td {
    padding: 0.55rem 0.6rem;
    border: 1px solid var(--border-color);
    text-align: center;
    font-size: 0.85rem;
}

.matrix-table th {
    background: var(--bg-tertiary);
    font-weight: 600;
    color: var(--text-secondary);
}

.badge-a { background: #dcfce7; color: #166534; }
.badge-b { background: #fef3c7; color: #92400e; }
.badge-c { background: #fee2e2; color: #b91c1c; }
.badge-x { background: #dbeafe; color: #1d4ed8; }
.badge-y { background: #e0e7ff; color: #4338ca; }
.badge-z { background: #fce7f3; color: #be185d; }

.badge-ax { background: #dcfce7; color: #166534; }
.badge-ay { background: #d1fae5; color: #065f46; }
.badge-az { background: #bbf7d0; color: #15803d; }
.badge-bx { background: #fef3c7; color: #92400e; }
.badge-by { background: #fde68a; color: #a16207; }
.badge-bz { background: #fcd34d; color: #b45309; }
.badge-cx { background: #fee2e2; color: #b91c1c; }
.badge-cy { background: #fecaca; color: #dc2626; }
.badge-cz { background: #fca5a5; color: #ef4444; }

.matrix-cell-ax { background: #dcfce7; color: #166534; }
.matrix-cell-ay { background: #d1fae5; color: #065f46; }
.matrix-cell-az { background: #bbf7d0; color: #15803d; }
.matrix-cell-bx { background: #fef3c7; color: #92400e; }
.matrix-cell-by { background: #fde68a; color: #a16207; }
.matrix-cell-bz { background: #fcd34d; color: #b45309; }
.matrix-cell-cx { background: #fee2e2; color: #b91c1c; }
.matrix-cell-cy { background: #fecaca; color: #dc2626; }
.matrix-cell-cz { background: #fca5a5; color: #ef4444; }

.funnel-container {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.funnel-stage {
    display: grid;
    grid-template-columns: minmax(140px, 1fr) minmax(0, 2fr);
    gap: 0.75rem;
    align-items: center;
}

.funnel-bar {
    width: 100%;
    height: 38px;
    background: var(--bg-tertiary);
    border-radius: 8px;
    overflow: hidden;
}

.funnel-bar-inner {
    height: 100%;
    width: 0;
    border-radius: 8px;
    transition: width 0.3s ease;
}

.funnel-stage-all { background: #dbeafe; }
.funnel-stage-active { background: #e0e7ff; }
.funnel-stage-confirmed { background: #fef3c7; }
.funnel-stage-paid { background: #dcfce7; }
.funnel-stage-shipped { background: #cffafe; }
.funnel-stage-completed { background: #d1fae5; }

.funnel-info {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

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

.funnel-stats {
    display: flex;
    flex-wrap: wrap;
    gap: 0.6rem;
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.funnel-conversion {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    align-items: center;
}

.conversion-badge {
    padding: 0.2rem 0.5rem;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 600;
}

.conversion-good { background: #dcfce7; color: #166534; }
.conversion-medium { background: #fef3c7; color: #92400e; }
.conversion-low { background: #fee2e2; color: #b91c1c; }

.conversion-total {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.status-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 0.75rem;
}

.status-card {
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 0.75rem;
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
}

.status-name {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-secondary);
}

.status-count {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text-primary);
}

.status-amount {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.reconciliation-header {
    text-align: center;
}

.reconciliation-title {
    margin: 0 0 0.4rem 0;
    font-size: 1.1rem;
    color: var(--text-primary);
}

.reconciliation-period {
    margin: 0 0 0.4rem 0;
    color: var(--text-secondary);
}

.reconciliation-parties {
    margin: 0;
    color: var(--text-primary);
}

.balance-row {
    background: #e0e7ff;
}

.balance-row.closing {
    background: #c7d2fe;
}

.amount-positive {
    color: #dc2626;
    font-weight: 700;
}

.amount-negative {
    color: #16a34a;
    font-weight: 700;
}

@media (max-width: 768px) {
    .funnel-stage {
        grid-template-columns: 1fr;
    }
}

/* =============================================================================
   CORE DASHBOARD
   ============================================================================= */

.stat-card {
    text-decoration: none;
    color: inherit;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

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

.sales-summary {
    margin-bottom: 1.5rem;
}

.sales-cards {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1rem;
}

.sales-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 1.25rem;
}

.sales-card.highlight {
    background: linear-gradient(135deg, #dcfce7 0%, #d1fae5 100%);
    border-color: #86efac;
}

.sales-card.debt {
    background: linear-gradient(135deg, #fee2e2 0%, #fecaca 100%);
    border-color: #f87171;
    text-decoration: none;
}

.sales-label {
    font-size: 0.875rem;
    color: var(--text-secondary);
    margin-bottom: 0.25rem;
}

.sales-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
}

.sales-card.highlight .sales-value {
    color: #166534;
}

.sales-card.debt .sales-value {
    color: #b91c1c;
}

.sales-count {
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-top: 0.25rem;
}

.trend-up {
    color: #16a34a;
    font-weight: 600;
    margin-left: 0.25rem;
}

.trend-down {
    color: #dc2626;
    font-weight: 600;
    margin-left: 0.25rem;
}

.warehouse-summary {
    margin-bottom: 1.5rem;
}

.warehouse-cards {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
}

.warehouse-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 1rem 1.5rem;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    text-decoration: none;
    transition: background 0.2s;
    min-width: 140px;
}

.warehouse-card:hover {
    background: var(--bg-hover);
}

.warehouse-card.warning {
    background: #fef3c7;
    border-color: #f59e0b;
}

.warehouse-icon {
    font-size: 1.5rem;
    margin-bottom: 0.5rem;
}

.warehouse-value {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-primary);
}

.warehouse-card.warning .warehouse-value {
    color: #d97706;
}

.warehouse-label {
    font-size: 0.75rem;
    color: var(--text-secondary);
    text-align: center;
}

.dashboard-table {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    overflow: hidden;
}

.dashboard-table table {
    width: 100%;
    border-collapse: collapse;
}

.dashboard-table th,
.dashboard-table td {
    padding: 0.75rem 1rem;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}

.dashboard-table th {
    background: var(--bg-tertiary);
    font-weight: 600;
    color: var(--text-secondary);
    font-size: 0.875rem;
}

.dashboard-table tbody tr:last-child td {
    border-bottom: none;
}

.dashboard-table tbody tr:hover {
    background: var(--bg-hover);
}

.dashboard-table a {
    color: var(--primary-color);
    text-decoration: none;
}

.dashboard-table a:hover {
    text-decoration: underline;
}

.attention-badge.warning {
    background: #fef3c7;
    color: #d97706;
}

.attention-badge.plus {
    background: #dbeafe;
    color: #1d4ed8;
}

.chart-section {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 1.25rem;
    margin-bottom: 1.5rem;
}

.chart-section .section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.chart-period {
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.chart-container {
    position: relative;
    height: 250px;
}

@media (max-width: 768px) {
    .sales-cards {
        grid-template-columns: 1fr 1fr;
    }

    .warehouse-cards {
        flex-direction: column;
    }

    .warehouse-card {
        width: 100%;
        flex-direction: row;
        justify-content: flex-start;
        gap: 1rem;
    }

    .warehouse-icon {
        margin-bottom: 0;
    }

    .warehouse-label {
        text-align: left;
    }

    .dashboard-grid {
        grid-template-columns: 1fr;
    }

    .dashboard-table {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .dashboard-table table {
        min-width: 500px;
    }

    .chart-container {
        height: 200px;
    }
}

@media (max-width: 480px) {
    .sales-cards {
        grid-template-columns: 1fr;
    }

    .stat-cards {
        grid-template-columns: 1fr 1fr;
    }

    .sales-value {
        font-size: 1.25rem;
    }

    .page-header__main .page-title {
        font-size: 1.25rem;
    }

    .page-header__main .page-subtitle {
        font-size: 0.875rem;
    }
}

/* =============================================================================
   NOTIFICATIONS
   ============================================================================= */

.notifications-list {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    overflow: hidden;
}

.notification-item {
    display: flex;
    gap: 1rem;
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--border-color);
    align-items: flex-start;
    transition: background 0.15s;
}

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

.notification-item:hover {
    background: var(--bg-hover);
}

.notification-item.unread {
    background: rgba(59, 130, 246, 0.05);
    border-left: 3px solid var(--primary-color);
}

.notification-icon {
    width: 40px;
    height: 40px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    flex-shrink: 0;
}

.notification-info { background: #dbeafe; color: #1d4ed8; }
.notification-success { background: #dcfce7; color: #166534; }
.notification-warning { background: #fef3c7; color: #d97706; }
.notification-error { background: #fee2e2; color: #b91c1c; }

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

.notification-title {
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 0.25rem;
}

.notification-message {
    color: var(--text-secondary);
    font-size: 0.875rem;
    margin-bottom: 0.25rem;
}

.notification-time {
    color: var(--text-secondary);
    font-size: 0.75rem;
}

.notification-actions {
    flex-shrink: 0;
}

.empty-state {
    text-align: center;
    padding: 3rem 2rem;
}

.empty-state-icon {
    font-size: 3rem;
    margin-bottom: 1rem;
    opacity: 0.5;
}

.empty-state-title {
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 0.5rem;
}

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

/* =============================================================================
   SEARCH
   ============================================================================= */

.search-form-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 1.5rem;
    margin-bottom: 2rem;
}

.search-form {
    display: flex;
    gap: 1rem;
}

.search-form input {
    flex: 1;
    padding: 0.75rem 1rem;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    background: var(--bg-primary);
    color: var(--text-primary);
    font-size: 1rem;
}

.search-form input:focus {
    outline: none;
    border-color: var(--primary-color);
}

.search-hint {
    margin-top: 0.5rem;
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.search-result__badges {
    display: flex;
    gap: 0.35rem;
    align-items: center;
    margin-left: 0.5rem;
    flex-shrink: 0;
}

.search-result__badge {
    font-size: 0.7rem;
    padding: 0.2rem 0.45rem;
    border-radius: 6px;
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    white-space: nowrap;
}

.search-result__badge--status {
    background: rgba(16, 185, 129, 0.15);
    color: #16a34a;
}

.search-badges {
    display: flex;
    gap: 0.35rem;
    align-items: center;
    margin-left: 0.5rem;
    flex-shrink: 0;
}

.search-badge {
    font-size: 0.7rem;
    padding: 0.2rem 0.45rem;
    border-radius: 6px;
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    white-space: nowrap;
}

.search-badge--status {
    background: rgba(16, 185, 129, 0.15);
    color: #16a34a;
}

.search-overlay {
    z-index: 1000;
}

.results-summary {
    margin-bottom: 1.5rem;
    color: var(--text-secondary);
}

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

.result-section h3 {
    margin-bottom: 1rem;
    color: var(--text-primary);
    font-size: 1rem;
}

.result-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.result-item {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    text-decoration: none;
    transition: background 0.2s;
}

.result-item:hover {
    background: var(--bg-hover);
}

.result-icon {
    font-size: 1.5rem;
}

.result-content {
    flex: 1;
}

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

.result-subtitle {
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.result-badge {
    padding: 0.25rem 0.5rem;
    font-size: 0.75rem;
    border-radius: 4px;
    background: #e5e7eb;
    color: #4b5563;
}

.result-badge.badge-draft { background: #e5e7eb; color: #4b5563; }
.result-badge.badge-new { background: #dbeafe; color: #1d4ed8; }
.result-badge.badge-confirmed { background: #fef3c7; color: #d97706; }
.result-badge.badge-completed { background: #dcfce7; color: #166534; }
.result-badge.badge-shipped { background: #dcfce7; color: #166534; }
.result-badge.badge-cancelled { background: #fee2e2; color: #b91c1c; }

.empty-results {
    text-align: center;
    padding: 3rem;
}

.empty-icon {
    font-size: 3rem;
    margin-bottom: 1rem;
}

.empty-title {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 0.5rem;
}

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

/* =============================================================================
   PAGINATION
   ============================================================================= */

.pagination-container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem;
    border-top: 1px solid var(--border-color);
    background: var(--bg-secondary);
}

.pagination-info {
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.pagination {
    display: flex;
    gap: 0.25rem;
    align-items: center;
}

.pagination-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 36px;
    height: 36px;
    padding: 0 0.5rem;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-primary);
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    text-decoration: none;
    transition: all 0.15s;
}

.pagination-link:hover:not(.disabled):not(.active) {
    background: var(--bg-hover);
    border-color: var(--primary-color);
    color: var(--primary-color);
}

.pagination-link.active {
    background: var(--primary-color);
    border-color: var(--primary-color);
    color: white;
}

.pagination-link.disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.pagination-ellipsis {
    padding: 0 0.5rem;
    color: var(--text-secondary);
}

@media (max-width: 640px) {
    .pagination-container {
        flex-direction: column;
        gap: 1rem;
    }

    .pagination-link {
        min-width: 32px;
        height: 32px;
        font-size: 0.8125rem;
    }
}

/* =============================================================================
   DOCUMENT HISTORY
   ============================================================================= */

.document-history {
    margin-top: 1.5rem;
    padding: 1rem;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
}

.document-history h4 {
    margin: 0 0 1rem 0;
    font-size: 1rem;
    color: var(--text-primary);
}

.history-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.history-item {
    display: flex;
    gap: 0.75rem;
    padding: 0.5rem;
    background: var(--bg-primary);
    border-radius: 6px;
}

.history-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    font-weight: 600;
    font-size: 0.875rem;
    flex-shrink: 0;
}

.history-create { background: #dcfce7; color: #166534; }
.history-status { background: #dbeafe; color: #1d4ed8; }
.history-post { background: #d1fae5; color: #047857; }
.history-unpost { background: #fef3c7; color: #d97706; }
.history-update { background: #e5e7eb; color: #4b5563; }
.history-delete { background: #fee2e2; color: #b91c1c; }

.history-content {
    flex: 1;
    min-width: 0;
}

.history-description {
    font-size: 0.875rem;
    color: var(--text-primary);
}

.history-meta {
    display: flex;
    gap: 1rem;
    margin-top: 0.25rem;
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.history-user {
    font-weight: 500;
}

/* =============================================================================
   ORDER DETAIL REDESIGN - SIDEBAR SECTIONS
   ============================================================================= */

.order-sidebar {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.sidebar-section {
    padding: 1rem;
    background: var(--bg-secondary);
    border-radius: 10px;
    border: 1px solid var(--border-color);
}

.sidebar-section--danger {
    border-left: 3px solid #dc2626;
}

.sidebar-section--warning {
    border-left: 3px solid #d97706;
}

.sidebar-section--ok {
    border-left: 3px solid #16a34a;
}

.sidebar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.75rem;
}

.sidebar-title {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
}

.sidebar-details {
    background: var(--bg-secondary);
    border-radius: 10px;
    border: 1px solid var(--border-color);
}

.sidebar-details summary {
    padding: 0.75rem 1rem;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-secondary);
    cursor: pointer;
    list-style: none;
}

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

.sidebar-details summary::after {
    content: "+";
    float: right;
    font-weight: 400;
}

.sidebar-details[open] summary::after {
    content: "−";
}

.sidebar-details-content {
    padding: 0 1rem 1rem;
}

/* =============================================================================
   METRIC CARDS
   ============================================================================= */

.metric-highlight {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.metric-value {
    font-size: 1.25rem;
    font-weight: 700;
}

.metric-value--primary {
    color: var(--primary-color);
}

.metric-row {
    display: flex;
    justify-content: space-between;
    padding: 0.5rem 0;
    border-top: 1px solid var(--border-color);
    font-size: 0.875rem;
}

.metric-row:first-child {
    border-top: none;
    padding-top: 0;
}

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

/* =============================================================================
   RAG BADGES
   ============================================================================= */

.badge-rag--danger {
    background: #fee2e2;
    color: #b91c1c;
}

.badge-rag--warning {
    background: #fef3c7;
    color: #92400e;
}

.badge-rag--ok {
    background: #dcfce7;
    color: #166534;
}

/* =============================================================================
   PROGRESS BAR (full width)
   ============================================================================= */

.progress-bar-full {
    position: relative;
    height: 24px;
    background: var(--bg-tertiary);
    border-radius: 12px;
    overflow: hidden;
    margin-bottom: 0.5rem;
}

.progress-bar-fill {
    height: 100%;
    border-radius: 12px;
    transition: width 0.3s ease;
}

.progress-bar--danger .progress-bar-fill {
    background: #dc2626;
}

.progress-bar--warning .progress-bar-fill {
    background: #d97706;
}

.progress-bar--ok .progress-bar-fill {
    background: #16a34a;
}

.progress-bar-label {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-primary);
}

/* Progress width classes (no inline styles) */
.progress-w-0 { width: 0; }
.progress-w-5 { width: 5%; }
.progress-w-10 { width: 10%; }
.progress-w-15 { width: 15%; }
.progress-w-20 { width: 20%; }
.progress-w-25 { width: 25%; }
.progress-w-30 { width: 30%; }
.progress-w-35 { width: 35%; }
.progress-w-40 { width: 40%; }
.progress-w-45 { width: 45%; }
.progress-w-50 { width: 50%; }
.progress-w-55 { width: 55%; }
.progress-w-60 { width: 60%; }
.progress-w-65 { width: 65%; }
.progress-w-70 { width: 70%; }
.progress-w-75 { width: 75%; }
.progress-w-80 { width: 80%; }
.progress-w-85 { width: 85%; }
.progress-w-90 { width: 90%; }
.progress-w-95 { width: 95%; }
.progress-w-100 { width: 100%; }

/* =============================================================================
   PROMISE / ATP-CTP
   ============================================================================= */

.promise-info {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
}

.promise-date {
    font-size: 1.1rem;
    font-weight: 700;
}

.promise-reason {
    font-size: 0.8rem;
    margin-bottom: 0.5rem;
}

.badge-mode {
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    font-size: 0.7rem;
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
}

/* Chain mini visualization */
.chain-mini {
    display: flex;
    align-items: center;
    gap: 0;
    margin-top: 0.5rem;
}

.chain-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--border-color);
}

.chain-dot--done {
    background: #16a34a;
}

.chain-dot--active {
    background: #2563eb;
}

.chain-dot--pending {
    background: var(--border-color);
}

.chain-connector {
    width: 12px;
    height: 2px;
    background: var(--border-color);
}

/* =============================================================================
   STATUS BUTTONS
   ============================================================================= */

.status-buttons {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.status-buttons form {
    display: contents;
}

.status-buttons .btn {
    width: 100%;
    justify-content: flex-start;
}

/* =============================================================================
   QUICK ACTIONS
   ============================================================================= */

.quick-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.quick-actions form {
    display: contents;
}

/* =============================================================================
   TAB BADGES
   ============================================================================= */

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

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

.tab-badge--danger {
    background: #fee2e2;
    color: #b91c1c;
}

/* =============================================================================
   TABS CONTAINER
   ============================================================================= */

.tabs-container {
    width: 100%;
}

.tab-panel {
    display: none;
}

.tab-panel.active {
    display: block;
}

/* =============================================================================
   COLLAPSIBLE SECTION
   ============================================================================= */

.collapsible-section {
    margin-top: 1rem;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 10px;
}

.collapsible-section summary {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 1rem;
    cursor: pointer;
    font-weight: 600;
    color: var(--text-secondary);
    list-style: none;
}

.collapsible-section summary::-webkit-details-marker {
    display: none;
}

.collapsible-section summary::after {
    content: "▼";
    font-size: 0.75rem;
    transition: transform 0.2s;
}

.collapsible-section[open] summary::after {
    transform: rotate(180deg);
}

.collapsible-section summary:hover {
    color: var(--text-primary);
}

.collapsible-content {
    padding: 0 1rem 1rem;
}

.collapsible-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

.collapsible-subsection {
    margin-top: 1rem;
}

@media (max-width: 768px) {
    .collapsible-grid {
        grid-template-columns: 1fr;
    }
}

/* Sidebar form spacing */
.sidebar-form {
    margin-top: 0.5rem;
}

/* Block button */
.btn-block {
    width: 100%;
}

/* =============================================================================
   ALERT
   ============================================================================= */

.alert {
    padding: 0.75rem 1rem;
    border-radius: 8px;
    margin-bottom: 1rem;
    font-size: 0.875rem;
}

.alert-warning {
    background: #fef3c7;
    border: 1px solid #fde68a;
    color: #92400e;
}

.alert-danger {
    background: #fee2e2;
    border: 1px solid #fecaca;
    color: #b91c1c;
}

.alert-info {
    background: #dbeafe;
    border: 1px solid #bfdbfe;
    color: #1e40af;
}

/* =============================================================================
   ORDER DETAIL MOBILE ADAPTATION
   ============================================================================= */

@media (max-width: 768px) {
    /* Sidebar to top on mobile */
    .order-sidebar {
        order: -1;
    }

    /* Pipeline scrollable */
    .pipeline-stepper {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        padding-bottom: 0.5rem;
    }

    .pipeline-stage {
        min-width: 70px;
    }

    .pipeline-label {
        font-size: 0.65rem;
    }

    /* Tabs scrollable */
    .tabs {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        flex-wrap: nowrap;
        gap: 0;
    }

    .tabs .tab {
        flex-shrink: 0;
    }
}

/* =============================================================================
   ORDER DETAIL V2 - SALES MANAGER VIEW
   ============================================================================= */

.order-header {
    margin-bottom: 1rem;
}

.order-header-main {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.order-title {
    font-size: 1.5rem;
    font-weight: 700;
    margin: 0;
}

.order-date {
    color: var(--text-secondary);
    font-size: 0.875rem;
}

.order-parties {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-top: 0.5rem;
    font-size: 0.9rem;
    flex-wrap: wrap;
}

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

.party-arrow {
    color: var(--text-muted);
    font-weight: 600;
}

.party-to {
    font-weight: 600;
    color: var(--primary-color);
}

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

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

/* Order Meta - creation/modification info */
.order-meta {
    font-size: 0.7rem;
    color: var(--text-muted);
    padding: 0.5rem 0;
    text-align: right;
}

/* Key Metrics Bar */
.key-metrics {
    display: flex;
    gap: 1rem;
    margin-bottom: 1rem;
    flex-wrap: wrap;
}

.key-metric {
    flex: 1;
    min-width: 120px;
    max-width: 200px;
    padding: 0.75rem 1rem;
    background: var(--bg-secondary);
    border-radius: 10px;
    border: 1px solid var(--border-color);
}

.key-metric--amount {
    border-left: 3px solid var(--primary-color);
}

.key-metric--danger {
    border-left: 3px solid #dc2626;
}

.key-metric--warning {
    border-left: 3px solid #d97706;
}

.key-metric--ok {
    border-left: 3px solid #16a34a;
}

.key-metric--info {
    border-left: 3px solid #6b7280;
}

.key-metric-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.key-metric-value {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-primary);
}

.key-metric-label {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-secondary);
    margin-top: 0.125rem;
}

.key-metric-sub {
    font-size: 0.75rem;
    margin-top: 0.25rem;
}

.badge-sm {
    font-size: 0.65rem;
    padding: 0.125rem 0.375rem;
}

/* Chain mini compact */
.chain-mini-compact {
    display: flex;
    gap: 3px;
    margin-top: 0.25rem;
}

.chain-dot-sm {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--border-color);
}

.chain-dot-sm.chain-dot--done {
    background: #16a34a;
}

.chain-dot-sm.chain-dot--active {
    background: #2563eb;
}

.prediction-chain--vertical {
    display: grid;
    gap: 8px;
}

.prediction-flow {
    display: grid;
    grid-template-columns: 1fr;
    justify-items: start;
    gap: 6px;
}

.prediction-arrow {
    color: #9ca3af;
    font-size: 12px;
    line-height: 1;
    margin-left: 8px;
}

.prediction-meta {
    display: grid;
    gap: 4px;
    color: #6b7280;
    font-size: 12px;
}

/* Pipeline Compact */
.pipeline-compact {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 0.5rem 0;
    margin-bottom: 1rem;
}

.pip {
    width: 24px;
    height: 6px;
    border-radius: 3px;
    background: var(--border-color);
    transition: background 0.2s;
}

.pip.done {
    background: #16a34a;
}

.pip.active {
    background: var(--primary-color);
    animation: pulse 1.5s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.6; }
}

/* Order Content */
.order-content {
    margin-bottom: 1rem;
}

/* Data Table Compact */
.data-table--compact {
    font-size: 0.875rem;
}

.data-table--compact th,
.data-table--compact td {
    padding: 0.5rem 0.75rem;
}

.data-table tr.row-mismatch td {
    box-shadow: inset 4px 0 0 rgba(245, 158, 11, 0.85);
}

.data-table tr.row-org-mismatch td {
    box-shadow: inset 4px 0 0 rgba(37, 99, 235, 0.9);
}

.data-table tr.row-mismatch.row-org-mismatch td {
    box-shadow: inset 4px 0 0 rgba(245, 158, 11, 0.85), inset 8px 0 0 rgba(37, 99, 235, 0.9);
}

.focus-legend {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.6rem;
    margin-top: 0.5rem;
    font-size: 0.8rem;
    color: var(--text-secondary);
}

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

.focus-legend__item {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
}

.legend-swatch {
    width: 12px;
    height: 12px;
    border-radius: 3px;
    border: 1px solid rgba(245, 158, 11, 0.35);
    background: rgba(245, 158, 11, 0.12);
    box-shadow: inset 4px 0 0 rgba(245, 158, 11, 0.85);
}

.legend-swatch--warehouse {
    border-color: rgba(245, 158, 11, 0.35);
    background: rgba(245, 158, 11, 0.12);
    box-shadow: inset 4px 0 0 rgba(245, 158, 11, 0.85);
}

.legend-swatch--org {
    border-color: rgba(37, 99, 235, 0.35);
    background: rgba(37, 99, 235, 0.12);
    box-shadow: inset 4px 0 0 rgba(37, 99, 235, 0.9);
}

.focus-toolbar {
    position: sticky;
    top: 0;
    z-index: 5;
    margin: -0.75rem -0.75rem 0;
    padding: 0.75rem 0.75rem 0.6rem;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
    box-shadow: 0 12px 16px -16px rgba(16, 24, 40, 0.35);
}

/* Access Matrix */
.access-matrix th,
.access-matrix td {
    vertical-align: middle;
}

.access-matrix .matrix-module {
    font-weight: 600;
}

.access-matrix .matrix-preset select,
.access-matrix .matrix-scope select {
    min-width: 140px;
}

.access-matrix .matrix-extra {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 28px;
    height: 24px;
    padding: 0 6px;
    border-radius: 999px;
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    font-size: 0.75rem;
}

@media (max-width: 960px) {
    .access-matrix .matrix-preset select,
    .access-matrix .matrix-scope select {
        min-width: 120px;
    }
}

/* Alert Compact */
.alert-compact {
    padding: 0.5rem 0.75rem;
    margin-bottom: 0.75rem;
    font-size: 0.8rem;
}

/* Empty State */
.empty-state {
    padding: 2rem;
    text-align: center;
    color: var(--text-secondary);
}

/* Details Grid */
.details-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
}

.details-block {
    padding: 0.75rem;
    background: var(--bg-tertiary);
    border-radius: 8px;
}

.details-block--full {
    grid-column: 1 / -1;
}

.details-title {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-secondary);
    margin-bottom: 0.25rem;
}

.details-value {
    font-weight: 500;
}

.details-sub {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-top: 0.125rem;
}

.details-meta {
    margin-top: 1rem;
    padding-top: 0.75rem;
    border-top: 1px solid var(--border-color);
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* Order Footer - Sticky Action Bar */
.order-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    padding: 0.625rem 2rem;
    background: var(--bg-secondary);
    border-top: 1px solid var(--border-color);
    flex-wrap: wrap;
    position: sticky;
    bottom: 0;
    z-index: 80;
    margin: 1rem -2rem -2rem;
    box-shadow: 0 -2px 8px rgba(0, 0, 0, 0.05);
}

.order-footer-left,
.order-footer-right {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.order-footer-center {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.status-change {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.status-change form {
    display: contents;
}

.status-change__select {
    min-width: 160px;
    font-size: 0.8rem;
}

.status-change__hint {
    font-size: 0.78rem;
    color: var(--text-secondary);
    padding: 0.25rem 0.5rem;
    background: var(--bg-tertiary);
    border-radius: 999px;
}

.status-flow {
    margin-top: 0.5rem;
    padding: 0.5rem 0.75rem;
    background: var(--bg-tertiary);
    border-radius: 10px;
    border: 1px solid var(--border-color);
}

.status-flow-title {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-secondary);
    margin-bottom: 0.4rem;
}

.status-flow-items {
    display: grid;
    gap: 0.35rem;
}

.status-flow-item {
    display: flex;
    gap: 0.4rem;
    flex-wrap: wrap;
    align-items: center;
    font-size: var(--font-sm-plus);
    color: var(--text-primary);
}

.status-flow-item.is-blocked {
    color: var(--text-secondary);
}

.status-flow-name {
    font-weight: 600;
}

.status-flow-reason {
    font-size: var(--font-xs-plus);
    color: var(--text-secondary);
}

.status-flow--inline {
    margin-top: 0.25rem;
    padding: 0.25rem 0.5rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    justify-content: flex-end;
    width: 100%;
}

.status-flow--inline .status-flow-title {
    margin: 0;
    white-space: nowrap;
}

.status-flow--inline .status-flow-items {
    display: flex;
    flex-wrap: nowrap;
    gap: 0.45rem;
    overflow-x: auto;
    scrollbar-width: thin;
    justify-content: flex-end;
}

.status-flow--inline .status-flow-item {
    white-space: nowrap;
}

@media (max-width: 768px) {
    .order-header-main {
        flex-direction: column;
        align-items: flex-start;
    }

    .key-metrics {
        flex-direction: column;
    }

    .key-metric {
        max-width: none;
    }

    .order-footer {
        flex-direction: column;
        align-items: stretch;
        gap: 0.5rem;
        padding: 0.625rem 1rem;
        margin: 1rem -1rem -1rem;
    }

    .order-footer-left,
    .order-footer-center,
    .order-footer-right {
        justify-content: center;
        flex-wrap: wrap;
    }

    .pipeline-compact {
        justify-content: center;
    }
}

/* =============================================================================
   SITE HEADER V2 - COMPACT PROFESSIONAL
   ============================================================================= */

.site-header-v2 {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 8px 2rem;
    position: sticky;
    top: 0;
    z-index: 100;
    margin: 0 -2rem;
}

.site-header-v2::before {
    content: '';
    position: absolute;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 100vw;
    height: 100%;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
    z-index: -1;
}

.header-brand {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    text-decoration: none;
    flex-shrink: 0;
}

.brand-mark {
    width: 28px;
    height: 28px;
    background: var(--primary-color);
    color: white;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.02em;
}

.brand-mark--lg {
    width: 42px;
    height: 42px;
    font-size: 0.9rem;
}

.auth-card__brand {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
}

.auth-card__brand h1 {
    margin: 0;
}

.brand-name {
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -0.02em;
}

.header-nav {
    display: flex;
    align-items: center;
    gap: 2px;
    flex: 1;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
}

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

.nav-item {
    position: relative;
    padding: 8px 14px;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
    text-decoration: none;
    border-radius: 6px;
    white-space: nowrap;
    transition: all 0.15s ease;
}

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

.nav-item.active {
    color: var(--primary-color);
    background: var(--bg-card);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

.nav-item.active::after {
    content: '';
    position: absolute;
    bottom: -1px;
    left: 50%;
    transform: translateX(-50%);
    width: 20px;
    height: 2px;
    background: var(--primary-color);
    border-radius: 1px;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 4px;
    flex-shrink: 0;
    margin-left: 8px;
    padding-left: 12px;
    border-left: 1px solid var(--border-color);
}

.header-icon-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    color: var(--text-secondary);
    border-radius: 8px;
    transition: all 0.15s;
    position: relative;
}

.header-icon-btn:hover {
    color: var(--text-primary);
    background: var(--bg-card);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
}

.header-icon-btn.active {
    color: var(--primary-color);
    background: rgba(59, 130, 246, 0.1);
}

.notif-badge {
    position: absolute;
    top: 2px;
    right: 2px;
    min-width: 14px;
    height: 14px;
    padding: 0 3px;
    font-size: 0.6rem;
    font-weight: 700;
    color: white;
    background: #dc2626;
    border-radius: 7px;
    display: none;
}

.notif-badge:not(:empty) {
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Header Pulse - компактные метрики */
.header-pulse {
    display: flex;
    align-items: center;
    margin-right: 4px;
}
.pulse-link {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 10px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    text-decoration: none;
    font-size: 12px;
    font-weight: 600;
    transition: all 0.15s;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
}
.pulse-link:hover {
    background: var(--bg-hover);
    border-color: var(--border-hover, #d1d5db);
}
.pulse-item {
    display: inline-flex;
    align-items: center;
    padding: 0.125rem 0.375rem;
    border-radius: 4px;
    color: var(--text-secondary, #555);
}
.pulse-otd { color: #16a34a; }
.pulse-wip { color: #2563eb; }
.pulse-esc {
    background: #fef2f2;
    color: #dc2626;
}

/* Tasks badge */
.header-tasks-btn {
    position: relative;
}
.tasks-badge {
    position: absolute;
    top: 2px;
    right: 2px;
    min-width: 14px;
    height: 14px;
    padding: 0 3px;
    font-size: 0.6rem;
    font-weight: 700;
    color: white;
    background: #2563eb;
    border-radius: 10px;
    display: none;
}
.tasks-badge:not(:empty) {
    display: flex;
    align-items: center;
    justify-content: center;
}
.tasks-badge--alert {
    background: #dc2626;
}

/* Approvals badge */
.approvals-badge {
    position: absolute;
    top: 2px;
    right: 2px;
    min-width: 14px;
    height: 14px;
    background: #f59e0b;
    color: white;
    font-size: 10px;
    font-weight: 600;
    border-radius: 7px;
    padding: 0 4px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.header-profile {
    position: relative;
}

.header-profile .dropdown-menu {
    display: block;
}

.header-profile .dropdown-menu.open {
    display: block;
}

.profile-trigger {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.25rem;
    background: transparent;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    cursor: pointer;
    color: var(--text-secondary);
}

.profile-trigger:hover {
    background: var(--bg-hover);
    border-color: var(--text-muted);
}

:root { --font-main: 'Inter', system-ui, -apple-system, sans-serif; }

/* Header */
.site-header {
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
    position: sticky;
    top: 0;
    z-index: 100;
}
.header-inner {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 1.5rem;
    height: 56px;
    display: flex;
    align-items: center;
    gap: 2rem;
}
.header-logo {
    font-weight: 700;
    font-size: 1.125rem;
    color: var(--text-primary);
    text-decoration: none;
    letter-spacing: -0.5px;
}
.header-nav {
    display: flex;
    gap: 0.25rem;
    flex: 1;
}
.nav-link {
    padding: 0.5rem 0.75rem;
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.875rem;
    font-weight: 500;
    border-radius: 6px;
    transition: all 0.15s;
}
.nav-link:hover {
    color: var(--text-primary);
    background: var(--bg-hover);
}
.nav-link.active {
    color: var(--primary-color);
    background: rgba(59, 130, 246, 0.1);
}
.header-right {
    display: flex;
    align-items: center;
    gap: 1rem;
}
.search-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0.5rem;
    color: var(--text-secondary);
    border-radius: 6px;
    transition: all 0.15s;
}
.search-btn:hover {
    color: var(--text-primary);
    background: var(--bg-hover);
}
.notification-btn {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0.5rem;
    color: var(--text-secondary);
    border-radius: 6px;
    transition: all 0.15s;
    text-decoration: none;
}
.notification-btn:hover {
    color: var(--text-primary);
    background: var(--bg-hover);
}
.notification-badge {
    position: absolute;
    top: 2px;
    right: 2px;
    min-width: 16px;
    height: 16px;
    padding: 0 4px;
    font-size: 0.625rem;
    font-weight: 600;
    color: white;
    background: #dc2626;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
}
.btn-login {
    padding: 0.5rem 1rem;
    background: var(--primary-color);
    color: white;
    text-decoration: none;
    border-radius: 6px;
    font-size: 0.875rem;
    font-weight: 500;
}

/* Profile dropdown */
.profile-dropdown { position: relative; }
.profile-btn {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.375rem 0.5rem;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    cursor: pointer;
    color: var(--text-primary);
    font-size: 0.875rem;
    font-family: inherit;
}
.profile-btn:hover { background: var(--bg-hover); }
.avatar {
    width: 28px;
    height: 28px;
    background: var(--primary-color);
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    font-weight: 600;
}
.profile-name {
    max-width: 160px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-weight: 600;
}
.site-header .profile-name {
    color: var(--text-primary);
}
.site-header .profile-btn svg {
    color: var(--text-secondary);
}
.dropdown-menu {
    position: absolute;
    top: calc(100% + 4px);
    right: 0;
    min-width: 200px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    opacity: 0;
    visibility: hidden;
    transform: translateY(-8px);
    transition: all 0.15s;
    z-index: 1000;
}
.dropdown-menu.open,
.header-profile:hover .dropdown-menu {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
    pointer-events: auto;
}
.dropdown-header { padding: 0.75rem 1rem; }
.dropdown-user { font-weight: 600; color: var(--text-primary); }
.dropdown-email { font-size: 0.75rem; color: var(--text-secondary); margin-top: 0.125rem; }
.dropdown-divider { height: 1px; background: var(--border-color); margin: 0.25rem 0; }
.dropdown-item {
    display: block;
    padding: 0.5rem 1rem;
    color: var(--text-primary);
    text-decoration: none;
    font-size: 0.875rem;
}
.dropdown-item:hover { background: var(--bg-hover); }
.dropdown-item--danger { color: #dc2626; }
.dropdown-section { padding: 0.25rem 0; }
.dropdown-section-title {
    padding: 0.35rem 1rem 0.25rem;
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-secondary);
}
.dropdown-section-subtitle {
    padding: 0.25rem 1rem 0.1rem;
    font-size: 0.75rem;
    color: var(--text-tertiary);
}
.dropdown-language { display: grid; gap: 0.25rem; }
.dropdown-language-btn { font-weight: 500; }

.about-core {
    margin: 0 0 1rem;
    font-weight: 600;
}
.about-group { margin-bottom: 1rem; }
.about-group-title {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
}
.about-group-list { display: grid; gap: 0.5rem; }
.about-module-row {
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 0.5rem 0.75rem;
    background: var(--bg-secondary);
}
.about-module-main {
    display: flex;
    justify-content: space-between;
    gap: 0.75rem;
    font-weight: 600;
}
.about-module-version { color: var(--text-secondary); font-weight: 500; }
.about-module-meta {
    font-size: 0.75rem;
    color: var(--text-tertiary);
    margin-top: 0.2rem;
}
.about-module-deps {
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-top: 0.3rem;
}

/* Toast */
.toast-container {
    position: fixed;
    bottom: 1rem;
    right: 1rem;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}
.toast {
    padding: 0.75rem 1rem;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    animation: slideIn 0.3s ease;
}
.toast.success { border-left: 3px solid #16a34a; }
.toast.error { border-left: 3px solid #dc2626; }
.toast.warning { border-left: 3px solid #d97706; }
.toast.fade-out { opacity: 0; transition: opacity 0.3s; }
@keyframes slideIn {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

/* Main Content Container */
#main-content {
    max-width: none;
    margin: 0;
}

/* Page Content - унифицированные стили для контента страниц */
.page-content {
    padding: 1rem 0 2.5rem;
}

/* Mobile Menu Button */
.mobile-menu-btn {
    display: none;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    background: transparent;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    color: var(--text-primary);
}
.mobile-menu-btn:hover {
    background: var(--bg-hover);
}

/* Mobile Drawer */
.mobile-drawer-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 200;
    opacity: 0;
    transition: opacity 0.3s;
}
.mobile-drawer-overlay.open {
    opacity: 1;
}
.mobile-drawer {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: 280px;
    max-width: 85vw;
    background: var(--bg-secondary);
    z-index: 201;
    transform: translateX(-100%);
    transition: transform 0.3s ease;
    display: flex;
    flex-direction: column;
}
.mobile-drawer.open {
    transform: translateX(0);
}
.mobile-drawer-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem;
    border-bottom: 1px solid var(--border-color);
}
.mobile-drawer-header .header-logo {
    font-size: 1.25rem;
}
.mobile-drawer-close {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    color: var(--text-secondary);
}
.mobile-drawer-close:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}
.mobile-drawer-nav {
    flex: 1;
    overflow-y: auto;
    padding: 1rem 0;
}
.mobile-nav-link {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.875rem 1.25rem;
    color: var(--text-primary);
    text-decoration: none;
    font-size: 1rem;
    font-weight: 500;
    transition: background 0.15s;
}
.mobile-nav-link:hover {
    background: var(--bg-hover);
}
.mobile-nav-link.active {
    color: var(--primary-color);
    background: rgba(27, 94, 59, 0.08);
    border-left: 3px solid var(--primary-color);
    padding-left: calc(1.25rem - 3px);
}
.mobile-nav-link svg {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
}
.mobile-drawer-footer {
    padding: 1rem;
    border-top: 1px solid var(--border-color);
}
.mobile-user-info {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem;
    background: var(--bg-hover);
    border-radius: 8px;
    margin-bottom: 0.75rem;
}
.mobile-user-info .avatar {
    width: 40px;
    height: 40px;
    font-size: 0.875rem;
}
.mobile-user-name {
    font-weight: 600;
    color: var(--text-primary);
}
.mobile-user-email {
    font-size: 0.75rem;
    color: var(--text-secondary);
}
.mobile-logout-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    width: 100%;
    padding: 0.75rem;
    background: transparent;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    color: #dc2626;
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    font-family: inherit;
}
.mobile-logout-btn:hover {
    background: #fef2f2;
    border-color: #fecaca;
}

/* Mobile */
@media (max-width: 900px) {
    .header-nav { display: none; }
    .profile-name { display: none; }
    .mobile-menu-btn { display: flex; }
    .mobile-drawer-overlay { display: block; }
}

@media (max-width: 768px) {
    .page-content {
        padding: 1rem;
    }
    /* Улучшение touch-таргетов */
    .btn, .btn-secondary {
        min-height: 44px;
        padding: 0.75rem 1rem;
    }
    .form-group input,
    .form-group select,
    .form-group textarea {
        min-height: 44px;
        font-size: 16px; /* Prevent zoom on iOS */
    }
    /* Таблицы с горизонтальным скроллом */
    .table-responsive {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        margin: 0 -1rem;
        padding: 0 1rem;
    }
    .table-responsive .data-table {
        min-width: 600px;
    }
    /* Toast в центре внизу */
    .toast-container {
        left: 1rem;
        right: 1rem;
        bottom: 1rem;
    }
    .toast {
        width: 100%;
    }
    /* Скрыть search и notification на очень узких экранах */
    .header-right .search-btn,
    .header-right .notification-btn {
        padding: 0.625rem;
    }
}

@media (max-width: 480px) {
    .header-inner {
        padding: 0 1rem;
        gap: 0.75rem;
    }
    .page-content {
        padding: 0.75rem;
    }
    .profile-dropdown {
        display: none;
    }
}

.auth-page .site-header-v2,
.auth-page .site-footer {
    display: none;
}

.avatar-sm {
    width: 22px;
    height: 22px;
    background: var(--primary-color);
    color: white;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.65rem;
    font-weight: 600;
}

.btn-sm {
    padding: 0.375rem 0.75rem;
    font-size: 0.8rem;
}

/* Hide old topbar and nav-tabs */
.topbar,
.nav-tabs {
    display: none !important;
}

/* =============================================================================
   APP SHELL LAYOUT - STICKY HEADER/FOOTER
   ============================================================================= */

.app-shell {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    padding: 0 2rem;
}

.app-shell > main {
    flex: 1;
    padding: 1rem 0 2rem;
}

.site-footer {
    position: static;
    height: auto;
    padding: 0.75rem 0;
    border-top: 1px solid var(--border-color);
    font-size: 0.7rem;
    color: var(--text-muted);
    text-align: center;
    margin: 0 -2rem;
    padding: 0.75rem 2rem;
    background: var(--bg-secondary);
    box-shadow: none;
}

.app-shell > main,
#main-content {
    padding-bottom: 2rem !important;
}

/* =============================================================================
   PAGE HEADER - STICKY BREADCRUMBS + TITLE
   ============================================================================= */

.page-header-sticky {
    position: sticky;
    top: 44px; /* height of site-header-v2 */
    z-index: 90;
    background: var(--bg-primary);
    padding: 0.75rem 0;
    margin: 0 -2rem 1rem;
    padding-left: 2rem;
    padding-right: 2rem;
    border-bottom: 1px solid var(--border-color);
}

.page-header-sticky .breadcrumbs {
    margin-bottom: 0.25rem;
}

.page-header-sticky h1 {
    font-size: 1.25rem;
    margin: 0;
}

/* =============================================================================
   HEADER MOBILE
   ============================================================================= */

@media (max-width: 960px) {
    .app-shell {
        padding: 0 1.25rem;
    }

    .site-header-v2 {
        margin: 0 -1.25rem;
        padding: 0.5rem 1.25rem;
    }

    .site-footer {
        margin: 0 -1.25rem;
        padding: 0.75rem 1.25rem;
    }

    .page-header-sticky {
        margin: 0 -1.25rem 1rem;
        padding-left: 1.25rem;
        padding-right: 1.25rem;
    }

    .brand-name {
        display: none;
    }

    .nav-item {
        font-size: 0.7rem;
        padding: 0.3rem 0.4rem;
    }
}

@media (max-width: 768px) {
    .site-header-v2 {
        padding: 0.5rem 1rem;
    }

    .site-footer {
        padding: 0.75rem 1rem;
    }
}

@media (max-width: 720px) {
    .site-header-v2 {
        flex-wrap: wrap;
        gap: 0.5rem;
    }

    .header-nav {
        order: 3;
        width: 100%;
        padding-bottom: 0.25rem;
        margin-top: -0.25rem;
    }

    .nav-item {
        font-size: 0.65rem;
        padding: 0.25rem 0.375rem;
    }

    .page-header-sticky {
        top: 72px; /* taller header on mobile */
    }
}

@media (max-width: 480px) {
    .app-shell {
        padding: 0 0.75rem;
    }

    .ui-page {
        padding-left: 0.75rem;
        padding-right: 0.75rem;
    }

    .site-header-v2 {
        margin: 0 -0.75rem;
        padding: 0.5rem 0.75rem;
    }

    .site-footer {
        margin: 0 -0.75rem;
        padding: 0.75rem 0.75rem;
    }

    .page-header-sticky {
        margin: 0 -0.75rem 0.75rem;
        padding-left: 0.75rem;
        padding-right: 0.75rem;
    }
}

/* =============================================================================
   DOCUMENT HEADER (PROFESSIONAL STYLE)
   ============================================================================= */

.doc-header {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 0.85rem 1rem;
    margin-bottom: 1rem;
}

.doc-title-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    margin-bottom: 0.35rem;
    padding-bottom: 0.35rem;
    border-bottom: 1px solid var(--border-color);
}

.doc-top-main {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
    flex: 1 1 360px;
    min-width: 0;
}

.doc-top-status {
    display: flex;
    align-items: center;
    flex: 0 1 520px;
    justify-content: flex-end;
}

.doc-top-status .status-block {
    width: 100%;
}

.doc-title {
    font-size: var(--font-xl);
    font-weight: 700;
    margin: 0;
    color: var(--text-primary);
    grid-column: 2;
    text-align: center;
    justify-self: center;
}

.doc-date {
    font-weight: 400;
    color: var(--text-secondary);
    font-size: var(--font-sm);
}

.doc-actions {
    grid-column: 3;
    justify-self: end;
    margin-left: 0;
}

.doc-info-row--status .doc-label,
.doc-info-row--status .doc-value {
    padding-bottom: 0.625rem;
    border-bottom: 1px dashed var(--border-color);
}

.doc-info-row--status .doc-value {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

/* Status Block - contains main status bar and sub-status bar */
.status-block {
    display: flex;
    flex-direction: column;
    gap: 4px;
    flex: 0 1 360px;
    min-height: 52px; /* Compact height for status + sub-status */
}

/* Status Progress Bar */
.status-progress-bar {
    display: flex;
    align-items: center;
    gap: 3px;
}

.status-segment {
    height: 6px;
    flex: 1;
    border-radius: 3px;
    transition: all 0.2s ease;
    overflow: hidden;
}

.status-segment-label {
    display: none;
}

/* Dynamic status colors via CSS variables from --status-color */
.status-segment {
    --status-color: #6b7280;
    background: color-mix(in srgb, var(--status-color) 25%, transparent);
}

.status-segment.passed {
    background: var(--status-color);
}

/* Current status - larger with label */
.status-segment.current {
    flex: 0 0 auto;
    height: 26px;
    padding: 0 12px;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.status-segment.current .status-segment-label {
    display: block;
    font-size: var(--font-xs);
    font-weight: 600;
    color: #fff;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    white-space: nowrap;
}

/* Sub-status bar for "В работе" status */
.sub-status-bar {
    display: flex;
    align-items: center;
    gap: 3px;
}

.sub-status-segment {
    height: 6px;
    flex: 1;
    border-radius: 3px;
    transition: all 0.2s ease;
    overflow: hidden;
    cursor: help;
}

.sub-status-label {
    display: none;
}

/* Dynamic sub-status colors via CSS variables from --sub-status-color */
.sub-status-segment {
    --sub-status-color: #6b7280;
    background: color-mix(in srgb, var(--sub-status-color) 25%, transparent);
}

.sub-status-segment.passed {
    background: var(--sub-status-color);
}

/* Current sub-status - larger with label */
.sub-status-segment.current {
    flex: 0 0 auto;
    height: 22px;
    padding: 0 10px;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--sub-status-color);
}

.sub-status-segment.current .sub-status-label {
    display: block;
    font-size: var(--font-xxs);
    font-weight: 600;
    color: #fff;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    white-space: nowrap;
}

.doc-body {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 2rem;
    align-items: start;
}

.doc-info {
    display: table;
    border-collapse: collapse;
}

.doc-info-row {
    display: table-row;
}

.doc-label {
    display: table-cell;
    min-width: 100px;
    padding: 0.375rem 1rem 0.375rem 0;
    font-size: var(--font-xs);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    white-space: nowrap;
    vertical-align: middle;
    text-align: left;
}

.doc-value {
    display: table-cell;
    padding: 0.375rem 0;
    font-size: var(--font-md);
    color: var(--text-primary);
    font-weight: 500;
    vertical-align: middle;
}

.doc-value a {
    color: var(--primary-color);
    text-decoration: none;
}

.doc-value a:hover {
    text-decoration: underline;
}

/* Metrics grid 2x2 */
.doc-metrics {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.375rem;
    width: 320px;
}

.page-content[data-view-mode="a"] #fulfillment-snapshot .doc-metrics,
.page-content[data-view-mode="b"] #fulfillment-snapshot .doc-metrics,
.page-content[data-view-mode="c"] #fulfillment-snapshot .doc-metrics {
    width: 100%;
    grid-template-columns: repeat(3, minmax(150px, 1fr));
}

.sales-metrics {
    width: 100%;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
}

.metric-card {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0.625rem;
    background: var(--bg-tertiary);
    border-radius: 6px;
    border-left: 2px solid var(--border-color);
}

.metric-card--neutral {
    border-left-color: var(--border-color);
}

.metric-card--ok {
    border-left-color: #10b981;
    background: linear-gradient(90deg, rgba(16, 185, 129, 0.06) 0%, var(--bg-tertiary) 100%);
}

.metric-card--warning {
    border-left-color: #f59e0b;
    background: linear-gradient(90deg, rgba(245, 158, 11, 0.06) 0%, var(--bg-tertiary) 100%);
}

.metric-card--danger {
    border-left-color: #dc2626;
    background: linear-gradient(90deg, rgba(220, 38, 38, 0.06) 0%, var(--bg-tertiary) 100%);
}

.metric-main {
    display: flex;
    align-items: baseline;
    gap: 0.125rem;
    flex-shrink: 0;
}

.metric-value {
    font-size: 1rem;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1;
}

.metric-currency {
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--text-secondary);
}

.metric-meta {
    display: flex;
    flex-direction: column;
    gap: 0;
    margin-left: auto;
    text-align: right;
    min-width: 0;
}

/* Approval panel */
.approval-panel {
    margin-top: 1.25rem;
    padding: 1rem;
    border-radius: 14px;
    border: 1px solid var(--border-color);
    background: var(--bg-secondary);
}

.approval-panel__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    flex-wrap: wrap;
    margin-bottom: 0.75rem;
}

.section-title {
    margin: 0;
    font-size: var(--font-md);
    font-weight: 700;
}

.section-subtitle {
    color: var(--text-secondary);
    font-size: var(--font-sm);
}

.approval-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 1rem;
}

.approval-card {
    display: flex;
    flex-direction: column;
    gap: 0.55rem;
    padding: 0.75rem;
    border-radius: 12px;
    border: 1px solid var(--border-color);
    background: var(--bg-primary);
    min-height: 160px;
}

.approval-card__top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
}

.approval-card__title {
    font-size: 0.9rem;
    font-weight: 700;
}

.approval-card__meta {
    font-size: 0.78rem;
    color: var(--text-secondary);
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
}

.approval-card__actions {
    margin-top: auto;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.approval-badge {
    font-size: 0.68rem;
    font-weight: 700;
    padding: 0.2rem 0.5rem;
    border-radius: 999px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    border: 1px solid transparent;
}

.approval-badge--success {
    background: #dcfce7;
    color: #166534;
    border-color: #86efac;
}

.approval-badge--warning {
    background: #fef3c7;
    color: #92400e;
    border-color: #fcd34d;
}

.approval-badge--danger {
    background: #fee2e2;
    color: #991b1b;
    border-color: #fecaca;
}

.approval-badge--neutral {
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    border-color: var(--border-color);
}

.metric-label {
    font-size: 0.6rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.02em;
    color: var(--text-muted);
    white-space: nowrap;
}

.metric-status {
    font-size: 0.65rem;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.metric-card--ok .metric-status { color: #059669; }
.metric-card--warning .metric-status { color: #d97706; }
.metric-card--danger .metric-status { color: #dc2626; }

/* Alert inside doc-header */
.doc-header .alert-compact {
    margin-top: 0.75rem;
    margin-bottom: 0.75rem;
}

/* Responsive doc-header */
@media (max-width: 768px) {
    .doc-body {
        grid-template-columns: 1fr;
        gap: 1rem;
    }

    .doc-metrics {
        width: 100%;
        grid-template-columns: repeat(4, 1fr);
    }
}

@media (max-width: 560px) {
    .doc-metrics {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 640px) {
    .doc-header {
        padding: 0.875rem 1rem;
    }

    .doc-title-row {
        flex-direction: column;
        align-items: stretch;
        gap: 0.5rem;
    }

    .doc-top-main {
        grid-template-columns: 1fr;
        justify-items: start;
    }

    .doc-title {
        grid-column: auto;
        text-align: left;
        justify-self: start;
    }

    .doc-actions {
        grid-column: auto;
        justify-self: start;
    }

    .doc-title-row .status-progress-bar {
        width: 100%;
        flex: 0 0 auto;
    }

    .doc-top-status {
        align-items: stretch;
    }

    .doc-title {
        font-size: 1.1rem;
    }

    .doc-label {
        font-size: 0.6rem;
        min-width: 80px;
        padding-right: 0.5rem;
    }

    .doc-value {
        font-size: 0.8rem;
    }

    .status-segment.current {
        height: 22px;
        padding: 0 8px;
    }

    .status-segment.current .status-segment-label {
        font-size: 0.6rem;
    }

    .metric-card {
        flex: 1;
        min-width: 70px;
    }
}

/* =============================================================================
   SITE FOOTER WITH ACTIONS
   ============================================================================= */

.site-footer--with-actions {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
}

.site-footer--with-actions .footer-copyright {
    display: none;
}

.footer-actions {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.footer-actions .btn {
    font-size: 0.8rem;
    padding: 0.375rem 0.75rem;
}

.footer-actions .btn-compact {
    padding: 0.25rem 0.5rem;
    font-size: 0.75rem;
}

/* Back button with arrow icon */
.btn-back {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    padding: 0.5rem 0.875rem;
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--text-secondary);
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    text-decoration: none;
    transition: all 0.15s ease;
}

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

.btn-back svg {
    flex-shrink: 0;
    transition: transform 0.15s ease;
}

.btn-back:hover svg {
    transform: translateX(-2px);
}

.footer-actions .status-change {
    display: flex;
    gap: 0.375rem;
}

.footer-actions form {
    display: inline-flex;
}

/* Responsive footer actions */
@media (max-width: 768px) {
    .site-footer--with-actions {
        flex-direction: column;
        gap: 0.75rem;
        text-align: center;
    }

    .footer-actions {
        justify-content: center;
    }
}

@media (max-width: 480px) {
    .footer-actions {
        width: 100%;
    }

    .footer-actions .btn {
        flex: 1;
        min-width: 0;
    }
}

/* =============================================================================
   DASHBOARD STYLES
   ============================================================================= */

/* Dashboard Header */
.dashboard-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.dashboard-title {
    font-size: 1.5rem;
    font-weight: 700;
    margin: 0;
    color: var(--text-primary);
}

.dashboard-subtitle {
    font-size: 0.875rem;
    color: var(--text-secondary);
    margin: 0.25rem 0 0;
}

.dashboard-actions {
    display: flex;
    gap: 0.5rem;
}

.dashboard-actions .btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

/* Dashboard Metrics */
.dashboard-metrics {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 0.75rem;
    margin-bottom: 1.25rem;
}

.dashboard-metric {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 0.875rem;
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 0.75rem;
}

.dashboard-metric-icon {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.dashboard-metric-icon svg {
    width: 18px;
    height: 18px;
}

.dashboard-metric-icon--primary {
    background: rgba(27, 94, 59, 0.1);
    color: var(--primary-color);
}

.dashboard-metric-icon--success {
    background: rgba(16, 185, 129, 0.1);
    color: #10b981;
}

.dashboard-metric-icon--info {
    background: rgba(59, 130, 246, 0.1);
    color: #3b82f6;
}

.dashboard-metric-icon--warning {
    background: rgba(245, 158, 11, 0.1);
    color: #f59e0b;
}

.dashboard-metric-content {
    display: flex;
    flex-direction: column;
    gap: 0;
    flex: 1;
    min-width: 0;
}

.dashboard-metric-value {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1.1;
}

.dashboard-metric-label {
    font-size: 0.65rem;
    font-weight: 500;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.dashboard-metric-footer {
    display: none;
}

.dashboard-metric-total {
    font-size: 0.65rem;
    color: var(--text-muted);
}

.dashboard-metric-currency {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-secondary);
}

.dashboard-metric-link {
    font-size: 0.65rem;
    color: var(--primary-color);
    text-decoration: none;
}

.dashboard-metric-link:hover {
    text-decoration: underline;
}

/* Dashboard Section Title */
.dashboard-section-title {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    margin: 0 0 0.75rem;
}

/* Alert Cards */
.dashboard-alerts {
    margin-bottom: 1.5rem;
}

.alert-cards {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    flex: 1;
    min-width: 0;
}

.alert-card {
    flex: 1;
    min-width: 140px;
    max-width: 180px;
    padding: 1rem;
    border-radius: 10px;
    text-decoration: none;
    transition: all 0.15s ease;
    border: 1px solid transparent;
}

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

.alert-card-count {
    font-size: 1.5rem;
    font-weight: 700;
    line-height: 1;
    margin-bottom: 0.375rem;
}

.alert-card-label {
    font-size: 0.8rem;
    font-weight: 600;
    margin-bottom: 0.125rem;
}

.alert-card-hint {
    font-size: 0.7rem;
    opacity: 0.7;
}

.alert-card--draft {
    background: rgba(156, 163, 175, 0.1);
    color: #6b7280;
}

.alert-card--new {
    background: rgba(59, 130, 246, 0.1);
    color: #2563eb;
}

.alert-card--confirmed {
    background: rgba(245, 158, 11, 0.1);
    color: #d97706;
}

.alert-card--warning {
    background: rgba(245, 158, 11, 0.15);
    color: #b45309;
    border-color: rgba(245, 158, 11, 0.3);
}

.alert-card--danger {
    background: rgba(220, 38, 38, 0.1);
    color: #dc2626;
    border-color: rgba(220, 38, 38, 0.2);
}

/* Status Distribution */
.dashboard-status {
    margin-bottom: 1.5rem;
}

.status-distribution {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 0.75rem;
}

.status-bar-item {
    padding: 0.75rem;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    text-decoration: none;
    transition: all 0.15s ease;
}

.status-bar-item:hover {
    border-color: var(--primary-color);
    background: var(--bg-hover);
}

.status-bar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
}

.status-bar-name {
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--text-secondary);
}

.status-bar-count {
    font-size: 0.875rem;
    font-weight: 700;
    color: var(--text-primary);
}

.status-bar-track {
    height: 4px;
    background: var(--border-color);
    border-radius: 2px;
    overflow: hidden;
}

.status-bar-fill {
    height: 100%;
    border-radius: 2px;
    min-width: 2px;
    transition: width 0.3s ease;
}

.status-bar-item--draft .status-bar-fill { background: #9ca3af; }
.status-bar-item--new .status-bar-fill { background: #3b82f6; }
.status-bar-item--confirmed .status-bar-fill { background: #f59e0b; }
.status-bar-item--paid .status-bar-fill { background: #10b981; }
.status-bar-item--in_progress .status-bar-fill { background: #8b5cf6; }
.status-bar-item--shipped .status-bar-fill { background: #06b6d4; }
.status-bar-item--completed .status-bar-fill { background: #059669; }
.status-bar-item--cancelled .status-bar-fill { background: #ef4444; }

/* Dashboard Grid */
.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
}

.dashboard-panel--wide {
    grid-column: span 2;
}

/* Dashboard Panel */
.dashboard-panel {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    overflow: hidden;
}

.dashboard-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--border-color);
}

.dashboard-panel-title {
    font-size: 0.875rem;
    font-weight: 600;
    margin: 0;
    color: var(--text-primary);
}

.dashboard-panel-link {
    font-size: 0.75rem;
    color: var(--primary-color);
    text-decoration: none;
}

.dashboard-panel-link:hover {
    text-decoration: underline;
}

.dashboard-panel-badge {
    font-size: 0.65rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: var(--text-muted);
    background: var(--bg-tertiary);
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
}

.dashboard-panel-content {
    padding: 0;
}

.dashboard-empty {
    padding: 2rem;
    text-align: center;
    color: var(--text-muted);
    font-size: 0.875rem;
}

/* Compact List */
.compact-list {
    display: flex;
    flex-direction: column;
}

.compact-list-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.75rem 1.25rem;
    text-decoration: none;
    border-bottom: 1px solid var(--border-color);
    transition: background 0.1s ease;
}

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

.compact-list-item:hover {
    background: var(--bg-hover);
}

.compact-list-main {
    display: flex;
    flex-direction: column;
    gap: 0.125rem;
    min-width: 0;
}

.compact-list-number {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--primary-color);
}

.compact-list-client {
    font-size: 0.75rem;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.compact-list-meta {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-shrink: 0;
}

.compact-list-amount {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
}

.badge-sm {
    font-size: 0.6rem;
    padding: 0.2rem 0.4rem;
}

/* Top Clients */
.top-clients-list {
    display: flex;
    flex-direction: column;
}

.top-client-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1.25rem;
    border-bottom: 1px solid var(--border-color);
}

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

.top-client-rank {
    width: 24px;
    height: 24px;
    background: var(--bg-tertiary);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.7rem;
    font-weight: 700;
    color: var(--text-muted);
    flex-shrink: 0;
}

.top-client-item:first-child .top-client-rank {
    background: var(--primary-color);
    color: #fff;
}

.top-client-info {
    display: flex;
    flex-direction: column;
    gap: 0.125rem;
    min-width: 0;
    flex: 1;
}

.filters-inline {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    align-items: flex-end;
}

.filters-inline .form-group {
    margin-bottom: 0;
}

.filters-inline .form-group--actions {
    display: flex;
    gap: 0.5rem;
}

.status-chip--info .status-chip-count {
    color: #2563eb;
}

.status-chip--warning .status-chip-count {
    color: #d97706;
}

.qty-input {
    display: inline-block;
}

.mrp-row.selected {
    background-color: #f0fdf4;
}

.d-flex {
    display: flex;
}

.gap-2 {
    gap: 0.5rem;
}

.top-client-name {
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.top-client-orders {
    font-size: 0.7rem;
    color: var(--text-muted);
}

.top-client-amount {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
}

/* Quick Actions */
.quick-actions-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.5rem;
    padding: 1rem;
}

.quick-action {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    padding: 1rem;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    text-decoration: none;
    color: var(--text-secondary);
    transition: all 0.15s ease;
}

.quick-action:hover {
    background: var(--bg-hover);
    border-color: var(--primary-color);
    color: var(--primary-color);
}

.quick-action span {
    font-size: 0.75rem;
    font-weight: 500;
}

/* Dashboard Actions Row (Alerts + Quick Actions inline) */
.dashboard-actions-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
    margin-bottom: 1rem;
}

.dashboard-actions-row .alert-cards:empty {
    display: none;
}

.dashboard-actions-row .alert-cards:empty + .quick-actions-row {
    margin-left: auto;
}

/* Alert Chips (compact inline) */
.alert-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    padding: 0.375rem 0.625rem;
    border-radius: 6px;
    text-decoration: none;
    font-size: 0.75rem;
    font-weight: 500;
    transition: all 0.15s ease;
    border: 1px solid transparent;
}

.alert-chip:hover {
    transform: translateY(-1px);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
}

.alert-chip-count {
    font-weight: 700;
}

.alert-chip-label {
    opacity: 0.9;
}

.alert-chip--draft {
    background: rgba(156, 163, 175, 0.15);
    color: #4b5563;
}

.alert-chip--new {
    background: rgba(59, 130, 246, 0.12);
    color: #2563eb;
}

.alert-chip--confirmed {
    background: rgba(245, 158, 11, 0.12);
    color: #d97706;
}

.alert-chip--warning {
    background: rgba(245, 158, 11, 0.18);
    color: #b45309;
    border-color: rgba(245, 158, 11, 0.3);
}

.alert-chip--danger {
    background: rgba(220, 38, 38, 0.12);
    color: #dc2626;
    border-color: rgba(220, 38, 38, 0.2);
}

/* Quick Actions Row (inline buttons) */
.quick-actions-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
    flex-shrink: 0;
}

.quick-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    padding: 0.5rem 0.875rem;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    color: var(--text-secondary);
    font-size: 0.8125rem;
    font-weight: 500;
    text-decoration: none;
    transition: all 0.15s ease;
    white-space: nowrap;
}

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

.quick-btn svg {
    flex-shrink: 0;
}

/* Status Row (inline distribution) */
.status-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
    margin-bottom: 1.25rem;
}

.status-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.375rem 0.625rem;
    border-radius: 6px;
    text-decoration: none;
    font-size: 0.7rem;
    font-weight: 500;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    transition: all 0.15s ease;
}

.status-chip:hover {
    border-color: var(--primary-color);
    background: var(--bg-hover);
}

.status-chip-count {
    font-weight: 700;
    color: var(--text-primary);
}

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

/* Status chip colors */
.status-chip--draft { border-left: 3px solid #9ca3af; }
.status-chip--new { border-left: 3px solid #3b82f6; }
.status-chip--confirmed { border-left: 3px solid #f59e0b; }
.status-chip--paid { border-left: 3px solid #10b981; }
.status-chip--in_progress { border-left: 3px solid #8b5cf6; }
.status-chip--shipped { border-left: 3px solid #06b6d4; }
.status-chip--completed { border-left: 3px solid #059669; }
.status-chip--cancelled { border-left: 3px solid #ef4444; }

/* Dashboard Responsive */
@media (max-width: 1024px) {
    .dashboard-metrics {
        grid-template-columns: repeat(2, 1fr);
    }

    .dashboard-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 640px) {
    .dashboard-header {
        flex-direction: column;
        align-items: stretch;
    }

    .dashboard-actions {
        justify-content: stretch;
    }

    .dashboard-actions .btn {
        flex: 1;
        justify-content: center;
    }

    .dashboard-metrics {
        grid-template-columns: repeat(2, 1fr);
    }

    .dashboard-metric {
        padding: 0.75rem;
    }

    .dashboard-metric-icon {
        width: 32px;
        height: 32px;
    }

    .dashboard-metric-value {
        font-size: 1rem;
    }

    .alert-cards {
        flex-direction: column;
    }

    .alert-card {
        max-width: none;
    }

    .status-distribution {
        grid-template-columns: repeat(2, 1fr);
    }

    .quick-actions-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .dashboard-actions-row {
        flex-direction: column;
        align-items: stretch;
        gap: 0.75rem;
    }

    .alert-cards {
        flex-wrap: wrap;
        justify-content: flex-start;
    }

    .quick-actions-row {
        justify-content: flex-start;
        width: 100%;
    }

    .quick-btn {
        flex: 1;
        justify-content: center;
        min-width: 0;
    }

    .status-row {
        justify-content: center;
    }
}

/* =============================================================================
   HOME DASHBOARD COMPONENTS
   ============================================================================= */

/* Quick Button Primary */
.quick-btn--primary {
    background: var(--primary-color);
    border-color: var(--primary-color);
    color: #fff;
}

.quick-btn--primary:hover {
    background: #164a2e;
    border-color: #164a2e;
    color: #fff;
}

/* Sales Row */
.sales-row {
    display: flex;
    gap: 0.75rem;
    margin-bottom: 1rem;
    flex-wrap: wrap;
}

.sales-item {
    flex: 1;
    min-width: 140px;
    padding: 0.875rem 1rem;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    text-decoration: none;
}

.sales-item-label {
    font-size: 0.65rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: var(--text-secondary);
}

.sales-item-value {
    font-size: 1.125rem;
    font-weight: 700;
    color: var(--text-primary);
}

.sales-item-count {
    font-size: 0.7rem;
    color: var(--text-muted);
}

.sales-item--highlight {
    background: rgba(27, 94, 59, 0.08);
    border-color: rgba(27, 94, 59, 0.2);
}

.sales-item--highlight .sales-item-value {
    color: var(--primary-color);
}

.sales-item--debt {
    background: rgba(220, 38, 38, 0.08);
    border-color: rgba(220, 38, 38, 0.2);
}

.sales-item--debt .sales-item-value {
    color: #dc2626;
}

.sales-item--debt:hover {
    background: rgba(220, 38, 38, 0.12);
}

.trend-up {
    color: #16a34a;
    font-weight: 600;
}

.trend-down {
    color: #dc2626;
    font-weight: 600;
}

/* Chart Panel */
.chart-panel {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    margin-bottom: 1rem;
    overflow: hidden;
}

.chart-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--border-color);
}

.chart-panel-title {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-primary);
}

.chart-panel-period {
    font-size: 0.7rem;
    color: var(--text-muted);
}

.chart-panel-content {
    height: 200px;
    padding: 0.75rem;
}

/* Warehouse Stats Grid */
.warehouse-stats-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    padding: 0.75rem;
}

.warehouse-stat {
    flex: 1;
    min-width: 70px;
    padding: 0.75rem;
    background: var(--bg-tertiary);
    border-radius: 6px;
    text-align: center;
    text-decoration: none;
    transition: all 0.15s ease;
}

.warehouse-stat:hover {
    background: var(--bg-hover);
}

.warehouse-stat-value {
    display: block;
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1;
}

.warehouse-stat-label {
    display: block;
    font-size: 0.65rem;
    color: var(--text-secondary);
    margin-top: 0.25rem;
}

.warehouse-stat--warning {
    background: rgba(245, 158, 11, 0.1);
}

.warehouse-stat--warning .warehouse-stat-value {
    color: #d97706;
}

/* Dashboard Grid 3 columns on home */
@media (min-width: 1024px) {
    .dashboard-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

/* Charts Row (2 columns) */
.charts-row {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 1rem;
    margin-bottom: 1rem;
}

.chart-panel--small {
    min-width: 0;
}

/* Sales Row Responsive */
@media (max-width: 640px) {
    .sales-row {
        flex-direction: column;
    }

    .sales-item {
        min-width: 100%;
    }

    .chart-panel-content {
        height: 160px;
    }

    .charts-row {
        grid-template-columns: 1fr;
    }
}

/* =============================================================================
   DICTIONARY CARDS
   ============================================================================= */

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

.dict-card {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 1rem;
    background: var(--bg-tertiary);
    border-radius: 10px;
    border: 1px solid var(--border-color);
    text-decoration: none;
    color: inherit;
    transition: all 0.15s ease;
}

.dict-card:hover {
    background: var(--bg-hover);
    border-color: var(--primary-color);
    transform: translateY(-1px);
}

.dict-card--accent {
    border-color: rgba(27, 94, 59, 0.35);
    background: rgba(27, 94, 59, 0.04);
}

.dict-card--accent .dict-card-icon {
    background: rgba(27, 94, 59, 0.12);
    color: var(--primary-color);
}

.dict-card--accent .dict-card-count {
    color: var(--primary-color);
}

.dict-card--info {
    border-color: rgba(37, 99, 235, 0.35);
    background: rgba(37, 99, 235, 0.04);
}

.dict-card--info .dict-card-icon {
    background: rgba(37, 99, 235, 0.12);
    color: #1d4ed8;
}

.dict-card--info .dict-card-count {
    color: #1d4ed8;
}

.dict-card--warning {
    border-color: rgba(217, 119, 6, 0.35);
    background: rgba(217, 119, 6, 0.05);
}

.dict-card--warning .dict-card-icon {
    background: rgba(217, 119, 6, 0.12);
    color: #b45309;
}

.dict-card--warning .dict-card-count {
    color: #b45309;
}

.dict-card--danger {
    border-color: rgba(220, 38, 38, 0.35);
    background: rgba(220, 38, 38, 0.05);
}

.dict-card--danger .dict-card-icon {
    background: rgba(220, 38, 38, 0.12);
    color: #b91c1c;
}

.dict-card--danger .dict-card-count {
    color: #b91c1c;
}

.dict-card-icon {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    background: var(--bg-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--primary-color);
    flex-shrink: 0;
}

.dict-card-content {
    flex: 1;
    min-width: 0;
}

.dict-card-title {
    display: block;
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--text-primary);
}

.dict-card-desc {
    display: block;
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-top: 0.125rem;
}

.dict-card-count {
    font-weight: 700;
    font-size: 1.1rem;
    color: var(--primary-color);
    flex-shrink: 0;
}

@media (max-width: 640px) {
    .dict-cards {
        grid-template-columns: 1fr;
    }
}

/* =============================================================================
   FORM PAGE LAYOUT
   ============================================================================= */

.form-page {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.form-page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border-color);
}

.form-page-title {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.form-page-title h1 {
    font-size: var(--font-xl);
    font-weight: 700;
    margin: 0;
}

.form-page-actions {
    display: flex;
    gap: 0.5rem;
}

.form-page-body {
    display: grid;
    grid-template-columns: 1fr 280px;
    gap: 1.5rem;
    align-items: start;
}

.form-page-body--single {
    grid-template-columns: 1fr;
}

.form-main {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.form-main--full {
    max-width: 800px;
}

/* =============================================================================
   FORM CARDS
   ============================================================================= */

.form-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    overflow: hidden;
}

.form-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.875rem 1rem;
    border-bottom: 1px solid var(--border-color);
    background: var(--bg-tertiary);
}

.form-card-title {
    font-size: 0.85rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: var(--text-secondary);
}

.form-card-badge {
    font-size: 0.75rem;
    font-weight: 600;
    padding: 0.25rem 0.5rem;
    background: var(--primary-color);
    color: #fff;
    border-radius: 999px;
}

.form-card-actions {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.form-card-actions .checkbox-group {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.form-card-actions .checkbox-group label {
    font-weight: 600;
}

.form-card-body {
    padding: 1rem;
}

.form-card-body--table {
    padding: 0;
}

.form-card-body--table .table-responsive {
    border-radius: 0;
}

.form-card-body--table .items-table {
    margin: 0;
    border: none;
    border-radius: 0;
}

.form-card-body--table .btn-add-row {
    margin: 1rem;
}

/* =============================================================================
   FORM GRID
   ============================================================================= */

.form-grid {
    display: grid;
    gap: 1rem;
}

.form-grid--2 {
    grid-template-columns: repeat(2, 1fr);
}

.form-grid--3 {
    grid-template-columns: repeat(3, 1fr);
}

.form-grid--4 {
    grid-template-columns: repeat(4, 1fr);
}

/* =============================================================================
   FORM SIDEBAR
   ============================================================================= */

.form-sidebar {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    position: sticky;
    top: 1rem;
}

.form-sidebar-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 1rem;
}

.form-sidebar-card--highlight {
    background: rgba(27, 94, 59, 0.08);
    border-color: var(--primary-color);
}

.form-sidebar-title {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
}

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

.form-sidebar-meta {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-top: 0.25rem;
}

.form-sidebar-actions {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-top: 0.75rem;
}

.form-sidebar-text {
    font-size: 0.85rem;
    color: var(--text-secondary);
    line-height: 1.5;
}

.delivery-summary {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.delivery-summary-date {
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--text-primary);
}

.delivery-summary-hint {
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-top: 0.35rem;
}

.delivery-items {
    margin-top: 0.5rem;
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.delivery-item {
    display: flex;
    justify-content: space-between;
    gap: 0.5rem;
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.delivery-item-name {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.delivery-item-date {
    font-weight: 600;
    color: var(--text-primary);
}

.delivery-item--critical .delivery-item-date {
    color: #b91c1c;
}

/* =============================================================================
   CONTRACT HELPERS
   ============================================================================= */

.contract-field {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.inline-helper,
.contract-helper,
.client-helper {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 0.5rem 0.75rem;
    border: 1px dashed var(--border-color);
    border-radius: 8px;
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    font-size: 0.85rem;
}

.inline-helper--compact {
    margin-top: 0.35rem;
    padding: 0.35rem 0.5rem;
    font-size: 0.75rem;
}

.inline-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-top: 0.35rem;
    flex-wrap: wrap;
}

.items-table .row-linked td {
    background: rgba(16, 185, 129, 0.06);
}

.items-table .is-loading td {
    opacity: 0.6;
}

.inline-helper__text,
.contract-helper__text,
.client-helper__text {
    flex: 1;
}

.contract-modal {
    max-width: 720px;
}

.contract-modal-error {
    margin-bottom: 0.75rem;
    padding: 0.5rem 0.75rem;
    border-radius: 8px;
    border: 1px solid #fecaca;
    background: #fee2e2;
    color: #b91c1c;
    font-size: 0.85rem;
}

.client-modal-error {
    margin-bottom: 0.75rem;
    padding: 0.5rem 0.75rem;
    border-radius: 8px;
    border: 1px solid #fecaca;
    background: #fee2e2;
    color: #b91c1c;
    font-size: 0.85rem;
}

/* =============================================================================
   FORM TIPS
   ============================================================================= */

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

.form-tips li {
    position: relative;
    padding-left: 1rem;
    margin-bottom: 0.375rem;
}

.form-tips li::before {
    content: "•";
    position: absolute;
    left: 0;
    color: var(--primary-color);
}

/* =============================================================================
   FORM ELEMENTS ENHANCEMENTS
   ============================================================================= */

.required {
    color: #dc2626;
}

.form-group--checkbox {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.form-group--checkbox input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: var(--primary-color);
}

.form-group--checkbox label {
    margin-bottom: 0;
    cursor: pointer;
}

/* =============================================================================
   BUTTON ICON (table actions)
   ============================================================================= */

.btn-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    padding: 0;
    border: none;
    border-radius: 6px;
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.15s ease;
}

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

.btn-icon--danger:hover {
    background: #fee2e2;
    color: #dc2626;
}

/* =============================================================================
   ADD ROW BUTTON
   ============================================================================= */

.btn-add-row {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    background: transparent;
    border: 1px dashed var(--border-color);
    border-radius: 6px;
    color: var(--text-secondary);
    font-size: 0.875rem;
    cursor: pointer;
    transition: all 0.15s ease;
}

.btn-add-row:hover {
    border-color: var(--primary-color);
    color: var(--primary-color);
    background: rgba(27, 94, 59, 0.04);
}

/* =============================================================================
   FORM PAGE RESPONSIVE
   ============================================================================= */

@media (max-width: 1024px) {
    .form-grid--4 {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 768px) {
    .form-page-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .form-page-body {
        grid-template-columns: 1fr;
    }

    .form-sidebar {
        position: static;
        order: -1;
    }

    .form-grid--2,
    .form-grid--3,
    .form-grid--4 {
        grid-template-columns: 1fr;
    }
}

/* =============================================================================
   FULFILLMENT CHAIN (ATP/CTP визуализация)
   ============================================================================= */

.fulfillment-chain {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 0.25rem;
    padding: 0.625rem 0;
    margin: 0.75rem 0 0 0;
    background: transparent;
    border-top: 1px solid var(--border-color);
    width: 100%;
    box-sizing: border-box;
}

.fulfillment-chain + .alert-full-width {
    margin-top: 0.5rem;
}

.chain-step {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 0.25rem;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    white-space: nowrap;
}

.chain-step--success {
    background: rgba(22, 163, 74, 0.1);
    color: #16a34a;
}

.chain-step--warning {
    background: rgba(234, 179, 8, 0.1);
    color: #b45309;
}

.chain-step--danger {
    background: rgba(220, 38, 38, 0.1);
    color: #dc2626;
}

.chain-step--neutral {
    background: rgba(156, 163, 175, 0.1);
    color: #9ca3af;
}

.chain-icon {
    display: flex;
    align-items: center;
    justify-content: center;
}

.chain-icon svg {
    width: 16px;
    height: 16px;
}

.chain-label {
    font-size: 0.75rem;
    font-weight: 500;
}

.order-forecast {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    margin: 0.5rem 0 0.75rem;
    padding: 0.5rem 0.75rem;
    border: 1px dashed var(--border-color);
    border-radius: 10px;
    background: var(--bg-secondary);
}

.order-forecast-main {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
    font-size: var(--font-xs-plus);
}

.order-forecast-source,
.order-forecast-promised {
    font-size: var(--font-xs);
    color: var(--text-secondary);
}

.order-forecast-reason {
    font-size: var(--font-xs);
    color: var(--text-secondary);
    line-height: 1.4;
}

.chain-date {
    font-size: 0.6875rem;
    font-weight: 600;
    opacity: 0.75;
}

.chain-arrow {
    color: var(--text-tertiary);
    opacity: 0.4;
    flex-shrink: 0;
    margin: 0 0.125rem;
}

.chain-arrow svg {
    width: 12px;
    height: 12px;
}

/* ATP Badge в таблице товаров */
.atp-badge {
    display: inline-block;
    padding: 0.125rem 0.5rem;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 500;
    white-space: nowrap;
}

.atp-badge--stock {
    background: rgba(22, 163, 74, 0.1);
    color: #16a34a;
}

.atp-badge--incoming {
    background: rgba(59, 130, 246, 0.1);
    color: #2563eb;
}

.atp-badge--production {
    background: rgba(168, 85, 247, 0.1);
    color: #7c3aed;
}

.atp-badge--purchase {
    background: rgba(234, 179, 8, 0.1);
    color: #b45309;
}

.atp-date {
    display: block;
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-top: 0.125rem;
}

.atp-critical {
    display: inline-block;
    margin-left: 0.25rem;
    color: #dc2626;
    font-weight: 700;
    cursor: help;
}

.col-atp {
    width: 120px;
}

/* =============================================================================
   MRP RAG INDICATORS & COVERAGE
   ============================================================================= */

/* RAG Summary */
.rag-summary {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
}

.rag-summary-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    background: var(--bg-secondary);
    border-radius: 8px;
    font-size: 0.875rem;
}

.rag-count {
    font-weight: 600;
    font-size: 1rem;
}

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

/* RAG Indicator */
.rag-indicator {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
}

.rag-red {
    background: #dc3545;
}

.rag-amber {
    background: #ffc107;
}

.rag-green {
    background: #28a745;
}

/* RAG Badge variants */
.badge.bg-red {
    background: #dc3545 !important;
    color: #fff;
}

.badge.bg-amber {
    background: #ffc107 !important;
    color: #212529;
}

.badge.bg-green {
    background: #28a745 !important;
    color: #fff;
}

/* Coverage Bar */
.coverage-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
}

.coverage-bar {
    width: 60px;
    height: 6px;
    background: #e9ecef;
    border-radius: 3px;
    overflow: hidden;
}

.coverage-fill {
    height: 100%;
    border-radius: 3px;
    transition: width 0.3s ease;
}

.coverage-fill--green {
    background: #28a745;
}

.coverage-fill--amber {
    background: #ffc107;
}

.coverage-fill--red {
    background: #dc3545;
}

.coverage-text {
    font-size: 0.7rem;
    color: var(--text-secondary);
}

/* Pending Badge */
.pending-badge {
    display: inline-block;
    padding: 0.125rem 0.375rem;
    background: rgba(59, 130, 246, 0.1);
    color: #2563eb;
    border-radius: 4px;
    font-size: 0.7rem;
    font-weight: 500;
    margin-left: 0.25rem;
    cursor: help;
}

/* Customer Order Links */
.customer-orders-links {
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-top: 0.125rem;
}

.customer-order-link {
    color: #2563eb;
    text-decoration: none;
}

.customer-order-link:hover {
    text-decoration: underline;
}

/* =============================================================================
   SHIFT MASTER SUMMARY
   ============================================================================= */

.shift-summary {
    display: flex;
    gap: 1.5rem;
    flex-wrap: wrap;
}

.shift-summary-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 0.75rem 1rem;
    background: var(--bg-tertiary);
    border-radius: 8px;
    min-width: 80px;
}

.shift-summary-value {
    font-size: 1.5rem;
    font-weight: 600;
    line-height: 1.2;
}

.shift-summary-label {
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-top: 0.25rem;
}

.text-success {
    color: #28a745;
}

.text-primary {
    color: #2563eb;
}

/* RAG status mapping for badges */
.badge-success {
    background: #28a745 !important;
    color: #fff;
}

.badge-warning {
    background: #ffc107 !important;
    color: #212529;
}

.badge-danger {
    background: #dc3545 !important;
    color: #fff;
}

/* =============================================================================
   FREEZE ZONE STYLES
   ============================================================================= */

.freeze-info {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.25rem 0.5rem;
    background: rgba(220, 53, 69, 0.1);
    border: 1px solid rgba(220, 53, 69, 0.3);
    border-radius: 4px;
    font-size: 0.75rem;
    color: #dc3545;
    margin-left: 1rem;
}

.freeze-icon {
    font-size: 0.85rem;
}

.freeze-legend {
    float: right;
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    font-size: 0.75rem;
    font-weight: normal;
    color: var(--text-secondary);
}

.freeze-legend-marker {
    width: 12px;
    height: 12px;
    background: rgba(220, 53, 69, 0.15);
    border-right: 2px solid #dc3545;
}

.schedule-chart {
    position: relative;
}

.freeze-zone-overlay {
    position: absolute;
    top: 0;
    left: 0;
    bottom: 0;
    background: rgba(220, 53, 69, 0.08);
    pointer-events: none;
    z-index: 1;
}

.freeze-zone-line {
    position: absolute;
    top: 0;
    bottom: 0;
    width: 2px;
    background: #dc3545;
    z-index: 2;
    cursor: help;
}

.freeze-zone-line::after {
    content: '';
    position: absolute;
    top: 0;
    left: -3px;
    width: 8px;
    height: 8px;
    background: #dc3545;
    border-radius: 50%;
}

/* Gantt bar status colors */
.schedule-bar--planned {
    background: #6c757d;
}

.schedule-bar--in_progress {
    background: #2563eb;
}

.schedule-bar--completed {
    background: #28a745;
}

.schedule-bar--cancelled {
    background: #adb5bd;
    opacity: 0.6;
}

.schedule-bar:hover {
    opacity: 0.85;
    cursor: pointer;
}

/* Table summary row */
.table-summary td {
    background: var(--bg-tertiary);
    border-top: 2px solid var(--border-color);
}


/* =============================================================================
   SHIPMENT STATS (Warehouse Dashboard)
   ============================================================================= */

.shipment-alerts {
    margin-bottom: 1.5rem;
}

.shipment-alerts .ui-panel-title {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.shipment-stats-row {
    display: flex;
    gap: 1rem;
    padding: 0.75rem 0;
}

.shipment-stat {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 0.75rem 1.5rem;
    background: var(--bg-tertiary);
    border-radius: 8px;
    text-decoration: none;
    color: inherit;
    transition: background 0.15s ease;
}

.shipment-stat:hover {
    background: var(--bg-hover);
}

.shipment-stat-value {
    font-size: 1.5rem;
    font-weight: 700;
    line-height: 1.2;
}

.shipment-stat-label {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.shipment-stat--danger {
    background: #fef2f2;
    border: 1px solid #fecaca;
}

.shipment-stat--danger .shipment-stat-value {
    color: #dc2626;
}

.shipment-stat--warning {
    background: #fffbeb;
    border: 1px solid #fcd34d;
}

.shipment-stat--warning .shipment-stat-value {
    color: #d97706;
}

.shipment-stat--success {
    background: #f0fdf4;
    border: 1px solid #bbf7d0;
}

.shipment-stat--success .shipment-stat-value {
    color: #16a34a;
}

/* Filter chip colors */
.filter-chip--danger {
    background: #fef2f2;
    color: #dc2626;
    border-color: #fecaca;
}

.filter-chip--warning {
    background: #fffbeb;
    color: #d97706;
    border-color: #fcd34d;
}

/* =============================================================================
   STATUS TABS - Order list filter tabs
   ============================================================================= */

.status-tabs {
    display: flex;
    gap: 0.25rem;
    margin-bottom: 1rem;
    padding: 0.25rem;
    background: var(--bg-secondary);
    border-radius: 12px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.status-tab {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    border-radius: 8px;
    text-decoration: none;
    color: var(--text-secondary);
    font-size: 0.875rem;
    font-weight: 500;
    white-space: nowrap;
    transition: all 0.2s ease;
}

.status-tab:hover {
    background: rgba(0, 0, 0, 0.05);
    color: var(--text-primary);
}

.status-tab.active {
    background: var(--bg-primary);
    color: var(--text-primary);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.status-tab-label {
    font-weight: 500;
}

.status-tab-count {
    font-size: 0.75rem;
    padding: 0.125rem 0.375rem;
    border-radius: 999px;
    background: rgba(0, 0, 0, 0.06);
    color: var(--text-secondary);
    min-width: 1.25rem;
    text-align: center;
}

.status-tab.active .status-tab-count {
    background: var(--accent-color);
    color: white;
}

/* Dynamic tab colors via CSS variable --tab-color */
.status-tab.active .status-tab-count {
    background: var(--tab-color, #6b7280);
}

/* Compact filters panel */
.filters-panel--compact {
    padding: 0.75rem 1rem;
    margin-bottom: 1rem;
}

.filters-panel--compact .filters-form {
    gap: 0.75rem;
}

@media (max-width: 768px) {
    .status-tabs {
        gap: 0.125rem;
        padding: 0.125rem;
    }

    .status-tab {
        padding: 0.375rem 0.75rem;
        font-size: 0.8rem;
    }

    .status-tab-count {
        font-size: 0.7rem;
        padding: 0.1rem 0.25rem;
    }
}

/* Alert full width - for order header warnings */
.alert-full-width {
    margin: 0.75rem 0 0 0;
    padding: 0.625rem 0;
    border-radius: 0;
    font-size: 0.8125rem;
    font-weight: 500;
    background: transparent;
    border-top: 1px solid var(--border-color);
}


/* =============================================================================
   AI ASSISTANT STYLES
   ============================================================================= */

/* AI Panel */
.ai-panel {
    position: relative;
    margin: 1rem 0;
    padding: 1rem;
    background: linear-gradient(135deg, #f0f9ff 0%, #e0f2fe 100%);
    border: 1px solid #bae6fd;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

.ai-panel__header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 1rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid #bae6fd;
}

.ai-panel__icon {
    font-size: 1.25rem;
}

.ai-panel__title {
    font-weight: 600;
    color: #0369a1;
    flex: 1;
}

.ai-panel__close {
    background: none;
    border: none;
    font-size: 1.25rem;
    cursor: pointer;
    color: #64748b;
    padding: 0.25rem;
    line-height: 1;
}

.ai-panel__close:hover {
    color: #0f172a;
}

.ai-panel__loading {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: #0369a1;
    font-size: 0.875rem;
}

.ai-panel__loading .spinner {
    width: 16px;
    height: 16px;
    border: 2px solid #bae6fd;
    border-top-color: #0369a1;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

/* AI Suggestions */
.ai-suggestions {
    margin-bottom: 1rem;
}

.ai-suggestions h4 {
    font-size: 0.875rem;
    font-weight: 600;
    color: #0369a1;
    margin: 0 0 0.75rem;
}

.ai-suggestion {
    display: grid;
    grid-template-columns: 1fr auto auto auto;
    gap: 0.75rem;
    align-items: center;
    padding: 0.75rem;
    background: white;
    border: 1px solid #e0e0e0;
    border-radius: 6px;
    margin-bottom: 0.5rem;
}

.ai-suggestion__field {
    font-weight: 500;
    color: #334155;
}

.ai-suggestion__value {
    font-family: monospace;
    background: #f8fafc;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    color: #0f172a;
}

.ai-suggestion__confidence {
    font-size: 0.75rem;
    font-weight: 600;
    padding: 0.25rem 0.5rem;
    border-radius: 12px;
}

.ai-suggestion__confidence.confidence--high {
    background: #dcfce7;
    color: #166534;
}

.ai-suggestion__confidence.confidence--medium {
    background: #fef3c7;
    color: #92400e;
}

.ai-suggestion__confidence.confidence--low {
    background: #fee2e2;
    color: #991b1b;
}

.ai-suggestion__reason {
    grid-column: 1 / -1;
    font-size: 0.8125rem;
    color: #64748b;
}

.ai-suggestion__apply {
    background: #0ea5e9;
    color: white;
    border: none;
    padding: 0.375rem 0.75rem;
    border-radius: 4px;
    font-size: 0.8125rem;
    cursor: pointer;
}

.ai-suggestion__apply:hover {
    background: #0284c7;
}

/* AI Consequences */
.ai-consequences h4 {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.875rem;
    font-weight: 600;
    color: #0369a1;
    margin: 0 0 0.75rem;
}

.risk-badge {
    font-size: 0.6875rem;
    font-weight: 600;
    padding: 0.125rem 0.5rem;
    border-radius: 12px;
    text-transform: uppercase;
}

.risk-badge.risk--low {
    background: #dcfce7;
    color: #166534;
}

.risk-badge.risk--medium {
    background: #fef3c7;
    color: #92400e;
}

.risk-badge.risk--high {
    background: #fee2e2;
    color: #991b1b;
}

.ai-consequence {
    display: flex;
    gap: 0.75rem;
    padding: 0.75rem;
    background: white;
    border-radius: 6px;
    margin-bottom: 0.5rem;
}

.ai-consequence.consequence--info {
    border-left: 3px solid #3b82f6;
}

.ai-consequence.consequence--warning {
    border-left: 3px solid #f59e0b;
}

.ai-consequence.consequence--danger {
    border-left: 3px solid #ef4444;
}

.ai-consequence__icon {
    font-size: 1.25rem;
}

.ai-consequence.consequence--info .ai-consequence__icon {
    color: #3b82f6;
}

.ai-consequence.consequence--warning .ai-consequence__icon {
    color: #f59e0b;
}

.ai-consequence.consequence--danger .ai-consequence__icon {
    color: #ef4444;
}

.ai-consequence__content {
    flex: 1;
}

.ai-consequence__title {
    font-weight: 600;
    color: #0f172a;
    margin-bottom: 0.25rem;
}

.ai-consequence__description {
    font-size: 0.875rem;
    color: #475569;
}

.ai-consequence__metric {
    font-size: 0.8125rem;
    color: #64748b;
    margin-top: 0.5rem;
    font-family: monospace;
}

.ai-consequence__recommendations {
    margin: 0.5rem 0 0;
    padding-left: 1.25rem;
    font-size: 0.8125rem;
    color: #64748b;
}

.ai-consequence__recommendations li {
    margin-bottom: 0.25rem;
}

/* AI Prefill Button */
.btn-ai-prefill {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    background: linear-gradient(135deg, #0ea5e9 0%, #0284c7 100%);
    color: white;
    border: none;
    padding: 0.5rem 1rem;
    border-radius: 6px;
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-ai-prefill:hover {
    background: linear-gradient(135deg, #0284c7 0%, #0369a1 100%);
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(14, 165, 233, 0.3);
}

.btn-ai-prefill:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

/* AI Error */
.ai-error {
    padding: 0.75rem;
    background: #fef2f2;
    border: 1px solid #fecaca;
    border-radius: 6px;
    color: #991b1b;
    font-size: 0.875rem;
}

/* Form AI Panel Container */
.form-ai-panel-container {
    margin-top: 1rem;
}

/* AI Field Hints */
.ai-field-hint {
    margin-top: 0.5rem;
    padding: 0.5rem 0.75rem;
    border-radius: 6px;
    background: #eff6ff;
    border: 1px solid #bfdbfe;
    color: #1e3a8a;
    font-size: 0.8125rem;
    display: grid;
    gap: 0.35rem;
}

.ai-field-hint__title {
    font-weight: 600;
    font-size: 0.75rem;
    color: #1d4ed8;
    text-transform: uppercase;
}

.ai-field-hint__value {
    font-weight: 500;
}

.ai-field-hint__apply {
    align-self: start;
    justify-self: start;
    background: #2563eb;
    border: none;
    color: #fff;
    font-size: 0.75rem;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    cursor: pointer;
}

.ai-field-hint__apply:hover {
    background: #1d4ed8;
}

/* ==========================================================================
   Command Palette AI (CPA)
   ========================================================================== */

.command-palette-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    z-index: 9999;
    display: none;
    align-items: flex-start;
    justify-content: center;
    padding-top: 15vh;
}

.command-palette-overlay.open {
    display: flex;
}

.command-palette {
    width: 100%;
    max-width: 640px;
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    overflow: hidden;
    animation: commandPaletteIn 0.15s ease-out;
}

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

.command-palette__header {
    display: flex;
    align-items: center;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid #e5e7eb;
    gap: 0.75rem;
}

.command-palette__icon {
    font-size: 1.25rem;
    color: #9ca3af;
}

.command-palette__input {
    flex: 1;
    border: none;
    outline: none;
    font-size: 1rem;
    background: transparent;
    color: #111827;
}

.command-palette__input::placeholder {
    color: #9ca3af;
}

.command-palette__shortcut {
    background: #f3f4f6;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    font-size: 0.75rem;
    color: #6b7280;
    font-family: inherit;
}

.command-palette__body {
    max-height: 50vh;
    overflow-y: auto;
}

.command-palette__section {
    padding: 0.5rem 0;
}

.command-palette__section:not(:last-child) {
    border-bottom: 1px solid #f3f4f6;
}

.command-palette__section-title {
    padding: 0.5rem 1.25rem;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    color: #6b7280;
    letter-spacing: 0.05em;
}

.command-palette__section-title .section-icon {
    margin-right: 0.25rem;
}

.command-palette__items {
    padding: 0 0.5rem;
}

.command-palette__item {
    display: flex;
    align-items: center;
    padding: 0.75rem;
    border-radius: 8px;
    cursor: pointer;
    gap: 0.75rem;
    transition: background 0.1s ease;
}

.command-palette__item:hover,
.command-palette__item.selected {
    background: #f3f4f6;
}

.command-palette__item.top-recommendation {
    background: #eff6ff;
    border: 1px solid #bfdbfe;
}

.command-palette__item.top-recommendation:hover,
.command-palette__item.top-recommendation.selected {
    background: #dbeafe;
}

.command-palette__item.disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.command-palette__item.disabled:hover {
    background: transparent;
}

.command-palette__item .item-icon {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #f3f4f6;
    border-radius: 6px;
    font-size: 1rem;
    flex-shrink: 0;
}

.command-palette__item.top-recommendation .item-icon {
    background: #3b82f6;
    color: white;
}

.command-palette__item .item-content {
    flex: 1;
    min-width: 0;
}

.command-palette__item .item-label {
    font-weight: 500;
    color: #111827;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.command-palette__item .item-description {
    font-size: 0.8125rem;
    color: #6b7280;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.command-palette__item .item-shortcut {
    background: #e5e7eb;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    font-size: 0.75rem;
    color: #4b5563;
    font-family: inherit;
    flex-shrink: 0;
}

.command-palette__item .item-badge {
    background: #fbbf24;
    color: #78350f;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.875rem;
    flex-shrink: 0;
}

.command-palette__empty {
    padding: 2rem;
    text-align: center;
    color: #9ca3af;
}

.command-palette__footer {
    padding: 0.75rem 1.25rem;
    border-top: 1px solid #e5e7eb;
    background: #f9fafb;
}

.command-palette__hint {
    font-size: 0.75rem;
    color: #6b7280;
}

.command-palette__hint kbd {
    background: #e5e7eb;
    padding: 0.125rem 0.375rem;
    border-radius: 3px;
    margin: 0 0.25rem;
    font-family: inherit;
}

/* Floating Action Button */
.floating-action-button {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 56px;
    height: 56px;
    background: linear-gradient(135deg, #3b82f6 0%, #1d4ed8 100%);
    border-radius: 50%;
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.4);
    cursor: pointer;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.floating-action-button:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 20px rgba(59, 130, 246, 0.5);
}

.floating-action-button .fab-icon {
    font-size: 1.5rem;
    color: white;
}

.floating-action-button .fab-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    width: 20px;
    height: 20px;
    background: #ef4444;
    color: white;
    border-radius: 50%;
    font-size: 0.75rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
}

body:has(.ai-sidebar) .floating-action-button {
    display: none;
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
    .command-palette {
        background: #1f2937;
    }

    .command-palette__header {
        border-bottom-color: #374151;
    }

    .command-palette__input {
        color: #f9fafb;
    }

    .command-palette__section:not(:last-child) {
        border-bottom-color: #374151;
    }

    .command-palette__item:hover,
    .command-palette__item.selected {
        background: #374151;
    }

    .command-palette__item.top-recommendation {
        background: #1e3a5f;
        border-color: #2563eb;
    }

    .command-palette__item .item-icon {
        background: #374151;
    }

    .command-palette__item .item-label {
        color: #f9fafb;
    }

    .command-palette__item .item-description {
        color: #9ca3af;
    }

    .command-palette__footer {
        background: #111827;
        border-top-color: #374151;
    }
}

/* ==========================================================================
   Contextual Sidebar AI (CSA)
   ========================================================================== */

.ai-sidebar {
    position: fixed;
    top: 60px;
    right: 0;
    bottom: 0;
    width: 320px;
    background: #fff;
    border-left: 1px solid #e5e7eb;
    z-index: 100;
    display: flex;
    flex-direction: column;
    transition: transform 0.2s ease, width 0.2s ease;
    box-shadow: -4px 0 12px rgba(0, 0, 0, 0.05);
}

.ai-sidebar.collapsed {
    width: 0;
    transform: translateX(100%);
    border-left: 0;
    box-shadow: none;
    pointer-events: none;
}

.ai-sidebar.collapsed .ai-sidebar__expanded {
    display: none;
}

.ai-sidebar.collapsed .ai-sidebar__collapsed {
    display: flex;
}

.ai-sidebar__collapsed {
    display: none;
    flex-direction: column;
    align-items: center;
    padding: 1rem 0;
    cursor: pointer;
    position: relative;
}

.ai-sidebar__collapsed-icon {
    font-size: 1.5rem;
    padding: 0.5rem;
    background: #eff6ff;
    border-radius: 8px;
}

.ai-sidebar__collapsed-badge {
    position: absolute;
    top: 0.5rem;
    right: 0.25rem;
    width: 18px;
    height: 18px;
    background: #ef4444;
    color: white;
    font-size: 0.7rem;
    font-weight: 600;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.ai-sidebar__expanded {
    display: flex;
    flex-direction: column;
    height: 100%;
}

.ai-sidebar__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem;
    border-bottom: 1px solid #e5e7eb;
    background: #f9fafb;
}

.ai-sidebar__title {
    font-weight: 600;
    color: #111827;
}

.ai-sidebar__collapse {
    background: none;
    border: none;
    color: #6b7280;
    cursor: pointer;
    padding: 0.25rem;
    font-size: 1rem;
}

.ai-sidebar__collapse:hover {
    color: #111827;
}

.ai-sidebar__content {
    flex: 1;
    overflow-y: auto;
    padding: 0.5rem 0;
}

.ai-sidebar__section {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid #f3f4f6;
}

.ai-sidebar__section:last-child {
    border-bottom: none;
}

.ai-sidebar__section-title {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    color: #6b7280;
    margin-bottom: 0.75rem;
    letter-spacing: 0.05em;
}

.ai-sidebar__section-title span {
    margin-right: 0.25rem;
}

.ai-sidebar__loading {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: #6b7280;
    font-size: 0.875rem;
}

.ai-sidebar__loading .spinner {
    width: 16px;
    height: 16px;
    border: 2px solid #e5e7eb;
    border-top-color: #3b82f6;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

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

.ai-sidebar__empty {
    color: #9ca3af;
    font-size: 0.875rem;
    text-align: center;
    padding: 0.5rem;
}

.ai-sidebar__error {
    color: #ef4444;
    font-size: 0.875rem;
    text-align: center;
    padding: 0.5rem;
}

/* Primary Action Card */
.ai-sidebar__action-card {
    background: #eff6ff;
    border: 1px solid #bfdbfe;
    border-radius: 8px;
    padding: 1rem;
}

.ai-sidebar__action-card.primary {
    background: linear-gradient(135deg, #eff6ff 0%, #dbeafe 100%);
}

.action-card__header {
    display: flex;
    gap: 0.75rem;
    margin-bottom: 0.75rem;
}

.action-card__icon {
    width: 40px;
    height: 40px;
    background: #3b82f6;
    color: white;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    flex-shrink: 0;
}

.action-card__info {
    flex: 1;
    min-width: 0;
}

.action-card__title {
    font-weight: 600;
    color: #1e40af;
    margin-bottom: 0.25rem;
}

.action-card__reason {
    font-size: 0.8125rem;
    color: #3b82f6;
}

.action-card__button {
    width: 100%;
    padding: 0.625rem;
    background: #3b82f6;
    color: white;
    border: none;
    border-radius: 6px;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.15s ease;
}

.action-card__button:hover {
    background: #2563eb;
}

/* Context Cards */
.ai-sidebar__context-cards {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.5rem;
}

.context-card {
    background: #f9fafb;
    padding: 0.625rem;
    border-radius: 6px;
}

.context-card__label {
    font-size: 0.7rem;
    text-transform: uppercase;
    color: #6b7280;
    margin-bottom: 0.25rem;
}

.context-card__value {
    font-size: 0.875rem;
    font-weight: 500;
    color: #111827;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Related Items */
.ai-sidebar__related-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.related-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.625rem;
    background: #f9fafb;
    border-radius: 6px;
    text-decoration: none;
    color: inherit;
    transition: background 0.15s ease;
}

.related-item:hover {
    background: #f3f4f6;
}

.related-item__icon {
    font-size: 1.25rem;
}

.related-item__info {
    flex: 1;
    min-width: 0;
}

.related-item__label {
    font-weight: 500;
    color: #111827;
    font-size: 0.875rem;
}

.related-item__reason {
    font-size: 0.75rem;
    color: #6b7280;
}

/* Chat */
.ai-sidebar__chat {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 200px;
}

.ai-sidebar__chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 0.5rem 0;
    max-height: 200px;
}

.chat-message {
    display: flex;
    gap: 0.5rem;
    padding: 0.5rem;
    margin-bottom: 0.5rem;
}

.chat-message--user {
    flex-direction: row-reverse;
}

.chat-message__avatar {
    width: 28px;
    height: 28px;
    background: #e5e7eb;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.875rem;
    flex-shrink: 0;
}

.chat-message--ai .chat-message__avatar {
    background: #dbeafe;
}

.chat-message__text {
    background: #f3f4f6;
    padding: 0.5rem 0.75rem;
    border-radius: 12px;
    font-size: 0.8125rem;
    color: #374151;
    max-width: 80%;
}

.chat-message--user .chat-message__text {
    background: #3b82f6;
    color: white;
}

.chat-message.typing .chat-message__text {
    color: #9ca3af;
}

.ai-sidebar__chat-input {
    display: flex;
    gap: 0.5rem;
    padding-top: 0.5rem;
    border-top: 1px solid #f3f4f6;
}

.ai-sidebar__chat-field {
    flex: 1;
    padding: 0.5rem 0.75rem;
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    font-size: 0.875rem;
}

.ai-sidebar__chat-field:focus {
    outline: none;
    border-color: #3b82f6;
}

.ai-sidebar__chat-send {
    padding: 0.5rem 0.75rem;
    background: #3b82f6;
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
}

.ai-sidebar__chat-send:hover {
    background: #2563eb;
}

/* Responsive: hide on mobile */
@media (max-width: 1024px) {
    .ai-sidebar {
        display: none;
    }
}

/* Adjust main content when sidebar is open */
body:has(.ai-sidebar:not(.collapsed)) .page-content {
    margin-right: 320px;
}

body:has(.ai-sidebar.collapsed) .page-content {
    margin-right: 0;
}

/* ==========================================================================
   Guided Workflow AI (GWA)
   ========================================================================== */

.workflow-guide {
    background: linear-gradient(135deg, #f0f9ff 0%, #e0f2fe 100%);
    border: 1px solid #bae6fd;
    border-radius: 12px;
    margin-bottom: 1.5rem;
    overflow: hidden;
}

.workflow-guide__bar {
    padding: 1rem 1.25rem;
}

.workflow-guide__header {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 0.75rem;
}

.workflow-guide__title {
    font-weight: 600;
    color: #0369a1;
    flex: 1;
}

.workflow-guide__percent {
    font-size: 1.25rem;
    font-weight: 700;
    color: #0284c7;
}

.workflow-guide__toggle {
    background: none;
    border: none;
    color: #0369a1;
    cursor: pointer;
    padding: 0.25rem;
    font-size: 0.75rem;
}

.workflow-guide__progress {
    height: 6px;
    background: #bae6fd;
    border-radius: 3px;
    margin-bottom: 1rem;
    overflow: hidden;
}

.workflow-guide__progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #0ea5e9 0%, #0284c7 100%);
    border-radius: 3px;
    transition: width 0.3s ease;
}

.workflow-guide__steps {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.workflow-step {
    display: flex;
    align-items: center;
    gap: 0.375rem;
    padding: 0.375rem 0.75rem;
    background: white;
    border-radius: 20px;
    font-size: 0.8125rem;
    cursor: pointer;
    transition: all 0.15s ease;
    border: 1px solid transparent;
}

.workflow-step:hover {
    border-color: #0ea5e9;
}

.workflow-step--completed {
    background: #dcfce7;
    color: #166534;
}

.workflow-step--completed .workflow-step__icon {
    color: #22c55e;
}

.workflow-step--current {
    background: #0ea5e9;
    color: white;
    font-weight: 500;
}

.workflow-step--current .workflow-step__icon {
    color: white;
}

.workflow-step--pending {
    background: white;
    color: #64748b;
}

.workflow-step--blocked {
    background: #fef3c7;
    color: #92400e;
}

.workflow-step__arrow {
    color: #94a3b8;
    font-size: 0.75rem;
}

/* Details panel */
.workflow-guide__details {
    padding: 1rem 1.25rem;
    border-top: 1px solid #bae6fd;
    background: white;
}

.workflow-guide__current-step {
    margin-bottom: 1rem;
}

.current-step__header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 0.5rem;
}

.current-step__badge {
    background: #0ea5e9;
    color: white;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 500;
}

.current-step__title {
    font-size: 1.125rem;
    font-weight: 600;
    color: #0f172a;
}

.current-step__description {
    color: #64748b;
    font-size: 0.875rem;
    margin-bottom: 1rem;
}

/* Criteria checklist */
.criteria-list {
    background: #f8fafc;
    border-radius: 8px;
    padding: 0.75rem;
    margin-bottom: 1rem;
}

.criteria-item {
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
    padding: 0.5rem 0;
    border-bottom: 1px solid #e2e8f0;
}

.criteria-item:last-of-type {
    border-bottom: none;
}

.criteria-item--met .criteria-icon {
    color: #22c55e;
}

.criteria-item--pending .criteria-icon {
    color: #94a3b8;
}

.criteria-item--pending .criteria-label {
    color: #64748b;
}

.criteria-label {
    flex: 1;
    font-size: 0.875rem;
}

.criteria-help {
    font-size: 0.75rem;
    color: #f59e0b;
    margin-left: auto;
}

.criteria-progress {
    text-align: center;
    font-size: 0.75rem;
    color: #64748b;
    padding-top: 0.5rem;
}

/* Action button */
.workflow-action-btn {
    width: 100%;
    padding: 0.75rem;
    background: linear-gradient(135deg, #0ea5e9 0%, #0284c7 100%);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s ease;
}

.workflow-action-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(14, 165, 233, 0.4);
}

/* Outcomes */
.workflow-guide__outcomes {
    background: #f0fdf4;
    border: 1px solid #bbf7d0;
    border-radius: 8px;
    padding: 0.75rem;
    margin-top: 1rem;
}

.outcomes__title {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    color: #166534;
    margin-bottom: 0.5rem;
}

.outcome-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.375rem 0;
    font-size: 0.875rem;
    color: #166534;
}

.outcome-icon {
    font-size: 1rem;
}

.outcome-delay {
    margin-left: auto;
    font-size: 0.75rem;
    color: #4ade80;
}

/* Risks */
.workflow-guide__risks {
    margin-top: 1rem;
}

.risks-title {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    color: #b45309;
    margin-bottom: 0.5rem;
}

.risk-item {
    background: #fef3c7;
    border-left: 3px solid #f59e0b;
    padding: 0.625rem;
    border-radius: 0 6px 6px 0;
    margin-bottom: 0.5rem;
}

.risk-item--high {
    background: #fee2e2;
    border-left-color: #ef4444;
}

.risk-description {
    font-size: 0.875rem;
    color: #92400e;
    margin-bottom: 0.25rem;
}

.risk-mitigation {
    font-size: 0.75rem;
    color: #78350f;
}

/* Responsive */
@media (max-width: 768px) {
    .workflow-guide__steps {
        flex-wrap: nowrap;
        overflow-x: auto;
        padding-bottom: 0.5rem;
    }

    .workflow-step__name {
        display: none;
    }

    .workflow-step.current .workflow-step__name {
        display: inline;
    }
}

/* =============================================================================
   WORKSHOP INTERFACE (Цеховой интерфейс)
   ============================================================================= */

.workshop-page {
    background: #f6f7fb;
    padding-bottom: 80px; /* Space for sticky footer */
}

.workshop-page .topbar {
    display: flex !important;
}

.workshop-shell {
    padding-bottom: 1rem;
}

.workshop-breadcrumbs {
    background: #ffffff;
    border: 1px solid rgba(148, 163, 184, 0.35);
    border-radius: 12px;
    padding: 0.4rem 0.75rem;
    margin-bottom: 0.75rem;
    box-shadow: 0 6px 14px rgba(15, 23, 42, 0.04);
}

.workshop-flow {
    display: grid;
    gap: 0.5rem;
}

.workshop-flow__steps {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.workshop-flow__step {
    padding: 0.3rem 0.6rem;
    border-radius: 999px;
    font-size: 0.7rem;
    font-weight: 600;
    color: #64748b;
    background: #f1f5f9;
    border: 1px solid #e2e8f0;
}

.workshop-flow__step.is-active {
    background: #e0f2fe;
    border-color: #bae6fd;
    color: #0369a1;
}

.workshop-layout {
    align-items: start;
}

.workshop-status-pill {
    padding: 0.25rem 0.6rem;
    border-radius: 999px;
    font-size: 0.7rem;
    font-weight: 600;
    background: #e2e8f0;
    color: #334155;
}

.workshop-status-pill.is-working {
    background: #dcfce7;
    color: #166534;
}

.workshop-status-pill.is-ready {
    background: #e0f2fe;
    color: #0369a1;
}

.workshop-task {
    display: grid;
    gap: 0.4rem;
}

.workshop-steps-panel {
    margin-top: 0.75rem;
    padding: 0.75rem;
    border-radius: 12px;
    border: 1px solid rgba(148, 163, 184, 0.35);
    background: #f8fafc;
}

.workshop-steps-list {
    display: grid;
    gap: 0.35rem;
    margin-top: 0.4rem;
    font-size: 0.85rem;
    color: #334155;
}

.workshop-step-item {
    padding: 0.35rem 0.5rem;
    border-radius: 10px;
    background: #ffffff;
    border: 1px dashed rgba(148, 163, 184, 0.4);
}

.workshop-task__title {
    font-size: 1.05rem;
    font-weight: 700;
    color: #111827;
}

.workshop-task__meta {
    font-size: 0.85rem;
    color: #6b7280;
}

.workshop-progress {
    display: grid;
    gap: 0.35rem;
    margin-top: 0.4rem;
}

.progress-bar {
    width: 100%;
    height: 8px;
    border-radius: 999px;
    background: #e2e8f0;
    overflow: hidden;
}

.progress-bar__fill {
    height: 100%;
    background: #4f46e5;
    width: 0;
    transition: width 0.2s ease;
}

.progress-meta {
    font-size: 0.75rem;
    color: #64748b;
}

.workshop-actions {
    display: grid;
    gap: 0.5rem;
    margin-top: 0.5rem;
}

.workshop-queue-list {
    display: grid;
    gap: 0.5rem;
}

.workshop-queue-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 0.6rem 0.75rem;
    border-radius: 10px;
    border: 1px solid rgba(148, 163, 184, 0.35);
    background: #fff;
}

.workshop-queue-main {
    display: grid;
    gap: 0.15rem;
}

.workshop-queue-title {
    font-weight: 600;
    font-size: 0.85rem;
    color: #111827;
}

.workshop-queue-sub {
    font-size: 0.78rem;
    color: #6b7280;
}

.workshop-queue-meta {
    font-size: 0.75rem;
    color: #64748b;
    text-align: right;
    white-space: nowrap;
}

.workshop-summary-block {
    border: none;
    border-left: 0;
    padding: 0.5rem 0 0;
    background: transparent;
}

.workshop-report-intro {
    margin-bottom: 1rem;
}

.workshop-todo {
    margin: 0;
    padding-left: 1.1rem;
    font-size: 0.85rem;
    color: #4b5563;
    display: grid;
    gap: 0.35rem;
}

.workshop-report-panel {
    display: grid;
    gap: 0.5rem;
}

.workshop-unit-block .report-unit-form {
    display: grid;
    gap: 0.5rem;
}

.workshop-unit-block .unit-input {
    font-size: 1.1rem;
}

.workshop-unit-list {
    display: grid;
    gap: 0.4rem;
    margin-top: 0.6rem;
}

.workshop-unit-item {
    display: flex;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 0.5rem 0.6rem;
    border-radius: 10px;
    border: 1px solid rgba(148, 163, 184, 0.35);
    background: #fff;
    font-size: 0.8rem;
    color: #475569;
}
.workshop-hero {
    display: grid;
    grid-template-columns: minmax(0, 2fr) minmax(240px, 1fr);
    gap: 1.5rem;
    margin-top: 1.25rem;
    margin-bottom: 1.5rem;
    align-items: start;
}

.workshop-hero__title {
    font-size: 1.6rem;
    margin: 0 0 0.5rem;
    color: #111827;
}

.workshop-hero__subtitle {
    margin: 0 0 1rem;
    color: #6b7280;
    font-size: 0.95rem;
}

.workshop-steps {
    display: grid;
    gap: 0.75rem;
}

.workshop-step {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    background: #fff;
    border: 1px solid rgba(18, 24, 38, 0.08);
    border-radius: 14px;
    padding: 0.75rem 1rem;
    box-shadow: 0 6px 16px rgba(18, 24, 38, 0.04);
}

.workshop-step__index {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: grid;
    place-items: center;
    background: #eef2ff;
    color: #4f46e5;
    font-weight: 700;
    font-size: 0.85rem;
    flex-shrink: 0;
}

.workshop-step__title {
    font-weight: 700;
    font-size: 0.9rem;
    color: #111827;
}

.workshop-step__text {
    font-size: 0.82rem;
    color: #6b7280;
    margin-top: 0.2rem;
}

.workshop-summary {
    background: #111827;
    color: #fff;
    border-radius: 18px;
    padding: 1.25rem;
    box-shadow: 0 10px 24px rgba(15, 23, 42, 0.2);
    display: grid;
    gap: 0.5rem;
}

.workshop-summary__title {
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: rgba(255, 255, 255, 0.65);
}

.workshop-summary__value {
    font-size: 2rem;
    font-weight: 700;
}

.workshop-summary__label {
    font-size: 0.9rem;
    color: rgba(255, 255, 255, 0.8);
}

.workshop-summary__hint {
    font-size: 0.8rem;
    color: rgba(255, 255, 255, 0.6);
}

.workshop-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 16px;
    margin-top: 0;
}

.workshop-card {
    min-height: 210px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 18px;
    border-radius: 18px;
    background: #fff;
    border: 1px solid rgba(18, 24, 38, 0.08);
    box-shadow: 0 8px 20px rgba(18, 24, 38, 0.04);
    text-decoration: none;
    color: inherit;
    transition: all 0.2s ease;
    position: relative;
    overflow: hidden;
}

.workshop-card:active {
    transform: scale(0.96);
    box-shadow: 0 4px 10px rgba(18, 24, 38, 0.08);
}

.workshop-card .icon-tile {
    width: 48px;
    height: 48px;
    border-radius: 14px;
    display: grid;
    place-items: center;
    background: #eef2ff;
    color: #4f46e5;
    font-size: 24px;
}

.workshop-card__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
}

.workshop-badge {
    padding: 0.3rem 0.6rem;
    border-radius: 999px;
    font-size: 0.7rem;
    font-weight: 600;
    border: 1px solid transparent;
}

.workshop-badge--working {
    background: #dcfce7;
    color: #166534;
    border-color: #bbf7d0;
}

.workshop-badge--attention {
    background: #fee2e2;
    color: #b91c1c;
    border-color: #fecaca;
}

.workshop-badge--idle {
    background: #e2e8f0;
    color: #334155;
    border-color: #cbd5f5;
}

.workshop-card__info {
    margin-top: 12px;
}

.workshop-card__title {
    font-size: 1.1rem;
    font-weight: 700;
    color: #1a1a1a;
    display: block;
}

.workshop-card__status {
    font-size: 0.85rem;
    color: #666;
    margin-top: 4px;
    display: block;
}

.workshop-card__footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
}

.workshop-meta {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
}

.workshop-meta__label {
    font-size: 0.7rem;
    color: #94a3b8;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.workshop-meta__value {
    font-size: 0.85rem;
    font-weight: 700;
    color: #0f172a;
}

.workshop-card__cta {
    font-size: 0.8rem;
    font-weight: 600;
    color: #4f46e5;
}

.workshop-card.status-working { border-color: #22c55e; border-width: 2px; }
.workshop-card.status-idle { opacity: 0.9; }
.workshop-card.status-attention { border-color: #ef4444; border-width: 2px; }

.workshop-card.status-working .icon-tile { background: #dcfce7; color: #16a34a; }
.workshop-card.status-attention .icon-tile { background: #fee2e2; color: #dc2626; }

.machine-switch-list {
    display: grid;
    gap: 0.5rem;
}

.machine-switch-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 0.6rem 0.75rem;
    border-radius: 10px;
    border: 1px solid rgba(148, 163, 184, 0.4);
    text-decoration: none;
    color: inherit;
    background: #fff;
    transition: all 0.15s ease;
}

.machine-switch-item:hover {
    border-color: #6366f1;
    background: #eef2ff;
}

.machine-switch-name {
    font-weight: 600;
    font-size: 0.9rem;
    color: #111827;
}

.machine-switch-status {
    font-size: 0.7rem;
    padding: 0.2rem 0.5rem;
    border-radius: 999px;
    border: 1px solid transparent;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    font-weight: 600;
}

.machine-switch-status.status-working {
    background: #dcfce7;
    color: #166534;
    border-color: #bbf7d0;
}

.machine-switch-status.status-attention {
    background: #fee2e2;
    color: #b91c1c;
    border-color: #fecaca;
}

.machine-switch-status.status-idle {
    background: #e2e8f0;
    color: #334155;
    border-color: #cbd5f5;
}

.workshop-empty {
    grid-column: 1 / -1;
    background: #fff;
    border-radius: 18px;
    padding: 2rem;
    border: 1px dashed rgba(148, 163, 184, 0.6);
}

/* Action Grid for Machine Workspace */
.action-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    margin-top: 20px;
}

.action-card {
    background: #fff;
    padding: 24px;
    border-radius: 20px;
    text-align: center;
    border: 1px solid rgba(18, 24, 38, 0.08);
    box-shadow: 0 8px 20px rgba(18, 24, 38, 0.04);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    cursor: pointer;
    transition: all 0.2s ease;
    text-decoration: none;
    color: inherit;
    border: none;
}

.action-card:active {
    transform: scale(0.95);
    background: #f8fafc;
}

.action-card__icon {
    font-size: 32px;
}

.action-card__label {
    font-weight: 600;
    font-size: 1rem;
}

.action-card.primary {
    background: #4f46e5;
    color: #fff;
}

.action-card.secondary {
    background: #fff;
    color: #1a1a1a;
}

/* Info Card */
.info-card {
    background: #fff;
    padding: 20px;
    border-radius: 20px;
    box-shadow: 0 8px 20px rgba(18, 24, 38, 0.04);
    margin-bottom: 20px;
}

.info-card__header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.info-card__title {
    font-size: 1.2rem;
    font-weight: 700;
}

/* Quick Input Controls */
.report-block {
    margin-bottom: 24px;
}

.report-block__label {
    display: block;
    font-weight: 600;
    margin-bottom: 12px;
    color: #4b5563;
}

.quick-inputs {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.workshop-page .quick-btn {
    padding: 12px 16px;
    border-radius: 12px;
    border: 1px solid #e2e8f0;
    background: #fff;
    font-weight: 600;
    cursor: pointer;
    min-width: 64px;
    transition: all 0.15s ease;
}

.workshop-page .quick-btn:active {
    background: #f1f5f9;
    transform: translateY(2px);
}

.report-input-wrap {
    margin-top: 12px;
    display: flex;
    align-items: center;
    gap: 12px;
}

.large-input {
    width: 100%;
    padding: 16px;
    font-size: 1.5rem;
    font-weight: 700;
    border: 2px solid #e2e8f0;
    border-radius: 16px;
    text-align: center;
}

.large-input:focus {
    outline: none;
    border-color: #4f46e5;
}

/* Sticky Footer */
.sticky-footer {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 16px 20px;
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(10px);
    border-top: 1px solid #e2e8f0;
    display: flex;
    gap: 12px;
    z-index: 100;
}

.footer-btn {
    flex: 1;
    padding: 16px;
    border-radius: 14px;
    font-weight: 700;
    font-size: 1.1rem;
    text-align: center;
    cursor: pointer;
    border: none;
}

.footer-btn--primary {
    background: #4f46e5;
    color: #fff;
}

.footer-btn--secondary {
    background: #f1f5f9;
    color: #475569;
}

@media (max-width: 640px) {
    .action-grid {
        grid-template-columns: 1fr;
    }
    
    .workshop-grid {
        grid-template-columns: 1fr 1fr;
    }
}

@media (max-width: 900px) {
    .workshop-hero {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 640px) {
    .workshop-grid {
        grid-template-columns: 1fr;
    }
}

/* Mode Toggle Pill for Production Header */
.mode-toggle-pill {
    display: inline-flex;
    background: #f1f5f9;
    padding: 4px;
    border-radius: 999px;
    margin-left: 12px;
    vertical-align: middle;
}

.mode-label, .mode-link {
    font-size: 0.75rem;
    padding: 4px 12px;
    border-radius: 999px;
    text-decoration: none;
    font-weight: 600;
}

.mode-label.active {
    background: #fff;
    color: #1a1a1a;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

.mode-link {
    color: #64748b;
}

.mode-link:hover {
    color: #1a1a1a;
}

.quick-btn--accent {
    background: #f5f3ff;
    color: #7c3aed;
    border-color: #ddd6fe;
}

.quick-btn--accent:hover {
    background: #ede9fe;
}

/* A/B Testing Variants */
.fab-position--bottom_right {
    right: 24px;
    bottom: 24px;
}

.fab-position--bottom_center {
    left: 50%;
    transform: translateX(-50%);
    bottom: 24px;
}

.ai-sidebar--collapsed .ai-sidebar__expanded {
    display: none;
}

/* =============================================================================
   ADMIN ICON COLORS
   CSS classes to replace inline style="--icon-color: #xxx"
   ============================================================================= */

.admin-card-icon--indigo { --icon-color: #6366f1; }
.admin-card-icon--emerald { --icon-color: #10b981; }
.admin-card-icon--blue { --icon-color: #3b82f6; }
.admin-card-icon--violet { --icon-color: #8b5cf6; }
.admin-card-icon--amber { --icon-color: #f59e0b; }
.admin-card-icon--cyan { --icon-color: #06b6d4; }
.admin-card-icon--pink { --icon-color: #ec4899; }
.admin-card-icon--green { --icon-color: #22c55e; }
.admin-card-icon--orange { --icon-color: #f97316; }
.admin-card-icon--sky { --icon-color: #0ea5e9; }
.admin-card-icon--teal { --icon-color: #14b8a6; }
.admin-card-icon--yellow { --icon-color: #eab308; }
.admin-card-icon--red { --icon-color: #ef4444; }

/* Admin card chevron icon size */
.admin-card-count svg {
    width: 20px;
    height: 20px;
}

/* =============================================================================
   UTILITY CLASSES
   ============================================================================= */

/* Table column widths */
.col-w-40 { width: 40px; }
.col-w-60 { width: 60px; }
.col-w-70 { width: 70px; }
.col-w-90 { width: 90px; }
.col-w-100 { width: 100px; }
.col-w-120 { width: 120px; }
.col-w-150 { width: 150px; }
.col-w-180 { width: 180px; }
.col-w-200 { width: 200px; }
.col-w-max-200 { max-width: 200px; }

/* Display utilities */
.d-none { display: none; }
.d-inline { display: inline; }
.d-inline-block { display: inline-block; }
.d-block { display: block; }
.d-contents { display: contents; }
.d-flex { display: flex; }

/* Position utilities */
.pos-relative { position: relative; }

/* Dynamic color backgrounds - use with status colors from template */
.bg-status-color {
    background: var(--status-bg-color);
    color: var(--status-text-color, #fff);
}

/* Text truncate with max-width */
.text-truncate-200 {
    max-width: 200px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Form inline layout */
.form-inline {
    display: inline;
}

/* Card spacing utilities */
.card-mb { margin-bottom: 1.5rem; }
.card-mt { margin-top: 1.5rem; }
.card-maxw-640 { max-width: 640px; }
.card-maxw-700 { max-width: 700px; }

/* Alert with margin-top */
.alert-mt { margin-top: 1rem; }

/* Pre with word wrap */
.pre-wrap { white-space: pre-wrap; }

/* Icon sizes */
.icon-16 { width: 16px; height: 16px; }
.icon-20 { width: 20px; height: 20px; }
.icon-48 { width: 48px; height: 48px; }

/* Icon with margin */
.icon-mr-4 { margin-right: 4px; }
.icon-mr-6 { margin-right: 0.35rem; }
.icon-mr-8 { margin-right: 0.5rem; }

/* Inline icons */
.icon-inline {
    display: inline;
    vertical-align: middle;
}

.icon-inline-block {
    display: inline-block;
    vertical-align: middle;
}

/* Width utilities */
.w-100 { width: 100%; }

/* Font utilities */
.font-mono { font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace; }

/* Opacity utilities */
.opacity-40 { opacity: 0.4; }
.opacity-70 { opacity: 0.7; }

/* Status chip color preview */
.status-chip-color,
.substatus-color {
    display: inline-block;
    width: 12px;
    height: 12px;
    border-radius: 50%;
}

/* Color form preview */
.color-form-preview,
.status-form-preview {
    width: 40px;
    height: 40px;
    border-radius: 8px;
    border: 1px solid var(--border-color);
}

/* Substatus header with custom color */
.substatus-header {
    border-left: 4px solid var(--status-color);
    padding-left: 12px;
}

/* Flow stage card with custom color */
.flow-stage-card {
    border-left: 4px solid var(--flow-color);
}

/* Substatus card with custom color */
.substatus-card {
    border-left: 4px solid var(--sub-color);
}

/* Column widths extended */
.col-w-70 { width: 70px; }
.col-w-80 { width: 80px; }
.col-w-90 { width: 90px; }

/* Margin utilities */
.mt-8 { margin-top: 0.5rem; }
.mb-16 { margin-bottom: 1rem; }

/* Icon font sizes */
.icon-font-lg { font-size: 1.25rem; }

/* Font sizes */
.font-xs { font-size: 0.75rem; }
.font-sm { font-size: 0.875rem; }

/* Align self utilities */
.align-self-end { align-self: flex-end; }
.align-self-center { align-self: center; }
.align-self-start { align-self: flex-start; }

/* Text color utilities */
.text-secondary { color: var(--text-secondary); }
.text-muted { color: var(--text-muted); }

/* Margin utilities */
.m-0 { margin: 0; }
.mt-0 { margin-top: 0; }
.mb-0 { margin-bottom: 0; }

/* Module dependencies */
.module-deps {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

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

.module-dep-name {
    font-weight: 600;
    color: #111827;
}

.module-dep-req {
    font-size: 12px;
    color: #6b7280;
}

.module-dep-issues {
    font-size: 12px;
    color: #b91c1c;
}
