/* ============================================================
   Афина — единый стиль
   ============================================================ */
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
    font-family: -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    background: #f4f6fb;
    color: #1f2430;
    font-size: 14px;
    line-height: 1.5;
}
a { color: #2454ff; text-decoration: none; }
a:hover { text-decoration: underline; }

/* ================== Логотип "Афина" ================== */
.brand {
    display: inline-flex; align-items: center; gap: 10px;
    font-weight: 800;
    font-size: 20px;
    letter-spacing: 0.5px;
    background: linear-gradient(135deg, #2454ff 0%, #7a3fff 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    text-decoration: none;
    user-select: none;
}
.brand .brand-mark {
    width: 32px; height: 32px;
    border-radius: 10px;
    background: linear-gradient(135deg, #2454ff 0%, #7a3fff 100%);
    display: inline-flex; align-items: center; justify-content: center;
    color: #fff;
    font-size: 18px;
    font-weight: 900;
    -webkit-text-fill-color: #fff;
    box-shadow: 0 4px 12px rgba(36,84,255,.25);
    flex-shrink: 0;
}
.brand .brand-text {
    -webkit-text-fill-color: transparent;
    background: linear-gradient(135deg, #2454ff 0%, #7a3fff 100%);
    -webkit-background-clip: text;
    background-clip: text;
}
.admin-header .brand,
.admin-header .brand .brand-text {
    background: linear-gradient(135deg, #7fa9ff 0%, #c7a4ff 100%);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}
.admin-header .brand .brand-mark {
    background: linear-gradient(135deg, #7fa9ff 0%, #c7a4ff 100%);
    -webkit-text-fill-color: #1f2430;
    color: #1f2430;
}

/* ================== Логотип-картинка ================== */
.brand-logo {
    height: 40px;
    width: auto;
    display: block;
}
.admin-header .brand-logo {
    height: 38px;
    filter: brightness(0) invert(1) brightness(0.9);
}
.auth-logo-img {
    height: 72px;
    width: auto;
    display: block;
    margin: 0 auto;
}

/* ================== Шапки ================== */
header.app-header,
header.admin-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 14px 28px;
    background: #fff;
    border-bottom: 1px solid #e3e7ee;
    position: sticky; top: 0; z-index: 100;
}
header.admin-header {
    background: #1f2430;
    color: #fff;
    border-bottom: 1px solid #141820;
}
.header-user {
    display: flex; gap: 12px; align-items: center;
    color: #6a7285; font-size: 14px;
}
.admin-header .header-user { color: #cfd6e4; }

/* Навигация админки */
.admin-nav { display: flex; gap: 8px; }
.admin-nav a {
    color: #cfd6e4; font-size: 14px; padding: 6px 14px;
    border-radius: 8px; transition: background .15s;
    text-decoration: none;
}
.admin-nav a:hover { background: rgba(255,255,255,.06); text-decoration: none; }
.admin-nav a.active { background: rgba(127,169,255,.20); color: #fff; }

/* ================== Основной контейнер ================== */
main {
    max-width: 1200px;
    margin: 24px auto;
    padding: 0 20px 60px;
}
h1 { font-size: 24px; margin: 0 0 20px; }
h2 { font-size: 18px; margin: 28px 0 14px; }

/* ================== Кнопки — единый стиль ================== */
button, .btn,
.btn-ghost, .btn-danger, .btn-sig {
    display: inline-flex; align-items: center; justify-content: center;
    gap: 6px;
    padding: 10px 18px;
    border: 1px solid transparent;
    border-radius: 8px;
    font-size: 14px; font-weight: 500;
    cursor: pointer;
    transition: background .15s, border-color .15s, box-shadow .15s, transform .1s;
    text-decoration: none;
    line-height: 1.2;
    white-space: nowrap;
}
button:active, .btn:active, .btn-ghost:active, .btn-danger:active { transform: translateY(1px); }

/* Primary — синяя */
button, .btn {
    background: #2454ff; color: #fff;
    border-color: #2454ff;
}
button:hover, .btn:hover {
    background: #1a3fd6; border-color: #1a3fd6;
    text-decoration: none;
}

/* Ghost — светлая с рамкой */
.btn-ghost, .btn-sig {
    background: #fff; color: #2454ff;
    border-color: #cfd6e4;
}
.btn-ghost:hover, .btn-sig:hover {
    background: #f0f4ff; border-color: #2454ff;
    text-decoration: none;
}

/* Danger — красная */
.btn-danger {
    background: #d33; color: #fff; border-color: #d33;
}
.btn-danger:hover { background: #b02020; border-color: #b02020; }

/* Маленькие кнопки в карточках */
.btn-sm {
    padding: 6px 12px;
    font-size: 13px;
    border-radius: 6px;
}

/* Ссылка-кнопка */
button.link, .btn-link {
    background: none; color: #2454ff; padding: 0;
    border: none; cursor: pointer; font-size: 14px;
}
button.link:hover { background: none; text-decoration: underline; }

/* ================== Статистика ================== */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 16px;
    margin: 20px 0 32px;
}
.stat-card {
    background: #fff;
    border: 1px solid #e3e7ee;
    border-radius: 14px;
    padding: 22px 24px;
}
.stat-value {
    font-size: 34px; font-weight: 700; color: #2454ff;
    line-height: 1;
}
.stat-label { font-size: 14px; color: #1f2430; margin-top: 8px; }
.stat-sub { font-size: 13px; color: #6a7285; margin-top: 6px; }
.stat-sub b.ok { color: #1e7a3d; }
.stat-sub b.warn { color: #a86a00; }

/* ================== Таблица ================== */
table.docs {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    background: #fff;
    border: 1px solid #e3e7ee;
    border-radius: 12px;
    overflow: hidden;
}
table.docs th, table.docs td {
    padding: 12px 16px;
    min-width: max-content;
    text-align: left;
    border-bottom: 1px solid #eef1f6;
    vertical-align: middle;
    font-size: 14px;
}
table.docs th {
    background: #f8faff;
    font-weight: 600; color: #5a6478;
    font-size: 13px; text-transform: uppercase; letter-spacing: .3px;
}
table.docs tr:last-child td { border-bottom: none; }
table.docs tr:hover td { background: #fafbff; }

.actions {
    display: flex;
    flex-wrap: nowrap; /* Запрет переноса */
    gap: 2px;
    align-items: center;
    justify-content: flex-end;
    white-space: nowrap;
    min-width: 210px; /* Гарантированное место под 7-8 иконок */
}
.actions form { display: inline-flex; margin: 0; padding: 0; }
.actions a, .actions button, .actions label {
    display: inline-flex; align-items: center; justify-content: center;
    width: 28px; height: 28px; padding: 0; margin: 0;
    background: none; color: #2454ff;
    border: none; border-radius: 6px; cursor: pointer;
    font-size: 16px;
    transition: background .15s;
}
.actions a:hover, .actions button:hover {
    background: #e6efff; text-decoration: none;
}
.actions .danger { color: #d33; }
.actions .danger:hover { background: #fdeaea; }

/* ================== Бейджи ================== */
.badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 999px;
    font-size: 12px; font-weight: 500;
    background: #eef1f6; color: #5a6478;
}
.badge.ok { background: #e6f7ec; color: #1e7a3d; }
.badge.warn { background: #fff6e0; color: #a86a00; }
.badge.admin { background: #e6efff; color: #2454ff; }
.badge.err { background: #fdeaea; color: #a82323; }

/* ================== Фильтры ================== */
.filters-form {
    display: flex; gap: 10px; flex-wrap: wrap;
    align-items: center; margin: 16px 0 20px;
}
.filters-form input[type=text],
.filters-form input[type=email],
.filters-form input[type=password],
.filters-form select {
    padding: 10px 12px;
    border: 1px solid #cfd6e4;
    border-radius: 8px;
    background: #fff;
    font-size: 14px;
    outline: none;
    transition: border-color .15s, box-shadow .15s;
}
.filters-form input[type=text] { flex: 1 1 300px; }
.filters-form input:focus, .filters-form select:focus {
    border-color: #2454ff;
    box-shadow: 0 0 0 3px rgba(36,84,255,.12);
}

/* ================== Карточки клиентов (сетка) ================== */
.users-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 16px;
}
.user-card {
    display: block;
    background: #fff;
    border: 1px solid #e3e7ee;
    border-radius: 14px;
    padding: 20px;
    text-decoration: none;
    color: inherit;
    transition: transform .15s, box-shadow .15s, border-color .15s;
    position: relative;
}
.user-card:hover {
    transform: translateY(-2px);
    border-color: #7fa9ff;
    box-shadow: 0 10px 24px rgba(30,60,150,.10);
    text-decoration: none;
}
.user-card-head {
    display: flex; align-items: center; gap: 14px;
    padding-bottom: 14px;
    margin-bottom: 12px;
    border-bottom: 1px solid #eef1f6;
}
.user-avatar {
    width: 52px; height: 52px; flex-shrink: 0;
    border-radius: 50%;
    background: linear-gradient(135deg, #2454ff, #7a3fff);
    color: #fff;
    display: flex; align-items: center; justify-content: center;
    font-size: 22px; font-weight: 700;
    text-transform: uppercase;
    box-shadow: 0 4px 12px rgba(36,84,255,.18);
}
.user-avatar.big { width: 88px; height: 88px; font-size: 36px; }
.user-avatar.gray {
    background: linear-gradient(135deg, #8a93a6, #c2c9d6);
    box-shadow: 0 4px 12px rgba(138,147,166,.25);
}

/* ФИО в карточке списка — выразительное */
.user-card-name {
    font-size: 16px; font-weight: 700; color: #1f2430;
    letter-spacing: -0.2px;
    line-height: 1.25;
    overflow: hidden; text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}
.user-card-email {
    font-size: 13px; color: #6a7285;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
    margin-top: 2px;
}
.user-card-name-block { min-width: 0; flex: 1; }

.user-card-row {
    display: flex; justify-content: space-between; align-items: center;
    gap: 8px; padding: 4px 0; font-size: 13px;
}
.user-card-row .muted { min-width: 100px; }

.user-card-actions {
    display: flex; gap: 8px; margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid #eef1f6;
    align-items: center; flex-wrap: wrap;
}
.user-card-actions form { margin: 0; }

/* ================== Карточка одного клиента ================== */
.client-card {
    background: #fff;
    border: 1px solid #e3e7ee;
    border-radius: 16px;
    padding: 28px 32px;
    margin-bottom: 28px;
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 28px;
    align-items: start;
}

/* ФИО крупно и красиво */
.client-name {
    margin: 0 0 18px;
    font-size: 30px;
    font-weight: 800;
    letter-spacing: -0.6px;
    line-height: 1.15;
    color: #1f2430;
    background: linear-gradient(135deg, #1f2430 0%, #3a4a7a 100%);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}
.client-name-sub {
    font-size: 14px; color: #6a7285;
    margin: -12px 0 18px;
    letter-spacing: 0.2px;
}

.client-meta {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 8px 24px;
    margin-bottom: 18px;
}
.client-meta > div { font-size: 14px; }
.client-meta .muted { margin-right: 6px; }

.client-stats {
    display: flex; gap: 32px; flex-wrap: wrap;
    padding: 16px 0;
    margin: 8px 0 18px;
    border-top: 1px solid #eef1f6;
    border-bottom: 1px solid #eef1f6;
}
.stat-mini-value {
    font-size: 26px; font-weight: 700; color: #2454ff; line-height: 1;
}
.stat-mini-value.ok { color: #1e7a3d; }
.stat-mini-value.warn { color: #a86a00; }
.stat-mini-label { font-size: 12px; color: #6a7285; margin-top: 4px; }

.client-actions {
    display: flex; gap: 10px; flex-wrap: wrap;
    margin-top: 12px;
}

/* ================== Уведомления ================== */
.alert {
    padding: 12px 16px;
    border-radius: 10px;
    margin-bottom: 16px;
    font-size: 14px;
    border: 1px solid transparent;
}
.alert.ok {
    background: #e6f7ec; color: #166534;
    border-color: #c2e7cd;
}
.alert.err {
    background: #fdeaea; color: #a82323;
    border-color: #f5c7c7;
}
.alert.info {
    background: #e6efff; color: #1e3d7a;
    border-color: #c7dbff;
}

/* ================== Формы ================== */
.form-card {
    background: #fff;
    border: 1px solid #e3e7ee;
    border-radius: 14px;
    padding: 24px 28px;
    max-width: 640px;
}
.form-field { margin-bottom: 16px; }
.form-field label {
    display: block;
    margin-bottom: 6px;
    font-size: 13px; font-weight: 500; color: #5a6478;
}
.form-field input,
.form-field select {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #cfd6e4;
    border-radius: 8px;
    font-size: 14px;
    outline: none;
    transition: border-color .15s, box-shadow .15s;
}
.form-field input:focus,
.form-field select:focus {
    border-color: #2454ff;
    box-shadow: 0 0 0 3px rgba(36,84,255,.12);
}
.form-field .hint {
    font-size: 12px; color: #6a7285; margin-top: 4px;
}
.checkbox-field {
    display: flex; align-items: center; gap: 8px;
    margin: 12px 0 20px; font-size: 14px;
}
.checkbox-field input { width: auto; }
.form-actions {
    display: flex; gap: 10px; margin-top: 20px;
}

/* ================== Upload-форма ================== */
.upload-form {
    display: flex; gap: 10px;
    margin: 20px 0;
    background: #fff;
    padding: 16px 20px;
    border: 1px solid #e3e7ee;
    border-radius: 12px;
    align-items: center;
}
.upload-form input[type=file] {
    flex: 1; font-size: 14px;
}

/* ================== Список документов (пользователь) ================== */
.docs-list { display: flex; flex-direction: column; gap: 14px; }
.doc-card {
    background: #fff;
    border: 1px solid #e3e7ee;
    border-radius: 14px;
    overflow: hidden;
    transition: box-shadow .15s;
}
.doc-card:hover { box-shadow: 0 4px 16px rgba(30,40,80,.06); }
.doc-row {
    display: grid;
    grid-template-columns: 1fr auto auto;
    align-items: center;
    gap: 16px;
    padding: 16px 22px;
}
.doc-name { 
    font-weight: 600; font-size: 15px; 
    word-break: break-all; 
    max-width: 220px; /* Ограничиваем ширину */
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap; /* Обрезаем в одну строку */
}
.doc-meta {
    display: flex; gap: 8px; align-items: center;
    color: #6a7285; font-size: 13px;
}

/* ================== Блок подписи ================== */
.sig-block {
    display: grid;
    grid-template-columns: auto 1fr auto;
    gap: 16px; align-items: center;
    padding: 14px 22px;
    background: #f0f7ff;
    border-top: 1px solid #d9e6ff;
}
.sig-icon {
    width: 38px; height: 38px;
    border-radius: 50%;
    background: #1e7a3d; color: #fff;
    display: flex; align-items: center; justify-content: center;
    font-size: 20px; font-weight: 700;
}
.sig-info { min-width: 0; }
.sig-title { font-size: 13px; font-weight: 600; color: #1e3d7a; }
.sig-subject {
    font-size: 14px; color: #1f2430; margin: 3px 0;
    word-break: break-word;
}
.sig-meta {
    display: flex; gap: 10px; flex-wrap: wrap;
    font-size: 12px; color: #6a7285;
}
.sig-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* ================== Пустое состояние ================== */
.empty {
    text-align: center;
    padding: 48px 20px;
    color: #6a7285;
    background: #fff;
    border: 1px dashed #cfd6e4;
    border-radius: 14px;
}

/* ================== Toast ================== */
#status-toast {
    position: fixed; bottom: 24px; right: 24px;
    padding: 14px 18px; border-radius: 10px;
    background: #1f2430; color: #fff;
    max-width: 480px;
    display: none; z-index: 9999;
    white-space: pre-wrap;
    box-shadow: 0 12px 32px rgba(0,0,0,.25);
    font-size: 14px;
}
#status-toast.ok { background: #1e7a3d; }
#status-toast.err { background: #a82323; }

/* ================== Утилиты ================== */
.muted { color: #6a7285; }
.small { font-size: 12px; }
.center { text-align: center; }
.right { text-align: right; }
.mb-16 { margin-bottom: 16px; }

/* ================== Auth-страницы ================== */
.auth-page {
    display: flex; align-items: center; justify-content: center;
    min-height: 100vh;
    background: #f4f6fb;
    padding: 20px;
}
.auth-card {
    width: 100%; max-width: 440px;
    background: #fff;
    padding: 40px 36px;
    border-radius: 16px;
    box-shadow: 0 12px 40px rgba(30,40,80,.10);
    text-align: center;
}
.auth-card h2 {
    margin: 0 0 6px;
    font-size: 24px;
    text-align: center;
}
.auth-card p.subtitle {
    color: #6a7285;
    font-size: 14px;
    margin: 0 0 24px;
    text-align: center;
}
.auth-card .auth-logo {
    display: inline-flex; align-items: center; gap: 12px;
    margin-bottom: 24px;
}
.auth-card .auth-logo .brand-mark {
    width: 44px; height: 44px;
    border-radius: 12px;
    background: linear-gradient(135deg, #2454ff 0%, #7a3fff 100%);
    display: inline-flex; align-items: center; justify-content: center;
    color: #fff;
    font-size: 24px;
    font-weight: 900;
    box-shadow: 0 6px 16px rgba(36,84,255,.30);
}
.auth-card .auth-logo .brand-text {
    font-size: 32px;
    font-weight: 900;
    letter-spacing: 0.5px;
    background: linear-gradient(135deg, #2454ff 0%, #7a3fff 100%);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}
.auth-card label {
    display: block;
    margin: 14px 0 6px;
    font-size: 13px; font-weight: 500; color: #5a6478;
    text-align: left;
}
.auth-card input {
    width: 100%;
    padding: 11px 14px;
    border: 1px solid #cfd6e4;
    border-radius: 8px;
    font-size: 14px;
    outline: none;
    transition: border-color .15s, box-shadow .15s;
}
.auth-card input:focus {
    border-color: #2454ff;
    box-shadow: 0 0 0 3px rgba(36,84,255,.12);
}
.auth-card button {
    width: 100%;
    margin-top: 20px;
    padding: 13px;
    font-size: 15px;
}
.auth-card .alt-action {
    text-align: center;
    margin-top: 20px;
    font-size: 14px;
}
.field-error {
    display: block;
    color: #d33; font-size: 12px;
    margin-top: 4px;
}

/* Бейдж администратора — более выразительный */
.badge.admin {
    background: linear-gradient(135deg, #2454ff 0%, #7a3fff 100%);
    color: #fff;
    border: none;
    font-weight: 600;
    box-shadow: 0 2px 8px rgba(36,84,255,.25);
}

/* Бейдж администратора — более выразительный */
.badge.admin {
    background: linear-gradient(135deg, #2454ff 0%, #7a3fff 100%);
    color: #fff;
    border: none;
    font-weight: 600;
    box-shadow: 0 2px 8px rgba(36,84,255,.25);
}

/* ================== Бейдж администратора ================== */
.badge.admin {
    background: linear-gradient(135deg, #2454ff 0%, #7a3fff 100%);
    color: #fff;
    border: none;
    font-weight: 600;
    box-shadow: 0 2px 8px rgba(36,84,255,.25);
}


/* --- Список подписей под документом --- */
.sig-item {
    padding: 8px 12px;
    margin: 6px 0;
    border-left: 3px solid #16a34a;
    background: rgba(22, 163, 74, 0.05);
    border-radius: 4px;
}
.sig-item .sig-subject {
    font-weight: 500;
}
.sig-item .sig-meta {
    color: #6b7280;
    font-size: 0.85em;
    margin-top: 2px;
}
.sig-item .sig-actions {
    margin-top: 6px;
    display: flex;
    gap: 8px;
    align-items: center;
}
.sig-item.small {
    padding: 6px 8px;
    margin: 4px 0;
    font-size: 0.85em;
}

/* ============================================================
   Модернизация: метрики, панели, градиенты
   ============================================================ */

.metrics-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin: 20px 0 30px;
}

.metric-card {
    background: linear-gradient(135deg, #ffffff 0%, #f8fafc 100%);
    border: 1px solid #e2e8f0;
    border-radius: 14px;
    padding: 18px 20px;
    box-shadow: 0 4px 16px rgba(15, 23, 42, 0.05);
    transition: transform 0.15s, box-shadow 0.15s;
    position: relative;
    overflow: hidden;
}

.metric-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(15, 23, 42, 0.08);
}

.metric-icon {
    font-size: 24px;
    opacity: 0.85;
    margin-bottom: 6px;
}

.metric-label {
    font-size: 12px;
    color: #64748b;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-weight: 600;
}

.metric-value {
    font-size: 34px;
    font-weight: 700;
    color: #0f172a;
    line-height: 1.1;
    margin: 4px 0 4px;
}

.metric-value-small {
    font-size: 20px;
    font-weight: 700;
    color: #0f172a;
    line-height: 1.2;
    margin: 6px 0;
}

.metric-unit {
    font-size: 18px;
    font-weight: 500;
    color: #94a3b8;
    margin-left: 2px;
}

.metric-sub {
    font-size: 13px;
    color: #64748b;
}

.metric-bar {
    height: 6px;
    background: #e2e8f0;
    border-radius: 3px;
    margin-top: 12px;
    overflow: hidden;
}

.metric-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, #6366f1 0%, #8b5cf6 100%);
    border-radius: 3px;
    transition: width 0.5s ease;
}

.panel {
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 14px;
    padding: 20px 22px;
    margin-bottom: 20px;
    box-shadow: 0 2px 10px rgba(15, 23, 42, 0.03);
}

.panel h2 {
    font-size: 16px;
    margin: 0 0 14px;
    color: #0f172a;
    font-weight: 600;
}

.panel-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 14px;
}

.two-col {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

@media (max-width: 900px) {
    .two-col { grid-template-columns: 1fr; }
}

.kv-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.kv-table td {
    padding: 6px 8px;
    border-bottom: 1px solid #f1f5f9;
}

.kv-key {
    color: #64748b;
    font-weight: 500;
    width: 40%;
}

.kv-val {
    color: #0f172a;
    font-family: ui-monospace, Menlo, monospace;
    font-size: 12px;
    word-break: break-all;
}

.log-view {
    background: #0f172a;
    color: #e2e8f0;
    font-family: ui-monospace, Menlo, monospace;
    font-size: 12px;
    line-height: 1.5;
    padding: 16px;
    border-radius: 10px;
    max-height: 480px;
    overflow-y: auto;
    white-space: pre-wrap;
    word-break: break-word;
    margin: 0;
}

.badge {
    display: inline-block;
    padding: 2px 8px;
    font-size: 11px;
    font-weight: 600;
    border-radius: 999px;
    background: #f1f5f9;
    color: #475569;
}

.badge.ok  { background: #dcfce7; color: #166534; }
.badge.warn{ background: #fef3c7; color: #92400e; }
.badge.admin { background: #ede9fe; color: #5b21b6; }

.admin-nav a.active {
    font-weight: 600;
    color: #6366f1;
}

/* ============ System tab ============ */
.sys-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}
.sys-actions { display: flex; gap: 10px; }

.modal {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.55);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
}
.modal-card {
    background: #fff;
    border-radius: 14px;
    padding: 26px 28px;
    max-width: 480px;
    width: 90%;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}
.modal-card h2 { margin: 0 0 12px; font-size: 18px; }
.modal-card input[type=text] {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    font-size: 14px;
    font-family: ui-monospace, Menlo, monospace;
    margin-bottom: 16px;
}
.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

.btn-danger {
    background: #dc2626;
    color: #fff;
    border: none;
    padding: 8px 16px;
    border-radius: 8px;
    font-size: 13px;
    cursor: pointer;
}
.btn-danger:hover { background: #b91c1c; }

.btn-sm { font-size: 12px; padding: 5px 10px; }
.btn-sig {
    background: #eef2ff;
    color: #4338ca;
    border: 1px solid #c7d2fe;
    padding: 6px 12px;
    border-radius: 8px;
    text-decoration: none;
    font-size: 12px;
    display: inline-block;
    margin-right: 4px;
}
.btn-sig:hover { background: #e0e7ff; }

/* ============================================================
   Разделы документов — карточки с цветовой маркировкой
   Итерация 1: плитки, цвет, счётчики, пустое состояние
   ============================================================ */

.folder-card {
    background: #fff;
    border: 1px solid #e3e7ee;
    border-radius: 16px;
    overflow: hidden;
    margin-bottom: 20px;
    transition: box-shadow .18s ease, transform .18s ease, border-color .18s ease;
    position: relative;
}

.folder-card:hover {
    border-color: #cfd6e4;
    box-shadow: 0 10px 28px rgba(30,40,80,.08);
    transform: translateY(-1px);
}

/* Цветная полоска слева — по индексу папки */
.folder-card::before {
    content: "";
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 4px;
    border-top-left-radius: 16px;
    border-bottom-left-radius: 16px;
}
.folder-card.folder-color-0::before { background: #2454ff; }
.folder-card.folder-color-1::before { background: #1e7a3d; }
.folder-card.folder-color-2::before { background: #7a3fff; }
.folder-card.folder-color-3::before { background: #a86a00; }
.folder-card.folder-color-4::before { background: #0e7490; }
.folder-card.folder-color-5::before { background: #a82323; }

/* Шапка раздела */
.folder-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    padding: 16px 22px 16px 26px;
    border-bottom: 1px solid #eef1f6;
    background: linear-gradient(180deg, #fbfcff 0%, #f6f9ff 100%);
    flex-wrap: wrap;
}

.folder-card-title-block {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
    flex: 1;
}

.folder-icon {
    width: 38px;
    height: 38px;
    flex-shrink: 0;
    border-radius: 10px;
    background: linear-gradient(135deg, #e6efff 0%, #f0f4ff 100%);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    box-shadow: inset 0 0 0 1px rgba(36,84,255,.08);
}

.folder-card.folder-color-1 .folder-icon { background: linear-gradient(135deg,#e6f7ec,#f0faf3); }
.folder-card.folder-color-2 .folder-icon { background: linear-gradient(135deg,#f0e6ff,#f7f0ff); }
.folder-card.folder-color-3 .folder-icon { background: linear-gradient(135deg,#fff6e0,#fffbf0); }
.folder-card.folder-color-4 .folder-icon { background: linear-gradient(135deg,#e0f5fb,#f0fbff); }
.folder-card.folder-color-5 .folder-icon { background: linear-gradient(135deg,#fdeaea,#fff5f5); }

.folder-name {
    font-size: 16px;
    font-weight: 700;
    color: #1f2430;
    letter-spacing: -0.2px;
    line-height: 1.25;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    min-width: 0;
}

/* Счётчики-бейджи */
.folder-stats {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    margin-top: 4px;
}

.folder-stat {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 9px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 500;
    background: #eef1f6;
    color: #5a6478;
    line-height: 1.6;
}

.folder-stat b { font-weight: 700; }

.folder-stat.stat-total { background: #e6efff; color: #1e3d7a; }
.folder-stat.stat-signed { background: #e6f7ec; color: #166534; }
.folder-stat.stat-unsigned { background: #fff6e0; color: #a86a00; }

/* Действия в шапке */
.folder-actions {
    display: flex;
    gap: 6px;
    align-items: center;
    flex-shrink: 0;
}

.folder-actions .btn-ghost,
.folder-actions .btn-danger {
    padding: 6px 12px;
    font-size: 13px;
    border-radius: 7px;
}

/* Форма загрузки внутри карточки */
.folder-card .upload-form {
    margin: 14px 22px;
}

/* Пустое состояние */
.folder-empty {
    margin: 0 22px 18px;
    padding: 26px 20px;
    border: 1.5px dashed #cfd6e4;
    border-radius: 12px;
    background: #fafbff;
    text-align: center;
    color: #6a7285;
    font-size: 14px;
    transition: border-color .15s, background .15s;
}

.folder-empty:hover {
    border-color: #7fa9ff;
    background: #f4f8ff;
}

.folder-empty-icon {
    font-size: 28px;
    display: block;
    margin-bottom: 6px;
    opacity: 0.85;
}

.folder-empty strong {
    color: #1f2430;
    font-weight: 600;
    display: block;
    margin-bottom: 4px;
}

@media (max-width: 720px) {
    .folder-card-header {
        flex-direction: column;
        align-items: stretch;
    }
    .folder-actions { justify-content: flex-end; }
}
/* Подсветка строк доверенностей */
.poa-row-expired td { background: #fdeaea !important; }
.poa-row-warning td { background: #fff6e0 !important; }
