*, *::before, *::after {
    box-sizing: border-box;
}

/* Общие стили */
body {
    font-family: 'Roboto', sans-serif;
    background-color: #f0f2f5;
    margin: 0;
    padding: 0;
    min-height: 100vh;
}

/* Основной контент с отступом для фиксированного header */
main {
    margin-top: 120px;
    padding: 2rem;
}

header {
    background-color: #007bff;
    color: white;
    padding: 1rem;
    text-align: center;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    position: fixed;
    top: 0;
    width: 100%;
    z-index: 1000;
}

header h1 {
    margin: 0;
    font-size: 1.8rem;
}

header nav {
    margin-top: 15px;
}

nav a {
    color: white;
    margin: 0 1rem;
    text-decoration: none;
    font-weight: 500;
    transition: color 0.3s;
}

nav a:hover {
    color: #e0e0e0;
}

/* Контейнер для форм */
.container {
    background: white;
    padding: 2rem;
    border-radius: 10px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    width: 100%;
    max-width: 400px;
    margin: 2rem auto;
}

/* Стили для форм */
form {
    display: flex;
    flex-direction: column;
}

label {
    font-size: 1rem;
    color: #333;
    margin-bottom: 0.5rem;
}

input[type="text"],
input[type="password"],
input[type="number"],
input[type="file"] {
    padding: 0.8rem;
    border: 1px solid #ccc;
    border-radius: 5px;
    font-size: 1rem;
    margin-bottom: 1rem;
    transition: border-color 0.3s;
}

input:focus {
    outline: none;
    border-color: #007bff;
    box-shadow: 0 0 5px rgba(0, 123, 255, 0.3);
}

button {
    background-color: #007bff;
    color: white;
    padding: 0.8rem;
    border: none;
    border-radius: 5px;
    font-size: 1rem;
    cursor: pointer;
    transition: background-color 0.3s;
}

button:hover {
    background-color: #0056b3;
}

/* Уведомления */
.error, .message {
    padding: 0.8rem;
    border-radius: 5px;
    margin-bottom: 1rem;
    text-align: center;
    word-break: break-word;
    overflow-wrap: anywhere;
    white-space: pre-wrap;
}

.error {
    background-color: #f8d7da;
    color: #721c24;
}

.message {
    background-color: #d4edda;
    color: #155724;
}

/* Стили для таблицы аккаунтов */
.accounts-table {
    margin: 2rem 0;
    background: white;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    overflow: hidden;
}

/* Контейнер для прокрутки таблицы */
.table-scroll-container {
    max-height: 500px;
    overflow-y: auto;
    overflow-x: auto;
}

.accounts-table table {
    width: 100%;
    min-width: 800px;
    border-collapse: collapse;
    background: white;
    table-layout: fixed; /* Фиксированная ширина колонок */
}

/* Фиксированный заголовок таблицы */
.accounts-table thead {
    position: sticky;
    top: 0;
    z-index: 10;
}

.accounts-table th,
.accounts-table td {
    padding: 1rem;
    text-align: left;
    border-bottom: 1px solid #e0e0e0;
    overflow: hidden;
    text-overflow: ellipsis;
}

.accounts-table th {
    background-color: #007bff;
    color: white;
    font-weight: 500;
    text-transform: uppercase;
    font-size: 0.9rem;
}

.accounts-table tbody tr:hover {
    background-color: #f8f9fa;
}

.accounts-table tbody tr:last-child td {
    border-bottom: none;
}

/* Стили для ячейки с секретом */
.secret-cell {
    position: relative;
    word-break: break-all;
}

.secret-hidden,
.secret-visible {
    display: inline-block;
    max-width: 100%;
    word-break: break-all;
    overflow-wrap: break-word;
}

.secret-visible {
    font-family: 'Courier New', monospace;
    font-size: 0.85em;
}

.toggle-secret-btn {
    background: none;
    border: 1px solid #007bff;
    color: #007bff;
    padding: 0.2rem 0.4rem;
    margin-left: 0.3rem;
    border-radius: 3px;
    cursor: pointer;
    font-size: 0.7rem;
    transition: all 0.3s;
    white-space: nowrap;
}

.toggle-secret-btn:hover {
    background-color: #007bff;
    color: white;
}

/* Стили для редактирования */
.actions-cell {
    min-width: 120px;
    white-space: nowrap;
}

.edit-btn, .save-btn, .cancel-btn {
    background: none;
    border: 1px solid;
    padding: 0.3rem 0.5rem;
    margin: 0 0.2rem;
    border-radius: 3px;
    cursor: pointer;
    font-size: 0.8rem;
    transition: all 0.3s;
}

