:root {
    --primary: #249bd3;      /* light-blue */
    --secondary: #2ca97c;    /* dark-green */
    --bg: #f8fafc;
    --surface: #ffffff;
    --text: #1e293b;
    --border: #e2e8f0;
    --danger: #ef4444;
    --warning: #f59e0b;
    --success: #22c55e;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
}

/* Header */
.header {
    background: var(--surface);
    border-bottom: 2px solid var(--primary);
    padding: 1rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 100;
}
.logo {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--primary);
}
.header nav a {
    margin-left: 1rem;
    text-decoration: none;
    color: var(--text);
    font-weight: 500;
    transition: color 0.2s;
}
.header nav a:hover { color: var(--primary); }

/* Container */
.container { max-width: 90%; margin: 0 auto; padding: 1.5rem; }

/* Toolbar */
.toolbar {
    display: flex;
    gap: 1rem;
    margin-bottom: 1rem;
    flex-wrap: wrap;
}
.toolbar input, .toolbar select {
    padding: 0.5rem 1rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 0.95rem;
    min-width: 200px;
}

/* Table */
.table-wrapper {
    background: var(--surface);
    border-radius: 10px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    overflow: auto;          /* Включает скролл по обоим осям */
    max-height: 75vh;        /* Ограничивает высоту, чтобы шапка прилипала к контейнеру */
    border: 1px solid var(--border);
}

/* Сама таблица */
.license-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
    min-width: 1000px;       /* Предотвращает сплющивание колонок */
}

/* Заголовок таблицы */
.license-table th {
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    color: white;
    padding: 0.85rem 1rem;
    text-align: left;
    font-weight: 600;
    position: sticky;
    top: 0;                  /* ✅ Теперь привязка к верху КОНТЕЙНЕРА, а не экрана */
    z-index: 10;
    white-space: nowrap;     /* Запрещает перенос текста в шапке */
}

/* Ячейки таблицы */
.license-table td {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--border);
    /* white-space: nowrap;     /* Сохраняет выравнивание колонок */ */
    vertical-align: middle;
}

/* Убираем двойные границы при скролле */
.license-table thead th {
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.wrap-column {
  min-width: 300px;
  overflow-wrap: break-word;
}

.status-column {
  min-width: 155px;
}
.license-table tr:hover { background: #f1f5f9; }
.license-table tr.status-expired { background: #fef2f2; }
.license-table tr.status-soon { background: #fffbeb; }

.key-cell {
    font-family: monospace;
    font-size: 0.85rem;
    color: #64748b;
    max-width: 200px;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Status badges */
.status-badge {
    padding: 0.25rem 0.75rem;
    border-radius: 999px;
    font-size: 0.8rem;
    font-weight: 500;
    display: inline-block;
}
.status-active { background: #dcfce7; color: #166534; }
.status-soon { background: #fef3c7; color: #92400e; }
.status-expired { background: #fee2e2; color: #991b1b; }
.status-none { background: #f1f5f9; color: #475569; }
.status-error { background: #f1f5f9; color: #dc2626; }

/* Actions */
.actions { display: flex; gap: 0.5rem; }
.actions button {
    background: none;
    border: none;
    font-size: 1.1rem;
    cursor: pointer;
    padding: 0.25rem;
    border-radius: 4px;
    transition: background 0.2s;
}
.actions button:hover { background: #e2e8f0; }
.btn-delete:hover { background: #fee2e2; }

/* Buttons */
.btn-primary {
    background: var(--secondary);
    color: white;
    border: none;
    padding: 0.5rem 1.25rem;
    border-radius: 6px;
    font-weight: 500;
    cursor: pointer;
    transition: opacity 0.2s;
}
.btn-primary:hover { opacity: 0.9; }
.btn-cancel {
    background: #e2e8f0;
    color: var(--text);
    border: none;
    padding: 0.5rem 1.25rem;
    border-radius: 6px;
    cursor: pointer;
}

/* Modal */
.modal {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 200;
    padding: 1rem;
}
.modal.hidden { display: none; }
.modal-content {
    background: var(--surface);
    border-radius: 12px;
    padding: 1.5rem;
    width: 100%;
    max-width: 600px;
    max-height: 90vh;
    overflow-y: auto;
    position: relative;
}
.modal-close {
    position: absolute;
    top: 1rem;
    right: 1.25rem;
    font-size: 1.5rem;
    cursor: pointer;
    color: #64748b;
}
.modal-close:hover { color: var(--text); }

/* Form */
.form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    margin: 1rem 0;
}
.form-grid .full { grid-column: 1 / -1; }
.form-grid label {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    font-size: 0.9rem;
    font-weight: 500;
}
.form-grid input, .form-grid textarea {
    padding: 0.5rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 0.95rem;
}
.form-actions {
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
    margin-top: 1.5rem;
}

/* Flash messages */
.flash-messages { margin-bottom: 1rem; }
.flash {
    background: var(--secondary);
    color: white;
    padding: 0.75rem 1rem;
    border-radius: 6px;
    margin-bottom: 0.5rem;
}

/* Empty state */
.empty-state {
    text-align: center;
    padding: 3rem;
    color: #64748b;
}

/* Responsive */
@media (max-width: 768px) {
    .form-grid { grid-template-columns: 1fr; }
    .header { flex-direction: column; gap: 0.75rem; }
    .toolbar { flex-direction: column; }
    .toolbar input, .toolbar select { width: 100%; }
}
