/* =============================================================================
   Основные стили — оптимизировано для Full HD и 2K
   Дубликаты правил и мёртвый код .compact-view удалены
   ============================================================================= */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

html, body {
    height: 100%;
    width: 100%;
}

body {
    background-color: #f0f2f5;
    color: #333;
    line-height: 1.6;
    padding: 20px;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    overflow: hidden;
}

.container {
    flex: 1;
    display: flex;
    flex-direction: column;
    max-width: 100%;
    margin: 0 auto;
    background-color: white;
    border-radius: 12px;
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.1);
    overflow: hidden;
    height: calc(100vh - 40px);
}

/* =============================================================================
   Шапка
   ============================================================================= */
header {
    background: linear-gradient(135deg, #1c3f76 0%, #2c5aa0 100%);
    color: white;
    padding: 15px 25px;
    flex-shrink: 0;
}

header h1 {
    font-size: 24px;
    font-weight: 600;
    margin-bottom: 5px;
    display: flex;
    align-items: center;
    gap: 10px;
}

header h1::before {
    content: "📊";
    font-size: 24px;
}

header p {
    opacity: 0.9;
    font-size: 13px;
}

/* =============================================================================
   Панель управления и фильтры
   ============================================================================= */
.controls-section {
    padding: 12px 25px;
    background-color: #f8f9fa;
    border-bottom: 1px solid #eaeaea;
    display: flex;
    flex-direction: column;
    gap: 12px;
    flex-shrink: 0;
}

.file-controls {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.btn {
    padding: 8px 14px;
    border-radius: 6px;
    border: none;
    cursor: pointer;
    font-weight: 500;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    white-space: nowrap;
}

.btn-primary {
    background-color: #2c5aa0;
    color: white;
}

.btn-primary:hover {
    background-color: #1c3f76;
    transform: translateY(-1px);
}

.btn-secondary {
    background-color: #6c757d;
    color: white;
}

.btn-secondary:hover {
    background-color: #545b62;
}

.btn-reset {
    background-color: #dc3545;
    color: white;
}

.btn-reset:hover {
    background-color: #c82333;
    transform: translateY(-1px);
}

.file-info {
    font-size: 12px;
    color: #666;
    font-style: italic;
    background: #f8f9fa;
    padding: 5px 8px;
    border-radius: 4px;
    border-left: 3px solid #2c5aa0;
    min-width: 150px;
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.filters {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 10px;
    background: white;
    padding: 10px;
    border-radius: 6px;
    border: 1px solid #dee2e6;
}

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

.filter-label {
    font-size: 12px;
    font-weight: 500;
    margin-bottom: 3px;
    color: #555;
    display: flex;
    align-items: center;
    gap: 4px;
}

.filter-label::before {
    content: "🔍";
    font-size: 10px;
}

.filter-select,
.filter-input {
    padding: 6px 8px;
    border: 1px solid #ced4da;
    border-radius: 4px;
    font-size: 12px;
    background-color: white;
    transition: border-color 0.2s;
    height: 32px;
}

.filter-select:focus,
.filter-input:focus {
    outline: none;
    border-color: #2c5aa0;
    box-shadow: 0 0 0 3px rgba(44, 90, 160, 0.1);
}

.date-filters {
    display: flex;
    gap: 12px;
    padding-top: 10px;
    border-top: 1px dashed #dee2e6;
    flex-wrap: wrap;
}

.date-filter-group {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-width: 150px;
}

.date-filter-label {
    font-size: 12px;
    font-weight: 500;
    margin-bottom: 3px;
    color: #555;
    display: flex;
    align-items: center;
    gap: 4px;
}

.date-filter-label::before {
    content: "📅";
    font-size: 10px;
}

.clear-date-btn {
    margin-top: 3px;
    padding: 2px 5px;
    font-size: 10px;
    background-color: #f8f9fa;
    border: 1px solid #dee2e6;
    border-radius: 3px;
    cursor: pointer;
    transition: background-color 0.2s;
}

.clear-date-btn:hover {
    background-color: #e9ecef;
}

/* =============================================================================
   Статистика
   ============================================================================= */
.stats {
    display: flex;
    gap: 10px;
    flex-wrap: nowrap;
    padding-top: 10px;
    border-top: 1px dashed #dee2e6;
    overflow-x: auto;
    padding-bottom: 5px;
}

.stat-card {
    background-color: white;
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 12px;
    display: flex;
    flex-direction: column;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
    border: 1px solid #e9ecef;
    min-width: 100px;
    cursor: pointer;
    transition: all 0.2s;
    user-select: none;
    flex-shrink: 0;
}

.stat-card:hover {
    transform: translateY(-1px);
    box-shadow: 0 3px 6px rgba(0, 0, 0, 0.1);
}

.stat-card.active {
    border-color: #2c5aa0;
    box-shadow: 0 0 0 3px rgba(44, 90, 160, 0.2);
}

.stat-value {
    font-weight: 700;
    font-size: 18px;
    margin-top: 2px;
}

.stat-total         .stat-value { color: #2c5aa0; }
.stat-gost          .stat-value { color: #ffc107; }
.stat-active-kp     .stat-value { color: #28a745; }
.stat-completed-kp  .stat-value { color: #17a2b8; }
.stat-not-required-kp .stat-value { color: #6c757d; }
.stat-stopped-kp    .stat-value { color: #dc3545; }
.stat-active-mo     .stat-value { color: #28a745; }
.stat-completed-mo  .stat-value { color: #17a2b8; }
.stat-not-required-mo .stat-value { color: #6c757d; }
.stat-stopped-mo    .stat-value { color: #dc3545; }

/* =============================================================================
   Основная область с таблицей
   ============================================================================= */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
    overflow: hidden;
}

.table-wrapper {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
    overflow: hidden;
}

.table-container {
    flex: 1;
    padding: 15px 25px;
    overflow: auto;
    min-height: 0;
}

/* =============================================================================
   Таблица проектов
   ============================================================================= */
.orders-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 12px;
    background-color: white;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.04);
    border-radius: 6px;
    overflow: hidden;
    table-layout: fixed;
}

.orders-table thead {
    background-color: #0c1524;
    color: white;
    position: sticky;
    top: 0;
    z-index: 10;
}

.orders-table th {
    padding: 12px 6px;
    text-align: left;
    font-weight: 600;
    border-bottom: 2px solid #1c3f76;
    white-space: normal;
    word-wrap: break-word;
    min-height: 50px;
    vertical-align: top;
    line-height: 1.4;
}

/* Ширины колонок по умолчанию */
.orders-table th:nth-child(1)  { width: 60px; }
.orders-table th:nth-child(2)  { width: 35px; }
.orders-table th:nth-child(3)  { width: 240px; }
.orders-table th:nth-child(4)  { width: 90px; }
.orders-table th:nth-child(5)  { width: 90px; }
.orders-table th:nth-child(6)  { width: 55px; }
.orders-table th:nth-child(7)  { width: 160px; }
.orders-table th:nth-child(8)  { width: 120px; }
.orders-table th:nth-child(9)  { width: 115px; }
.orders-table th:nth-child(10) { width: 115px; }
.orders-table th:nth-child(11) { width: 200px; }
.orders-table th:nth-child(12) { width: 40px; }

.orders-table td {
    padding: 10px 6px;
    border-bottom: 1px solid #eaeaea;
    vertical-align: middle;
    white-space: normal;
    word-wrap: break-word;
    line-height: 1.4;
    min-height: 42px;
}

.orders-table tbody tr:hover td {
    background-color: #f0f7ff;
}

.orders-table .order-header {
    cursor: pointer;
    transition: background-color 0.2s;
}

.orders-table .order-header:hover {
    background-color: #f0f7ff;
}

/* Tooltip через CSS */
.orders-table td[title] {
    cursor: help;
    position: relative;
}

.orders-table td[title]:hover::after {
    content: attr(title);
    position: absolute;
    background: #333;
    color: white;
    padding: 6px 10px;
    border-radius: 5px;
    font-size: 12px;
    white-space: normal;
    max-width: 300px;
    z-index: 1000;
    top: 100%;
    left: 0;
    box-shadow: 0 3px 8px rgba(0, 0, 0, 0.15);
    line-height: 1.4;
}

.date-cell {
    font-family: 'Consolas', 'Monaco', monospace;
    white-space: nowrap;
    font-size: 11px;
}

.numeric-cell {
    text-align: right;
    font-family: 'Consolas', 'Monaco', monospace;
    white-space: nowrap;
    font-size: 11px;
}

.gostrue {
    text-align: center;
    font-size: 11px;
    font-weight: 500;
}

/* =============================================================================
   Кнопки в строках таблицы
   ============================================================================= */
.toggle-btn,
.open-new-tab-btn {
    background: none;
    border: none;
    cursor: pointer;
    width: 22px;
    height: 22px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: all 0.2s;
    padding: 0;
}

.toggle-btn:hover,
.open-new-tab-btn:hover {
    background-color: rgba(44, 90, 160, 0.1);
    transform: scale(1.1);
}

.open-new-tab-btn {
    font-size: 12px;
    margin-left: 4px;
}

.icon {
    font-size: 10px;
    transition: transform 0.3s;
}

.icon.rotated {
    transform: rotate(90deg);
}

/* =============================================================================
   Статусы
   ============================================================================= */
.status-indicator {
    display: inline-flex;
    align-items: center;
    padding: 3px 6px;
    border-radius: 4px;
    font-size: 10px;
    font-weight: 500;
    white-space: nowrap;
    max-width: 100px;
    overflow: hidden;
    text-overflow: ellipsis;
}

.status-completed    { background-color: #d4edda; color: #155724; border: 1px solid #c3e6cb; }
.status-in-progress  { background-color: #d1ecf1; color: #0c5460; border: 1px solid #bee5eb; }
.status-stopped      { background-color: #f8d7da; color: #721c24; border: 1px solid #f5c6cb; }
.status-not-required { background-color: #e2e3e5; color: #383d41; border: 1px solid #d6d8db; }

.plan-ok   { color: #28a745; font-weight: 600; }
.plan-late { color: #dc3545; font-weight: 600; }

.bool-true,
.bool-false {
    display: inline-block;
    padding: 2px 6px;
    border-radius: 3px;
    font-size: 11px;
    font-weight: 500;
}

.bool-true  { background-color: #28a745; color: white; }
.bool-false { background-color: #dc3545; color: white; }

/* =============================================================================
   Детали проекта (раскрывающаяся строка)
   ============================================================================= */
.order-details {
    background-color: #f9f9f9;
}

.order-details.hidden {
    display: none;
}

.details-container {
    padding: 15px;
    background: #f9f9f9;
    border-top: 1px solid #eee;
    max-height: 500px;
    overflow-y: auto;
}

.details-container h3 {
    margin: 12px 0 10px;
    color: #2c5aa0;
    font-size: 14px;
    border-bottom: 2px solid #2c5aa0;
    padding-bottom: 3px;
}

.details-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 15px;
    margin-bottom: 15px;
}

.details-block {
    background-color: white;
    padding: 12px;
    border-radius: 5px;
    border: 1px solid #e0e0e0;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

.details-block h4 {
    margin: 0 0 10px;
    color: #2c5aa0;
    font-size: 13px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 5px;
    border-bottom: 2px solid #e9ecef;
    padding-bottom: 5px;
}

.details-block div {
    font-size: 11px;
    margin-bottom: 5px;
    display: flex;
    justify-content: space-between;
    padding: 4px 0;
    border-bottom: 1px dashed #f0f0f0;
}

.details-block div:last-child {
    border-bottom: none;
    margin-bottom: 0;
}

.details-block strong {
    color: #495057;
    font-weight: 600;
    flex: 1;
    padding-right: 10px;
    min-width: 140px;
}

.details-block span {
    color: #333;
    text-align: right;
    flex: 1;
    word-break: break-word;
}

.subsection-header {
    margin: 15px 0 12px;
    color: #1c3f76;
    font-size: 14px;
    font-weight: 600;
    padding-bottom: 4px;
    border-bottom: 1px solid #d0d7e0;
}

.not-required-section {
    margin: 12px 0;
    color: #6c757d;
    font-size: 12px;
    font-style: italic;
    padding: 8px;
    background-color: #f8f9fa;
    border-radius: 5px;
    border: 1px solid #dee2e6;
}

.comment-block {
    margin: 10px 0;
    padding: 8px;
    background-color: #f8f9fa;
    border-radius: 4px;
    border-left: 3px solid #6c757d;
    font-size: 10px;
    line-height: 1.5;
}

.comment-block strong {
    color: #495057;
    font-weight: 600;
    display: block;
    margin-bottom: 4px;
    min-width: unset;     /* сбрасываем правило details-block strong */
    padding-right: 0;
}

.comment-block div {
    color: #212529;
    white-space: pre-wrap;
    display: block;
    min-height: 14px;
    border: none;
    padding: 0;
    font-size: 10px;
}

/* =============================================================================
   Таблица чертежей / оснастки
   ============================================================================= */
.drawings-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 10px;
    margin-top: 5px;
    table-layout: fixed;
    background-color: white;
    border: 1px solid #dee2e6;
}

.drawings-table th {
    background-color: #f8f9fa;
    border: 1px solid #dee2e6;
    padding: 5px 8px;
    text-align: left;
    font-weight: 600;
    color: #495057;
}

.drawings-table td {
    border: 1px solid #dee2e6;
    padding: 4px 8px;
    vertical-align: top;
}

.drawings-table tr:nth-child(even) { background-color: #f8f9fa; }
.drawings-table tr:hover            { background-color: #e9ecef; }

.drawings-table th:nth-child(1) { width: 5%; }
.drawings-table th:nth-child(2) { width: 50%; }
.drawings-table th:nth-child(3) { width: 15%; }
.drawings-table th:nth-child(4) { width: 15%; }
.drawings-table th:nth-child(5) { width: 15%; }

/* Страница аналитики — скролл и авто-высота контейнера,
   ширина контейнера наследуется из тех же медиа-правил что и главная */
body.analytics-page {
    overflow: auto;
    height: auto;
    min-height: 100vh;
}

/* Сбрасываем height:100% у html чтобы страница могла расти длиннее viewport */
html:has(body.analytics-page) {
    height: auto;
    min-height: 100%;
}

body.analytics-page .container {
    height: auto;
    overflow: clip;
    min-height: calc(100vh - 40px);
    max-width: 100%;
    width: 100%;
}

/* Последний дочерний элемент контейнера аналитики — footer,
   grid идёт перед ним, скругляем низ grid чтобы не было обрыва */
body.analytics-page .analytics-grid {
    border-radius: 0 0 12px 12px;
}

/* =============================================================================
   Навигация
   ============================================================================= */
.main-nav {
    display: flex;
    gap: 4px;
    padding: 0 20px;
    background: #1c3f76;
    border-bottom: 3px solid #2c5aa0;
}

.nav-link {
    display: inline-block;
    padding: 12px 22px;
    color: rgba(255,255,255,0.75);
    text-decoration: none;
    font-size: 13px;
    font-weight: 500;
    border-bottom: 3px solid transparent;
    margin-bottom: -3px;
    transition: color 0.2s, border-color 0.2s;
}

.nav-link:hover {
    color: #fff;
    border-bottom-color: rgba(255,255,255,0.5);
}

.nav-link.active {
    color: #fff;
    border-bottom-color: #fff;
    font-weight: 600;
}

/* =============================================================================
   Аналитика — фильтры
   ============================================================================= */
.analytics-filters {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: flex-end;
    padding: 16px 20px;
    background: #f8f9fa;
    border-bottom: 1px solid #e0e0e0;
}

/* =============================================================================
   Аналитика — KPI-карточки
   ============================================================================= */
.analytics-kpi {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    padding: 16px 20px;
    background: #fff;
    border-bottom: 1px solid #e0e0e0;
}

.kpi-card {
    flex: 1;
    min-width: 120px;
    background: linear-gradient(135deg, #1c3f76 0%, #2c5aa0 100%);
    color: #fff;
    border-radius: 10px;
    padding: 14px 18px;
    text-align: center;
    box-shadow: 0 2px 8px rgba(28,63,118,0.18);
}

.kpi-value {
    font-size: 30px;
    font-weight: 700;
    line-height: 1.1;
}

.kpi-label {
    font-size: 11px;
    opacity: 0.85;
    margin-top: 4px;
}

.kpi-managers    { background: linear-gradient(135deg, #1a56a0 0%, #3a7bd5 100%); }
.kpi-business    { background: linear-gradient(135deg, #155724 0%, #28a745 100%); }
.kpi-gost        { background: linear-gradient(135deg, #7b1f1f 0%, #c0392b 100%); }
.kpi-active-kp   { background: linear-gradient(135deg, #0c5460 0%, #17a2b8 100%); }
.kpi-completed-kp{ background: linear-gradient(135deg, #155724 0%, #28a745 100%); }
.kpi-stopped-kp  { background: linear-gradient(135deg, #721c24 0%, #dc3545 100%); }
.kpi-active-mo   { background: linear-gradient(135deg, #1c5c5c 0%, #20a09e 100%); }
.kpi-completed-mo{ background: linear-gradient(135deg, #1a4731 0%, #20c997 100%); }
.kpi-stopped-mo  { background: linear-gradient(135deg, #5a2d0c 0%, #e67e22 100%); }

/* Активная KPI-карточка */
.kpi-card[data-kpi-key] {
    cursor: pointer;
    transition: transform 0.15s, box-shadow 0.15s, opacity 0.15s;
}

.kpi-card[data-kpi-key]:hover {
    transform: translateY(-3px);
    box-shadow: 0 6px 18px rgba(28,63,118,0.30);
}

.kpi-card.kpi-active {
    outline: 3px solid #fff;
    outline-offset: 2px;
    transform: translateY(-3px);
    box-shadow: 0 6px 20px rgba(0,0,0,0.35);
}

/* Карточки без фильтра (менеджеры, бизнес) — не кликабельны */
.kpi-card[data-kpi-key=""] {
    cursor: default;
    opacity: 0.9;
}

/* =============================================================================
   Аналитика — сетка графиков
   ============================================================================= */
.analytics-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 20px;
    padding: 20px;
    background: #f0f2f5;
}

.chart-card {
    background: #fff;
    border-radius: 10px;
    border: 1px solid #e0e0e0;
    box-shadow: 0 2px 8px rgba(0,0,0,0.06);
    overflow: hidden;
}

.chart-wide {
    grid-column: 1 / -1;
}

.chart-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 18px 10px;
    border-bottom: 2px solid #e9ecef;
}

.chart-card-header h3 {
    margin: 0;
    font-size: 14px;
    font-weight: 600;
    color: #1c3f76;
}

.chart-hint {
    font-size: 11px;
    color: #adb5bd;
    font-style: italic;
}

.chart-body {
    padding: 14px;
    position: relative;
    min-height: 200px;
}

.chart-body-donut {
    min-height: 260px;
    max-height: 320px;
}

/* Split-блок: легенда слева, donut справа */
.chart-body-split {
    display: flex;
    gap: 16px;
    padding: 14px;
    min-height: 240px;
    align-items: center;
}

.split-legend {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 5px;
    overflow-y: auto;
    max-height: 280px;
}

.split-legend-row {
    display: flex;
    align-items: center;
    gap: 7px;
    font-size: 12px;
    padding: 3px 6px;
    border-radius: 4px;
    transition: background 0.1s;
}

.split-legend-row:hover {
    background: #f0f5ff;
}

.split-legend-dot {
    width: 11px;
    height: 11px;
    border-radius: 50%;
    flex-shrink: 0;
}

.split-legend-name {
    flex: 1;
    color: #333;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.split-legend-count {
    font-weight: 700;
    color: #1c3f76;
    min-width: 24px;
    text-align: right;
}

.split-legend-pct {
    color: #888;
    font-size: 11px;
    min-width: 38px;
    text-align: right;
}

.split-donut {
    width: 200px;
    height: 200px;
    flex-shrink: 0;
    position: relative;
}

/* =============================================================================
   Аналитика — таблица менеджеров
   ============================================================================= */
.analytics-table-wrap {
    overflow-x: auto;
}

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

.analytics-table thead tr {
    background: linear-gradient(135deg, #1c3f76 0%, #2c5aa0 100%);
    color: #fff;
}

.analytics-table th {
    padding: 10px 14px;
    text-align: left;
    font-weight: 600;
    white-space: nowrap;
    font-size: 12px;
}

.analytics-table td {
    padding: 9px 14px;
    border-bottom: 1px solid #f0f0f0;
    vertical-align: middle;
}

.analytics-table tbody tr:hover { background: #f0f5ff; }
.analytics-table tbody tr:last-child td { border-bottom: none; }

@media (max-width: 900px) {
    .analytics-grid       { grid-template-columns: 1fr; }
    .chart-wide           { grid-column: 1; }
    .analytics-kpi        { gap: 8px; }
    .kpi-card             { min-width: 100px; }
}

/* =============================================================================
   Блок «Обеспечение металлом» — полная ширина, данные + комментарий рядом
   ============================================================================= */

/* Блок на всю ширину раздела (вместо grid-колонки) */
.supply-full-block {
    width: 100%;
    margin-bottom: 10px;
}

/* Внутренний контейнер: данные слева, комментарий справа.
   Используем двойной класс .details-block .supply-metal-* чтобы
   специфичность (0,2,0) была выше, чем у .details-block div (0,1,1),
   иначе display:flex из .details-block div перебивает наш display:block. */
.details-block .supply-metal-inner {
    display: flex;
    flex-direction: row;
    justify-content: flex-start;
    gap: 16px;
    align-items: stretch;   /* обе колонки одной высоты */
    border-bottom: none;
    padding: 0;
    margin-bottom: 0;
}

.details-block .supply-metal-data {
    display: block;
    flex: 1.5;
    min-width: 0;
    border-bottom: none;
    padding: 0;
    margin-bottom: 0;
}

.details-block .supply-metal-right {
    display: flex;          /* чтобы дочерний элемент мог растянуться */
    flex-direction: column;
    flex: 1;
    min-width: 200px;
    border-bottom: none;
    padding: 0;
    margin-bottom: 0;
}

/* Комментарий БСМ — оформление как у других comment-block, на всю высоту */
.supply-comment-bsm {
    flex: 1;                /* растягивается на всю высоту правой колонки */
    margin: 0;
    padding: 10px 12px;
    background-color: #f8f9fa;
    border-radius: 6px;
    border: 1px solid #dee2e6;
    border-left: 3px solid #6c757d;
    font-size: 11px;
    line-height: 1.5;
    box-sizing: border-box;
}

.supply-comment-bsm strong {
    display: block;
    margin-bottom: 6px;
    color: #495057;
    font-weight: 600;
    font-size: 12px;
}

.supply-comment-bsm div {
    color: #212529;
    white-space: pre-wrap;
    display: block;
    border: none;
    padding: 0;
    font-size: 11px;
}

/* Заглушка если комментария нет */
.supply-comment-empty {
    flex: 1;
    margin: 0;
    padding: 10px 12px;
    background-color: #f8f9fa;
    border-radius: 6px;
    border: 1px dashed #dee2e6;
    color: #adb5bd;
    font-size: 11px;
    font-style: italic;
    display: flex;
    align-items: center;
    box-sizing: border-box;
}

/* Комментарий БСМ занимает всю высоту правой колонки */
.supply-comment-bsm {
    height: 100%;
    min-height: 80px;
}

/* Заглушка если комментария нет */
.supply-comment-empty {
    color: #adb5bd;
    font-size: 11px;
    font-style: italic;
    padding: 10px;
    border: 1px dashed #dee2e6;
    border-radius: 4px;
    min-height: 80px;
    display: flex;
    align-items: center;
}

/* На мобильных — вертикально */
@media (max-width: 768px) {
    .supply-metal-inner {
        flex-direction: column;
    }

    .supply-metal-right {
        min-width: unset;
        width: 100%;
    }
}

/* =============================================================================
   Счётчики оснастки (badge)
   ============================================================================= */
.tooling-counter {
    display: inline-block;
    background-color: #6c757d;
    color: white;
    font-size: 10px;
    padding: 1px 5px;
    border-radius: 10px;
    margin-left: 5px;
    vertical-align: middle;
}

.kp-tooling-counter { background-color: #17a2b8; }
.mo-tooling-counter { background-color: #28a745; }

/* =============================================================================
   Загрузка / нет данных
   ============================================================================= */
.loading {
    display: none;
    text-align: center;
    padding: 40px 20px;
    color: #2c5aa0;
    font-size: 14px;
    flex: 1;
    align-items: center;
    justify-content: center;
    flex-direction: column;
}

.loading.active {
    display: flex;
}

.spinner {
    border: 4px solid rgba(0, 0, 0, 0.1);
    border-radius: 50%;
    border-top: 4px solid #2c5aa0;
    width: 40px;
    height: 40px;
    animation: spin 1s linear infinite;
    margin-bottom: 10px;
}

@keyframes spin {
    0%   { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.no-data {
    text-align: center;
    padding: 40px 20px;
    color: #6c757d;
    font-size: 16px;
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 300px;
}

.no-data::before {
    content: "📭";
    font-size: 36px;
    display: block;
    margin-bottom: 10px;
    opacity: 0.5;
}

/* =============================================================================
   Футер
   ============================================================================= */
footer {
    text-align: center;
    padding: 10px 25px;
    color: #6c757d;
    font-size: 12px;
    border-top: 1px solid #eaeaea;
    background-color: #f8f9fa;
    flex-shrink: 0;
}

/* =============================================================================
   Адаптивность
   ============================================================================= */

/* 2K / Full HD */
@media (min-width: 1920px) {
    .container,
    body.analytics-page .container { max-width: 1800px; }
    .controls-section { padding: 15px 30px; }
    .table-container { padding: 20px 30px; }
    .filters { grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }
    .orders-table { font-size: 13px; }
    .orders-table th { padding: 14px 8px; }
    .orders-table td { padding: 12px 8px; }
    .orders-table th:nth-child(3)  { width: 280px; }
    .orders-table th:nth-child(7)  { width: 180px; }
    .orders-table th:nth-child(8)  { width: 140px; }
    .orders-table th:nth-child(11) { width: 240px; }
    .details-grid { grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 15px; }
    .status-indicator { font-size: 11px; padding: 4px 8px; }
    footer { padding: 10px 30px; }
    .analytics-grid { padding: 20px 30px; }
    .analytics-filters { padding: 16px 30px; }
    .analytics-kpi { padding: 16px 30px; }
}

@media (min-width: 1600px) and (max-width: 1919px) {
    .container,
    body.analytics-page .container { max-width: 1550px; }
    .orders-table th:nth-child(3)  { width: 220px; }
    .orders-table th:nth-child(7)  { width: 150px; }
    .orders-table th:nth-child(8)  { width: 110px; }
    .orders-table th:nth-child(11) { width: 180px; }
    .analytics-grid { padding: 16px 24px; }
    .analytics-filters { padding: 14px 24px; }
    .analytics-kpi { padding: 14px 24px; }
}

@media (max-width: 1599px) {
    .container { max-width: 100%; margin: 0 20px; }
    .orders-table th:nth-child(3)  { width: 200px; }
    .orders-table th:nth-child(7)  { width: 140px; }
    .orders-table th:nth-child(8)  { width: 100px; }
    .orders-table th:nth-child(11) { width: 160px; }
}

@media (max-width: 1400px) {
    .orders-table th:nth-child(3)  { width: 180px; }
    .orders-table th:nth-child(7)  { width: 120px; }
    .orders-table th:nth-child(8)  { width: 90px; }
    .orders-table th:nth-child(9)  { width: 100px; }
    .orders-table th:nth-child(10) { width: 100px; }
    .orders-table th:nth-child(11) { width: 140px; }
    .stat-card { min-width: 90px; }
}

@media (max-width: 1200px) {
    .table-container { overflow-x: auto; }
    .orders-table { min-width: 1100px; table-layout: auto; }
    .controls-section { flex-direction: column; align-items: stretch; }
    .filters { grid-template-columns: 1fr; }
    .stats { flex-wrap: wrap; justify-content: center; }
    .stat-card { min-width: 90px; flex: 1; }
}

@media (max-width: 992px) {
    body { padding: 15px; }
    .container { height: calc(100vh - 30px); }
    header { padding: 12px 20px; }
    header h1 { font-size: 20px; }
    .controls-section { padding: 10px 20px; }
    .table-container { padding: 10px 20px; }
    .btn { padding: 7px 12px; font-size: 12px; }
    .file-info { font-size: 11px; min-width: 120px; }
    footer { padding: 10px 20px; }
    .stat-card { min-width: 85px; padding: 6px 8px; }
    .stat-value { font-size: 16px; }
}

@media (max-width: 768px) {
    body { padding: 10px; }
    .container { height: calc(100vh - 20px); border-radius: 8px; }
    header { padding: 10px 15px; }
    header h1 { font-size: 18px; }
    header p { font-size: 12px; }
    .controls-section { padding: 8px 15px; gap: 8px; }
    .table-container { padding: 8px 15px; }
    .orders-table th, .orders-table td { padding: 8px 4px; font-size: 11px; }
    .orders-table th:nth-child(2)  { width: 30px; }
    .orders-table th:nth-child(3)  { width: 140px; }
    .orders-table th:nth-child(6)  { width: 45px; }
    .orders-table th:nth-child(7)  { width: 100px; }
    .orders-table th:nth-child(8)  { width: 80px; }
    .orders-table th:nth-child(11) { width: 120px; }
    .orders-table th:nth-child(12) { width: 35px; }
    .details-grid { grid-template-columns: 1fr; }
    .drawings-table { font-size: 9px; }
    .drawings-table th, .drawings-table td { padding: 3px 4px; }
    .status-indicator { font-size: 9px; padding: 2px 4px; max-width: 80px; }
    .stat-card { min-width: 80px; padding: 6px 8px; }
    .stat-value { font-size: 16px; }
    footer { padding: 8px 15px; }
}

@media (max-width: 576px) {
    .file-controls { flex-direction: column; align-items: stretch; }
    .btn { width: 100%; justify-content: center; }
    .file-info { width: 100%; text-align: center; }
    .orders-table th, .orders-table td { padding: 6px 3px; font-size: 10px; }
    .orders-table th:nth-child(2)  { width: 25px; }
    .orders-table th:nth-child(3)  { width: 120px; }
    .orders-table th:nth-child(7)  { width: 90px; }
    .orders-table th:nth-child(8)  { width: 70px; }
    .orders-table th:nth-child(11) { width: 100px; }
    .orders-table th:nth-child(12) { width: 30px; }
    .status-indicator { font-size: 8px; padding: 2px 3px; max-width: 70px; }
    .toggle-btn, .open-new-tab-btn { width: 20px; height: 20px; }
    .stat-card { min-width: 70px; padding: 5px 6px; font-size: 11px; }
    .stat-value { font-size: 14px; }
}

/* Низкие экраны */
@media (max-height: 700px) {
    body { padding: 15px; }
    .container { height: calc(100vh - 30px); }
    .controls-section { padding: 8px 20px; gap: 8px; }
    .filters { padding: 8px; }
    .filter-select, .filter-input { height: 28px; padding: 5px 7px; }
    .orders-table th { padding: 8px 5px; }
    .orders-table td { padding: 8px 5px; }
    .details-container { max-height: 350px; padding: 10px; }
}

@media (max-height: 600px) {
    body { padding: 10px; }
    .container { height: calc(100vh - 20px); }
    .controls-section { padding: 6px 15px; }
    header { padding: 8px 15px; }
    header h1 { font-size: 18px; margin-bottom: 3px; }
    .orders-table th { padding: 6px 4px; }
    .orders-table td { padding: 6px 4px; }
    .details-container { max-height: 250px; }
}


/* =============================================================================
   Страница логина — строгий индустриальный стиль
   ============================================================================= */

/* ================================================
   Страница логина — светлый современный стиль
   ================================================ */

/* login page */
body.login-page {
    display:flex; align-items:center; justify-content:center;
    min-height:100vh; padding:40px 20px; overflow:auto;
    background:#eef2f7;
}
.login-wrapper { width:100%; max-width:520px; }
.login-card { background:#fff; border-radius:14px; box-shadow:0 12px 48px rgba(28,63,118,0.15); overflow:hidden; }

/* header */
.login-header { background:linear-gradient(135deg,#1c3f76 0%,#2c5aa0 100%); padding:32px 44px 28px; }
.login-brand { display:flex; align-items:center; gap:18px; }
.login-logo { width:56px; height:56px; border-radius:50%; object-fit:cover; flex-shrink:0; box-shadow:0 2px 12px rgba(0,0,0,0.25); }
.login-brand-info { display:flex; flex-direction:column; gap:5px; }
.login-app-title { font-size:21px; font-weight:700; color:#fff; margin:0 0 6px; line-height:1.3; }
.login-app-sub { font-size:13px; color:rgba(255,255,255,0.52); margin:0; }

/* tabs */
.login-tabs { display:flex; border-bottom:1px solid #e4eaf3; }
.login-tab {
    flex:1; padding:16px 12px; background:#f7f9fc; border:none;
    border-bottom:3px solid transparent; margin-bottom:-1px;
    font-size:13px; font-weight:600; color:#8fa4bc; cursor:pointer; transition:all 0.2s;
}
.login-tab:hover { color:#2c5aa0; background:#eef3fb; }
.login-tab-active { background:#fff; color:#1c3f76; border-bottom-color:#2c5aa0; }

/* form */
.login-form-wrap { padding:32px 44px 28px; display:flex; flex-direction:column; gap:20px; }
.login-hidden { display:none !important; }

/* alerts */
.login-alert { padding:12px 15px; font-size:14px; border-radius:8px; margin:16px 44px -6px; line-height:1.4; }
.login-alert-error { background:#fff5f5; color:#c0392b; border:1px solid #f5c6c6; }
.login-alert-info { background:#f0faf4; color:#1e8449; border:1px solid #b7e4c7; }

/* fields */
.login-field { display:flex; flex-direction:column; gap:8px; }
.login-label { font-size:13px; font-weight:600; color:#4a6780; }
.login-field-hint { font-size:12px; color:#a8bccf; }

/* input — НЕ на всю ширину, с отступами */
.login-input {
    width:100%; padding:13px 16px;
    background:#f7f9fc; border:1.5px solid #dce6f0; border-radius:8px;
    font-size:15px; color:#1a2a3a;
    transition:border-color 0.2s,background 0.2s,box-shadow 0.2s;
    outline:none; box-sizing:border-box;
}
.login-input::placeholder { color:#aabcce; }
.login-input:focus { background:#fff; border-color:#2c5aa0; box-shadow:0 0 0 3px rgba(44,90,160,0.09); }

/* button — НЕ на всю ширину */
.login-btn {
    width:100%; margin-top:20px; padding:14px 20px;
    background:linear-gradient(135deg,#1c3f76 0%,#2c5aa0 100%);
    color:#fff; border:none; border-radius:8px;
    font-size:15px; font-weight:600; cursor:pointer;
    transition:opacity 0.2s,transform 0.1s;
    box-shadow:0 4px 16px rgba(28,63,118,0.22);
    box-sizing:border-box;
}
.login-btn:hover { opacity:0.91; }
.login-btn:active { transform:scale(0.99); }

/* hint */
.login-hint { text-align:center; font-size:13px; color:#90a4b8; margin:0; }
.login-hint a { color:#2c5aa0; font-weight:600; text-decoration:none; }
.login-hint a:hover { text-decoration:underline; }

/* footer */
.login-footer { text-align:center; font-size:12px; color:#b0c0d0; padding:0 44px 24px; margin:0; }

/* nav logout */
.nav-link-logout { margin-left:auto; color:rgba(255,255,255,0.6) !important; font-size:12px !important; }
.nav-link-logout:hover { color:#fff !important; border-bottom-color:rgba(255,255,255,0.3) !important; }
