/*
 * Каркас админки: шапка, вкладки, карточка контента, плитки сводки.
 * Все цвета — токенами из theme.css, прямых значений здесь нет.
 */
*, *::before, *::after {
    box-sizing: border-box;
}

body {
    min-height: 100vh;
    margin: 0;
    display: flex;
    flex-direction: column;
    background: var(--surface);
    color: var(--text);
    font-family: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
    font-size: 15px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

.a-container {
    width: 100%;
    padding: 0 24px;
}

/* ── Шапка ───────────────────────────────────────────────── */

.a-header {
    flex-shrink: 0;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
}

.a-header-inner {
    height: 62px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

.a-header-side {
    display: flex;
    align-items: center;
    gap: 11px;
    min-width: 0;
}

.a-logo {
    height: 26px;
    width: auto;
    display: block;
    color: var(--text);
}

.a-logo-mark {
    color: var(--pine);
}

/*
 * Ярлык «Админка»: цвет считывается мгновенно, но слово снимает
 * сомнения — в том числе у тех, кто не различает оттенки.
 */
.a-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
    padding: 3px 9px;
    font-size: 11.5px;
    font-weight: 600;
    letter-spacing: .03em;
    text-transform: uppercase;
    color: var(--accent-text);
    background: var(--accent-soft);
    border-radius: 6px;
}

.a-divider {
    color: var(--text-faint);
    font-size: 15px;
}

/* ── Аватар и меню ───────────────────────────────────────── */

.a-user {
    position: relative;
}

.a-user > summary {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 5px 10px 5px 5px;
    border-radius: 999px;
    cursor: pointer;
    list-style: none;
    transition: background .15s;
}

.a-user > summary::-webkit-details-marker {
    display: none;
}

.a-user > summary:hover {
    background: var(--hover);
}

.a-user > summary:focus-visible {
    outline: 3px solid var(--accent-soft);
    outline-offset: 1px;
}

.a-avatar {
    display: flex;
    align-items: center;
    justify-content: center;
    flex: none;
    width: 32px;
    height: 32px;
    font-size: 12.5px;
    font-weight: 600;
    color: var(--avatar-text);
    background: var(--avatar-bg);
    border-radius: 50%;
    user-select: none;
}

.a-avatar-lg {
    width: 42px;
    height: 42px;
    font-size: 16px;
}

.a-user-name {
    font-size: 14px;
    font-weight: 500;
    white-space: nowrap;
}

.a-menu {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    z-index: 20;
    min-width: 268px;
    padding: 8px;
    background: var(--surface-raised);
    border: 1px solid var(--border);
    border-radius: 14px;
    box-shadow: var(--shadow-menu);
}

.a-menu-head {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 10px 12px;
}

.a-menu-identity {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.a-menu-name {
    font-size: 14px;
    font-weight: 600;
}

.a-menu-email {
    font-size: 13px;
    color: var(--text-muted);
    overflow: hidden;
    text-overflow: ellipsis;
}

.a-menu-line {
    margin: 0 0 6px;
    border: 0;
    border-top: 1px solid var(--border);
}

.a-menu-item {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    font: inherit;
    font-size: 14px;
    color: var(--text-muted);
    text-align: left;
    background: none;
    border: 0;
    border-radius: 9px;
    padding: 10px;
    cursor: pointer;
    transition: background .15s, color .15s;
}

.a-menu-item:hover {
    background: var(--hover);
    color: var(--text);
}

.a-menu-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 8px 10px;
}

.a-menu-row-label {
    font-size: 14px;
    color: var(--text-muted);
}

/* ── Переключатель темы ──────────────────────────────────── */

.a-theme {
    display: inline-flex;
    gap: 2px;
    padding: 2px;
    background: var(--hover);
    border-radius: 9px;
}

.a-theme-option {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 26px;
    font-size: 13px;
    color: var(--text-muted);
    background: none;
    border: 0;
    border-radius: 7px;
    cursor: pointer;
    transition: color .15s, background .15s;
}

.a-theme-option:hover {
    color: var(--text);
}

.a-theme-option.is-active {
    color: var(--text);
    background: var(--surface);
    box-shadow: var(--shadow-card);
}

/* ── Вкладки ─────────────────────────────────────────────── */

.a-tabs {
    display: flex;
    align-items: center;
    gap: 26px;
    overflow-x: auto;
    scrollbar-width: none;
}

.a-tabs::-webkit-scrollbar {
    display: none;
}

.a-tab {
    flex-shrink: 0;
    font-size: 14.5px;
    color: var(--text-muted);
    text-decoration: none;
    padding: 13px 0 10px;
    border-bottom: 3px solid transparent;
    white-space: nowrap;
    transition: color .15s, border-color .15s;
}

.a-tab:hover {
    color: var(--accent-text);
}

.a-tab.is-active {
    color: var(--accent-text);
    font-weight: 500;
    border-bottom-color: var(--accent-line);
}

/* ── Контент ─────────────────────────────────────────────── */

.a-main {
    display: flex;
    flex: 1 0 auto;
    width: 100%;
    padding: 22px 24px 28px;
}

.a-card {
    flex: 1;
    background: var(--surface-sunken);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 32px;
}

.a-layout {
    max-width: 1100px;
    margin: 0 auto;
}

.a-title {
    font-size: 27px;
    font-weight: 600;
    letter-spacing: -.015em;
    margin: 0 0 6px;
}

.a-subtitle {
    font-size: 15px;
    color: var(--text-muted);
    margin: 0 0 30px;
}

/* ── Плитки сводки ───────────────────────────────────────── */

.a-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
    gap: 16px;
    margin-bottom: 26px;
}

