* { box-sizing: border-box; }

body {
    font-family: Arial, Helvetica, sans-serif;
    margin: 0;
    background: #f5f5f5;
    color: #222;
}

.topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #2c3e50;
    color: #fff;
    padding: 10px 20px;
}

.topbar nav {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 4px 0;
}

.topbar a,
.topbar .btn-link {
    color: #fff;
    margin-left: 10px;
}

.topbar .btn-link {
    background: none;
    border: none;
    padding: 0;
    cursor: pointer;
    font-size: inherit;
    font-family: inherit;
}

.topbar .user {
    margin-right: 4px;
    opacity: 0.85;
}

.container {
    max-width: 960px;
    margin: 20px auto;
    background: #fff;
    padding: 20px;
    border-radius: 6px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

h1 {
    margin-top: 0;
}

section {
    margin-bottom: 30px;
}

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

th, td {
    border: 1px solid #ddd;
    padding: 8px;
    text-align: left;
    vertical-align: middle;
}

th {
    background: #f0f0f0;
}

.form label {
    display: block;
    margin-bottom: 12px;
}

.form input {
    display: block;
    margin-top: 4px;
    padding: 6px;
    width: 100%;
    max-width: 300px;
}

.form-inline {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    align-items: center;
}

.form-inline input,
.form-inline select {
    padding: 4px;
}

button {
    padding: 6px 14px;
    cursor: pointer;
    background: #2c3e50;
    color: #fff;
    border: none;
    border-radius: 4px;
}

button:hover {
    background: #1a252f;
}

.scan-form input[type="text"] {
    font-size: 18px;
    padding: 10px;
    max-width: 280px;
}

.error {
    color: #b00020;
    font-weight: bold;
}

.success {
    color: #1a7a1a;
    font-weight: bold;
}

/* Остаток модели по уровню наличия */
.stock-ok {
    color: #1a7a1a;
    font-weight: bold;
}

.stock-low {
    color: #b8860b;
    font-weight: bold;
}

.stock-out {
    color: #b00020;
    font-weight: bold;
}

/* Flash-сообщения */
.flash {
    padding: 12px 16px;
    border-radius: 4px;
    margin-bottom: 16px;
    font-weight: bold;
    transition: opacity 0.4s;
}

.flash-success {
    background: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

.flash-error {
    background: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

.flash.fade-out { opacity: 0; }

/* Бейджи статусов */
.badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: bold;
    white-space: nowrap;
}

.badge-in-stock   { background: #d4edda; color: #155724; }
.badge-checked-out { background: #f8d7da; color: #721c24; }
.badge-maintenance { background: #fff3cd; color: #856404; }
.badge-decommissioned { background: #e2e3e5; color: #383d41; }
.badge-lost       { background: #f5c6cb; color: #491217; }
.badge-checkout   { background: #fdebd0; color: #7d4400; }
.badge-checkin    { background: #d4edda; color: #155724; }

/* Hover строк таблицы */
tbody tr:hover td { background: #f0f4f8; }

/* Кнопки опасных действий */
.btn-danger {
    background: #c0392b;
}

.btn-danger:hover {
    background: #96281b;
}

/* Статистика на странице проектов */
.stats-bar {
    display: flex;
    gap: 24px;
    flex-wrap: wrap;
    background: #f8f9fa;
    border: 1px solid #e0e0e0;
    border-radius: 6px;
    padding: 14px 20px;
    margin-bottom: 24px;
}

.stat {
    display: flex;
    flex-direction: column;
    align-items: center;
    min-width: 70px;
}

.stat-num {
    font-size: 26px;
    font-weight: bold;
    line-height: 1;
}

.stat-label {
    font-size: 11px;
    color: #666;
    margin-top: 4px;
    text-align: center;
}

/* Карточки активных проектов */
.project-cards {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 14px;
    margin-bottom: 8px;
}

.project-card {
    display: block;
    background: #2c3e50;
    color: #fff;
    border-radius: 8px;
    padding: 16px 20px;
    text-decoration: none;
    transition: background 0.15s;
}

.project-card:hover { background: #1a252f; }

.project-card-name {
    font-size: 15px;
    font-weight: bold;
    margin-bottom: 6px;
}

.project-card-client {
    font-size: 13px;
    opacity: 0.75;
    margin-bottom: 4px;
}

.project-card-date {
    font-size: 11px;
    opacity: 0.55;
}

/* Сворачиваемые категории оборудования */
details {
    margin-bottom: 14px;
    border: 1px solid #ddd;
    border-radius: 4px;
    background: #fafafa;
    padding: 6px 12px;
}

details[open] {
    padding-bottom: 12px;
}

details summary {
    cursor: pointer;
    font-weight: bold;
    padding: 6px 0;
    font-size: 16px;
}

details summary:hover {
    color: #2c3e50;
}

details table {
    margin-top: 10px;
    background: #fff;
}

section h2 {
    margin-bottom: 12px;
}

/* Печать этикеток со штрихкодами */
.labels-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.label-card {
    border: 1px dashed #999;
    padding: 8px 12px;
    text-align: center;
}

.label-title {
    font-size: 12px;
    max-width: 200px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

@media (max-width: 640px) {
    .topbar {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
        padding: 10px 14px;
    }

    .topbar nav {
        display: flex;
        flex-wrap: wrap;
        align-items: center;
        gap: 6px 12px;
        width: 100%;
    }

    .topbar .search-form {
        order: 10;
        width: 100%;
    }

    .topbar .search-form input {
        flex: 1;
        min-width: 0;
    }

    .container {
        margin: 0;
        border-radius: 0;
        padding: 14px;
        box-shadow: none;
    }

    table {
        display: block;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    button,
    input[type="submit"] {
        min-height: 44px;
        padding: 10px 16px;
    }

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

    .scan-form input[type="text"] {
        max-width: 100%;
        width: 100%;
        font-size: 22px;
        padding: 14px;
    }

    .form input,
    .form select,
    .form textarea {
        max-width: 100%;
    }

    .stats-bar { gap: 16px; padding: 12px 14px; }
    .stat-num { font-size: 20px; }
    .project-cards { grid-template-columns: 1fr 1fr; }

    .form-inline:not(.search-form) {
        flex-direction: column;
        align-items: stretch;
    }

    .form-inline:not(.search-form) input,
    .form-inline:not(.search-form) select {
        width: 100%;
    }
}

@media print {
    .no-print { display: none; }
    .topbar { display: none; }
    .container { box-shadow: none; max-width: 100%; }
    .label-card { break-inside: avoid; }
}
