/* Дизайн-система веб-интерфейса (vanilla CSS, без внешних CDN).
   Визуальный стиль повторяет example-web: светлая тема, карточки,
   синий акцент, системный стек шрифтов вместо Inter. */

:root {
    --brand-500: #3b82f6;
    --brand-600: #2563eb;
    --brand-700: #1d4ed8;
    --gray-50: #f9fafb;
    --gray-100: #f3f4f6;
    --gray-200: #e5e7eb;
    --gray-300: #d1d5db;
    --gray-400: #9ca3af;
    --gray-500: #6b7280;
    --gray-700: #374151;
    --gray-900: #111827;
    --red-50: #fef2f2;
    --red-500: #ef4444;
    --red-600: #dc2626;
    --red-700: #b91c1c;
    --green-600: #16a34a;
    --radius: 8px;
    --shadow-sm: 0 1px 2px rgba(17, 24, 39, 0.06);
    --shadow-lg: 0 10px 25px rgba(17, 24, 39, 0.12);
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: "Segoe UI", -apple-system, BlinkMacSystemFont, Roboto,
        "Helvetica Neue", Arial, sans-serif;
    font-weight: 400;
    color: var(--gray-900);
    background: var(--gray-50);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.container {
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 16px;
}

.muted { color: var(--gray-500); }
.hidden { display: none !important; }

/* --- Верхняя навигация --- */
.topnav {
    background: #fff;
    border-bottom: 1px solid var(--gray-200);
    position: sticky;
    top: 0;
    z-index: 10;
}
.topnav-inner {
    display: flex;
    justify-content: space-between;
    align-items: center;
    height: 60px;
}
.brand { display: flex; align-items: center; gap: 10px; }
.brand-logo {
    width: 34px;
    height: 34px;
    display: block;
}
.brand-name { font-weight: 700; font-size: 18px; letter-spacing: -0.02em; }
.brand-light { color: var(--gray-400); font-weight: 300; }
.topnav-right { display: flex; align-items: center; gap: 16px; font-size: 14px; }
.link-danger { color: var(--red-600); text-decoration: none; font-weight: 500; }
.link-danger:hover { color: var(--red-500); }

.main-content { flex: 1; padding: 36px 16px; }
.page-title { font-size: 26px; font-weight: 700; margin: 0 0 24px; }

/* --- Карточки и формы --- */
.card {
    background: #fff;
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--gray-200);
    padding: 24px;
}

.form { display: flex; flex-direction: column; gap: 18px; }
.form-group { display: flex; flex-direction: column; gap: 6px; }
.form-group label { font-size: 14px; font-weight: 500; color: var(--gray-700); }
.form-group input:not([type="checkbox"]):not([type="radio"]),
.form-group select,
.form-group textarea {
    padding: 9px 12px;
    border: 1px solid var(--gray-300);
    border-radius: 6px;
    font-size: 14px;
    font-family: inherit;
    width: 100%;
}
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--brand-500);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.18);
}

/* --- Кнопки --- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 9px 16px;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    text-decoration: none;
    transition: background-color 0.15s ease;
}
.btn-primary { background: var(--brand-600); color: #fff; }
.btn-primary:hover { background: var(--brand-700); }
.btn-secondary {
    background: #fff;
    color: var(--gray-900);
    border: 1px solid var(--gray-300);
}
.btn-secondary:hover { background: var(--gray-50); }
.btn-danger { background: var(--red-600); color: #fff; }
.btn-danger:hover { background: var(--red-500); }
.btn-block { width: 100%; }
.btn:disabled { opacity: 0.6; cursor: not-allowed; }

/* --- Страницы авторизации --- */
.auth-wrap {
    max-width: 420px;
    margin: 6vh auto 0;
    display: flex;
    flex-direction: column;
    gap: 20px;
}
.auth-header { text-align: center; }
.auth-header h1 { font-size: 24px; font-weight: 800; margin: 0 0 6px; }
.auth-card { box-shadow: var(--shadow-lg); }
.code-input {
    text-align: center;
    font-size: 22px;
    letter-spacing: 8px;
    font-variant-numeric: tabular-nums;
}

/* --- Сообщения об ошибках --- */
.alert {
    padding: 12px 14px;
    border-radius: 6px;
    font-size: 14px;
    margin-bottom: 18px;
}
.alert-error {
    background: var(--red-50);
    border-left: 4px solid var(--red-500);
    color: var(--red-700);
}
.alert-info {
    background: #eff6ff;
    border-left: 4px solid var(--brand-500);
    color: var(--brand-700);
}