.edit-btn {
    border-color: #28a745;
    color: #28a745;
}

.edit-btn:hover {
    background-color: #28a745;
    color: white;
}

.save-btn {
    border-color: #007bff;
    color: #007bff;
}

.save-btn:hover {
    background-color: #007bff;
    color: white;
}

.cancel-btn {
    border-color: #dc3545;
    color: #dc3545;
}

.cancel-btn:hover {
    background-color: #dc3545;
    color: white;
}

.edit-input {
    width: 80%;
    padding: 0.3rem;
    border: 1px solid #007bff;
    border-radius: 3px;
    font-size: 0.9rem;
    background-color: #f8f9fa;
}

.edit-input:focus {
    outline: none;
    border-color: #0056b3;
    box-shadow: 0 0 3px rgba(0, 123, 255, 0.3);
}

/* Стили для отсутствующих аккаунтов */
.no-accounts {
    text-align: center;
    padding: 3rem;
    background-color: #f8f9fa;
    border-radius: 8px;
    margin: 2rem 0;
}

.no-accounts p {
    font-size: 1.2rem;
    color: #6c757d;
    margin-bottom: 1.5rem;
}

/* Кнопки действий */
.action-buttons {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 2rem;
    gap: 1rem;
}

.btn-primary,
.btn-secondary,
.btn-create {
    padding: 0.8rem 1.5rem;
    border: none;
    border-radius: 5px;
    text-decoration: none;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.3s;
    display: inline-block;
    text-align: center;
}

.btn-primary {
    background-color: #007bff;
    color: white;
}

.btn-primary:hover {
    background-color: #0056b3;
}

.btn-secondary {
    background-color: #6c757d;
    color: white;
}

.btn-secondary:hover {
    background-color: #545b62;
}

.btn-create {
    background-color: #28a745;
    color: white;
}

.btn-create:hover {
    background-color: #218838;
}

/* Расширение контейнера для таблицы */
.container.wide {
    max-width: 1200px;
    margin: 0 auto;
}

/* Скроллбар */
.table-scroll-container::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

.table-scroll-container::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 4px;
}

.table-scroll-container::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 4px;
}

.table-scroll-container::-webkit-scrollbar-thumb:hover {
    background: #a8a8a8;
}

/* Адаптивность для таблицы */
@media (max-width: 768px) {
    .accounts-table {
        font-size: 0.9rem;
    }

    .accounts-table th,
    .accounts-table td {
        padding: 0.5rem;
    }

    .action-buttons {
        flex-direction: column;
        align-items: stretch;
    }

    .btn-primary,
    .btn-secondary,
    .btn-create {
        margin-bottom: 0.5rem;
    }
}

@media (max-width: 600px) {
    .accounts-table table {
        font-size: 0.8rem;
    }
    
    .secret-cell {
        min-width: 150px;
        max-width: 200px;
    }
    
    .toggle-secret-btn {
        padding: 0.1rem 0.3rem;
        font-size: 0.7rem;
    }
    
    .table-scroll-container {
        max-height: 300px;
    }
}

/* Бейджи статуса сертификата */
.badge {
    display: inline-block;
    padding: 0.25rem 0.5rem;
    font-size: 0.8rem;
    font-weight: 500;
    line-height: 1;
    text-align: center;
    white-space: nowrap;
    vertical-align: baseline;
    border-radius: 4px;
}

.badge-success {
    color: #155724;
    background-color: #d4edda;
    border: 1px solid #c3e6cb;
}

.badge-warning {
    color: #856404;
    background-color: #fff3cd;
    border: 1px solid #ffeeba;
}

/* Кнопка удаления */
.delete-btn {
    border-color: #dc3545;
    color: #dc3545;
    background: none;
    border: 1px solid #dc3545;
    padding: 0.3rem 0.5rem;
    margin: 0 0.2rem;
    border-radius: 3px;
    cursor: pointer;
    font-size: 0.8rem;
    transition: all 0.3s;
}

.delete-btn:hover {
    background-color: #dc3545;
    color: white;
}

/* Поле загрузки сертификата */
.cert-cell {
    min-width: 170px;
}

.cert-input-wrapper {
    margin-top: 0.3rem;
}

.cert-hint {
    display: block;
    font-size: 0.72rem;
    color: #6c757d;
    margin-top: 2px;
}

.edit-cert-input {
    font-size: 0.75rem;
    max-width: 170px;
    padding: 0.2rem;
}