:root {
    --primary: #2563eb;
    --primary-hover: #1d4ed8;
    --danger: #dc2626;
    --success: #16a34a;
    --warning: #d97706;
    --gray-50: #f9fafb;
    --gray-100: #f3f4f6;
    --gray-200: #e5e7eb;
    --gray-300: #d1d5db;
    --gray-500: #6b7280;
    --gray-700: #374151;
    --gray-900: #111827;
    --radius: 8px;
    --shadow: 0 1px 3px rgba(0,0,0,0.1);
    --shadow-lg: 0 10px 25px rgba(0,0,0,0.15);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background: var(--gray-50);
    color: var(--gray-900);
    line-height: 1.5;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}

/* ===== Header ===== */
.header {
    background: white;
    border-bottom: 1px solid var(--gray-200);
    padding: 16px 0;
    position: sticky;
    top: 0;
    z-index: 10;
}

.header .container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 16px;
}

.header h1 {
    font-size: 20px;
    font-weight: 600;
}

.tabs {
    display: flex;
    gap: 8px;
}

.tab {
    padding: 8px 16px;
    border: none;
    background: transparent;
    border-radius: var(--radius);
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    color: var(--gray-500);
    transition: all 0.2s;
}

.tab:hover {
    background: var(--gray-100);
    color: var(--gray-700);
}

.tab.active {
    background: var(--primary);
    color: white;
}

/* ===== Pages ===== */
main {
    padding: 24px 20px;
}

.page {
    display: none;
}

.page.active {
    display: block;
}

.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    flex-wrap: wrap;
    gap: 12px;
}

.page-header h2 {
    font-size: 24px;
    font-weight: 600;
}

.actions {
    display: flex;
    gap: 12px;
    align-items: center;
}

/* ===== Buttons ===== */
.btn {
    padding: 8px 16px;
    border: none;
    border-radius: var(--radius);
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.btn-primary {
    background: var(--primary);
    color: white;
}

.btn-primary:hover {
    background: var(--primary-hover);
}

.btn-secondary {
    background: var(--gray-100);
    color: var(--gray-700);
}

.btn-secondary:hover {
    background: var(--gray-200);
}

.btn-success {
    background: var(--success);
    color: white;
}

.btn-success:hover {
    opacity: 0.9;
}

.btn-warning {
    background: var(--warning);
    color: white;
}

.btn-danger {
    background: var(--danger);
    color: white;
}

.btn-danger:hover {
    opacity: 0.9;
}

.btn-sm {
    padding: 4px 10px;
    font-size: 13px;
}

/* ===== Inputs ===== */
.input, select.input {
    padding: 8px 12px;
    border: 1px solid var(--gray-300);
    border-radius: var(--radius);
    font-size: 14px;
    background: white;
    width: 100%;
}

.input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.form-group {
    margin-bottom: 16px;
}

.form-group label {
    display: block;
    margin-bottom: 6px;
    font-size: 14px;
    font-weight: 500;
    color: var(--gray-700);
}

/* ===== Table ===== */
.table-wrapper {
    background: white;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow-x: auto;
}

.table {
    width: 100%;
    border-collapse: collapse;
}

.table th,
.table td {
    padding: 12px 16px;
    text-align: left;
    border-bottom: 1px solid var(--gray-100);
}

.table th {
    background: var(--gray-50);
    font-weight: 600;
    font-size: 13px;
    color: var(--gray-500);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.table tbody tr:hover {
    background: var(--gray-50);
}

.table td.loading {
    text-align: center;
    color: var(--gray-500);
    padding: 40px;
}

.table .actions-cell {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

/* ===== Badges ===== */
.badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
}

.badge-available {
    background: #dcfce7;
    color: #166534;
}

.badge-issued {
    background: #fef3c7;
    color: #92400e;
}

.badge-lost {
    background: #fee2e2;
    color: #991b1b;
}

.badge-role {
    background: var(--gray-100);
    color: var(--gray-700);
}

/* ===== Modal ===== */
.modal-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.5);
    z-index: 100;
    justify-content: center;
    align-items: flex-start;
    padding: 40px 20px;
    overflow-y: auto;
}

.modal-overlay.active {
    display: flex;
}

.modal {
    background: white;
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    width: 100%;
    max-width: 500px;
    animation: slideDown 0.2s ease;
}

@keyframes slideDown {
    from { transform: translateY(-20px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    border-bottom: 1px solid var(--gray-200);
}

.modal-header h3 {
    font-size: 18px;
    font-weight: 600;
}

.modal-close {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: var(--gray-500);
    line-height: 1;
}

.modal-close:hover {
    color: var(--gray-900);
}

.modal-body {
    padding: 20px;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    margin-top: 20px;
}

/* ===== Toast ===== */
.toast-container {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 200;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.toast {
    padding: 12px 20px;
    border-radius: var(--radius);
    color: white;
    font-size: 14px;
    box-shadow: var(--shadow-lg);
    animation: slideIn 0.3s ease;
    min-width: 250px;
}

@keyframes slideIn {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

.toast-success { background: var(--success); }
.toast-error { background: var(--danger); }
.toast-info { background: var(--primary); }

/* ===== History list ===== */
.history-list {
    list-style: none;
    max-height: 400px;
    overflow-y: auto;
}

.history-item {
    padding: 12px;
    border-bottom: 1px solid var(--gray-100);
    display: flex;
    justify-content: space-between;
    gap: 12px;
}

.history-item:last-child {
    border-bottom: none;
}

.history-action {
    font-weight: 600;
}

.history-time {
    font-size: 12px;
    color: var(--gray-500);
}

.empty-state {
    text-align: center;
    padding: 40px;
    color: var(--gray-500);
}

/* ===== Responsive ===== */
@media (max-width: 768px) {
    .header .container {
        flex-direction: column;
        align-items: flex-start;
    }
    .page-header {
        flex-direction: column;
        align-items: flex-start;
    }
}

/* Добавь к существующим стилям */

.text-muted {
    color: var(--gray-500);
    font-size: 0.9em;
}

.pagination {
    margin-top: 20px;
}

/* Улучшение textarea */
textarea.input {
    resize: vertical;
    min-height: 60px;
}

/* Адаптивность для формы оборудования */
@media (max-width: 600px) {
    .page-header .actions {
        flex-direction: column;
        width: 100%;
    }
    .page-header .actions input, 
    .page-header .actions select,
    .page-header .actions button {
        width: 100%;
    }
}

/* ===== Карточка оборудования (детали) ===== */
.eq-details {
    padding: 10px 0;
}

.eq-detail-row {
    display: flex;
    margin-bottom: 14px;
    border-bottom: 1px solid var(--gray-100);
    padding-bottom: 10px;
}

.eq-detail-row:last-child {
    border-bottom: none;
    margin-bottom: 0;
}

.eq-label {
    width: 140px;
    font-weight: 600;
    color: var(--gray-500);
    flex-shrink: 0;
    font-size: 14px;
}

.eq-value {
    flex-grow: 1;
    color: var(--gray-900);
    font-size: 14px;
    word-break: break-word;
}

.eq-description {
    white-space: pre-wrap; /* Сохраняет переносы строк в описании */
    color: var(--gray-700);
    line-height: 1.5;
}

.doc-link {
    color: var(--primary);
    text-decoration: none;
    font-weight: 500;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.doc-link:hover {
    text-decoration: underline;
    color: var(--primary-hover);
}