/* --- Вкладки --- */
.tabs {
    display: flex;
    gap: 24px;
    border-bottom: 1px solid var(--gray-200);
    margin-bottom: 24px;
    flex-wrap: wrap;
}
.tabs a {
    padding: 12px 4px;
    font-size: 14px;
    font-weight: 500;
    color: var(--gray-500);
    text-decoration: none;
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
}
.tabs a:hover { color: var(--gray-700); border-bottom-color: var(--gray-300); }
.tabs a.active { color: var(--brand-600); border-bottom-color: var(--brand-500); }

/* --- Таблицы --- */
.table-wrap {
    background: #fff;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
}
table.data {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}
table.data th {
    text-align: left;
    padding: 10px 14px;
    background: var(--gray-50);
    color: var(--gray-500);
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    border-bottom: 1px solid var(--gray-200);
}
table.data td {
    padding: 10px 14px;
    border-bottom: 1px solid var(--gray-100);
    vertical-align: middle;
}
table.data tr:last-child td { border-bottom: none; }

/* --- Бейджи состояния --- */
.badge {
    display: inline-block;
    padding: 2px 10px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 600;
}
.badge-green { background: #dcfce7; color: var(--green-600); }
.badge-red { background: var(--red-50); color: var(--red-600); }
.badge-gray { background: var(--gray-100); color: var(--gray-500); }
.badge-yellow { background: #fef9c3; color: #a16207; }

/* --- Утилиты отступов и текста --- */
.mb-24 { margin-bottom: 24px; }
.mt-12 { margin-top: 12px; }
.text-sm { font-size: 13px; }
.nowrap { white-space: nowrap; }

.card-title { margin: 0 0 12px; font-size: 17px; font-weight: 600; }

/* Горизонтальные ряды форм */
.form-row {
    display: flex;
    gap: 14px;
    align-items: flex-end;
    flex-wrap: wrap;
}
.form-row .form-group { min-width: 180px; }
.form-group.grow { flex: 1; }
.btn-sm { padding: 5px 10px; font-size: 13px; font-weight: 500; }
.actions-cell { white-space: nowrap; }
.actions-cell .btn { margin: 2px 2px; }

/* Статистические карточки */
.stats-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 14px;
}
.stat-card { text-align: center; padding: 18px; }
.stat-value { font-size: 30px; font-weight: 800; color: var(--brand-600); }
.stat-label { font-size: 13px; color: var(--gray-500); margin-top: 4px; }

/* Список чекбоксов пользователей */
.checkbox-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 10px 12px;
    border: 1px solid var(--gray-300);
    border-radius: 6px;
    max-height: 220px;
    overflow-y: auto;
}
.checkbox-item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    cursor: pointer;
}
.checkbox-item input[type="checkbox"] {
    width: 16px;
    height: 16px;
    margin: 0;
    flex-shrink: 0;
}

/* Сортируемые заголовки таблицы журнала */
.sort-link {
    color: inherit;
    text-decoration: none;
    display: inline-block;
}
.sort-link:hover { color: var(--brand-600); }

/* Одноразовый показ пароля пользователя */
.password-reveal {
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 10px 0;
}
.password-reveal code {
    font-size: 20px;
    font-weight: 700;
    letter-spacing: 1px;
    background: var(--gray-100);
    border: 1px solid var(--gray-300);
    border-radius: 6px;
    padding: 8px 16px;
    user-select: all;
}
.btn-close-card { margin-top: 10px; }

/* Пагинация журнала */
.pagination {
    display: flex;
    align-items: center;
    gap: 14px;
    justify-content: center;
    margin-top: 16px;
}

/* --- Модальное окно --- */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(107, 114, 128, 0.55);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 50;
}
.modal-card {
    background: #fff;
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    padding: 24px;
    max-width: 420px;
    width: calc(100% - 32px);
    text-align: center;
    animation: fadeIn 0.2s ease-in-out;
}
.modal-icon {
    width: 40px;
    height: 40px;
    margin: 0 auto 12px;
    border-radius: 50%;
    background: var(--red-50);
    color: var(--red-600);
    font-weight: 800;
    font-size: 20px;
    line-height: 40px;
}
.modal-title { margin: 0 0 6px; font-size: 16px; }
.modal-message { margin: 0 0 18px; font-size: 14px; color: var(--gray-500); }
.modal-actions { display: flex; gap: 10px; justify-content: center; }

/* --- Toast-уведомления --- */
.toast-container {
    position: fixed;
    bottom: 20px;
    right: 20px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    z-index: 60;
}
.toast {
    background: var(--gray-900);
    color: #fff;
    padding: 12px 16px;
    border-radius: 6px;
    box-shadow: var(--shadow-lg);
    font-size: 14px;
    animation: fadeIn 0.25s ease-in-out;
    transition: opacity 0.3s ease;
}
.toast-error { background: var(--red-600); }

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(4px); }
    to { opacity: 1; transform: translateY(0); }
}