.a-stat {
    display: flex;
    flex-direction: column;
    gap: 8px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 20px 22px;
}

.a-stat-label {
    font-size: 12.5px;
    letter-spacing: .02em;
    text-transform: uppercase;
    color: var(--text-muted);
}

.a-stat-value {
    font-size: 30px;
    font-weight: 600;
    line-height: 1;
    letter-spacing: -.02em;
    font-variant-numeric: tabular-nums;
}

.a-stat-note {
    font-size: 12.5px;
    color: var(--text-faint);
}

/* ── Панель ──────────────────────────────────────────────── */

.a-panel {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 22px 24px;
}

.a-panel-title {
    font-size: 16px;
    font-weight: 600;
    margin: 0 0 4px;
}

.a-panel-note {
    font-size: 13.5px;
    color: var(--text-muted);
    margin: 0 0 18px;
}

.a-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.a-list-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 13px 0;
    border-top: 1px solid var(--border-soft);
    font-size: 14px;
}

.a-list-row:first-child {
    border-top: 0;
}

.a-list-label {
    color: var(--text-muted);
}

.a-list-value {
    margin-left: auto;
    font-variant-numeric: tabular-nums;
}

/* ── Состояния ───────────────────────────────────────────── */

.a-state {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    font-size: 13px;
    color: var(--text-muted);
}

.a-state::before {
    content: "";
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--text-faint);
}

.a-state.is-success::before { background: var(--success); }
.a-state.is-warning::before { background: var(--warning); }
.a-state.is-danger::before { background: var(--danger); }

/* ── Подвал ──────────────────────────────────────────────── */

.a-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
    padding-top: 20px;
    padding-bottom: 24px;
    font-size: 13px;
    color: var(--text-faint);
}

@media (max-width: 700px) {
    .a-container {
        padding: 0 16px;
    }

    .a-main {
        padding: 16px 16px 22px;
    }

    .a-card {
        padding: 22px 18px;
    }

    .a-user-name {
        display: none;
    }

    .a-title {
        font-size: 23px;
    }
}

/* Версия и окружение в подвале. Окружение показывается только вне
   прода: там оно очевидно, а вот «local» на боевом сайте — сигнал
   о неверной настройке. */
.a-footer-meta {
    display: inline-flex;
    align-items: center;
    gap: 10px;
}

.a-version {
    font-variant-numeric: tabular-nums;
}

.a-env {
    padding: 2px 7px;
    font-size: 11.5px;
    font-weight: 600;
    letter-spacing: .03em;
    text-transform: uppercase;
    color: var(--accent-text);
    background: var(--accent-soft);
    border-radius: 5px;
}

/* ── Поля ────────────────────────────────────────────────── */

.a-field {
    margin-bottom: 16px;
}

.a-label {
    display: block;
    font-size: 13px;
    color: var(--text-muted);
    margin-bottom: 6px;
}

.a-input {
    width: 100%;
    font: inherit;
    font-size: 15px;
    color: var(--text);
    background: var(--field-bg);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 11px 13px;
    transition: border-color .15s, box-shadow .15s;
}

.a-input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-soft);
}

.a-input[aria-invalid="true"] {
    border-color: var(--danger);
}

.a-check {
    display: flex;
    align-items: center;
    gap: 9px;
    font-size: 14px;
    color: var(--text-muted);
    margin: 0 0 22px;
    cursor: pointer;
}

.a-check input {
    width: 16px;
    height: 16px;
    accent-color: var(--accent);
    cursor: pointer;
}

/* ── Кнопка ──────────────────────────────────────────────── */

.a-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font: inherit;
    font-size: 15px;
    font-weight: 500;
    color: #fff;
    background: var(--accent);
    border: 0;
    border-radius: 10px;
    padding: 12px 20px;
    cursor: pointer;
    transition: background .15s;
}

.a-btn:hover {
    background: var(--accent-hover);
}

.a-btn:focus-visible {
    outline: 3px solid var(--accent-soft);
    outline-offset: 2px;
}

.a-btn--block {
    width: 100%;
}

/* ── Список администраторов ──────────────────────────────── */

.a-form-row {
    display: flex;
    align-items: flex-end;
    gap: 12px;
    flex-wrap: wrap;
}

.a-form-row .a-field {
    flex: 1 1 200px;
    margin-bottom: 0;
}

.a-avatar-sm {
    width: 28px;
    height: 28px;
    font-size: 11.5px;
}

.a-list-main {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.a-list-title {
    font-weight: 500;
}

.a-list-note {
    margin-left: auto;
    font-size: 13px;
    color: var(--text-faint);
    white-space: nowrap;
}

.a-list-main .a-list-note {
    margin-left: 0;
}

.a-list-action {
    flex: none;
}

.a-link-danger {
    font: inherit;
    font-size: 13.5px;
    color: var(--danger);
    background: none;
    border: 0;
    padding: 0;
    cursor: pointer;
}

.a-link-danger:hover {
    text-decoration: underline;
}

.a-notice {
    font-size: 14px;
    color: var(--accent-text);
    background: var(--accent-soft);
    border-radius: 10px;
    padding: 11px 13px;
    margin-bottom: 18px;
}

.a-hint {
    font-size: 12.5px;
    color: var(--text-faint);
    margin: 6px 0 0;
}

.a-alert {
    font-size: 14px;
    color: var(--danger-text);
    background: var(--danger-soft);
    border-radius: 10px;
    padding: 11px 13px;
    margin-bottom: 18px;
}

/* ── Модальные окна ──────────────────────────────────────── */

/*
 * На <dialog>: фокус, Esc и подложка достаются от браузера.
 * Своего JS — одна строка на открытие.
 */
.a-modal {
    width: min(420px, calc(100vw - 32px));
    padding: 26px 26px 22px;
    color: var(--text);
    background: var(--surface-raised);
    border: 1px solid var(--border);
    border-radius: 16px;
    box-shadow: var(--shadow-menu);
}

.a-modal::backdrop {
    background: rgba(16, 20, 32, .55);
    backdrop-filter: blur(2px);
}

/* Появление: короткое и сдержанное, диалог не должен «прыгать». */
.a-modal[open] {
    animation: a-modal-in .16s ease-out;
}

.a-modal[open]::backdrop {
    animation: a-backdrop-in .16s ease-out;
}

@keyframes a-modal-in {
    from { opacity: 0; transform: translateY(-6px) scale(.98); }
    to { opacity: 1; transform: none; }
}

@keyframes a-backdrop-in {
    from { opacity: 0; }
    to { opacity: 1; }
}

@media (prefers-reduced-motion: reduce) {
    .a-modal[open],
    .a-modal[open]::backdrop {
        animation: none;
    }
}

.a-modal__close-form {
    float: right;
    margin: -8px -8px 0 0;
}

.a-modal__close {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    font-size: 20px;
    line-height: 1;
    color: var(--text-faint);
    background: none;
    border: 0;
    border-radius: 8px;
    cursor: pointer;
    transition: color .15s, background .15s;
}

.a-modal__close:hover {
    color: var(--text);
    background: var(--hover);
}

.a-modal__title {
    font-size: 18px;
    font-weight: 600;
    letter-spacing: -.01em;
    margin: 0 0 8px;
}

.a-modal__text {
    font-size: 14.5px;
    line-height: 1.55;
    color: var(--text-muted);
    margin: 0 0 22px;
}

.a-modal__actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

/* Варианты кнопок, нужные диалогу. */
.a-btn--ghost {
    color: var(--text-muted);
    background: none;
    border: 1px solid var(--border);
}

.a-btn--ghost:hover {
    color: var(--text);
    background: var(--hover);
}

.a-btn--danger {
    background: var(--danger);
}

.a-btn--danger:hover {
    background: color-mix(in srgb, var(--danger) 85%, #000);
}
