:root {
    --a-bg: #f4f5f7;
    --a-surface: #ffffff;
    --a-border: #e5e7eb;
    --a-text: #1f2430;
    --a-muted: #6b7280;
    --a-primary: #8b3dff;
    --a-primary-dark: #6d21e0;
    --a-danger: #e5484d;
    --a-danger-bg: #fdecee;
    --a-success: #12924a;
    --a-success-bg: #e7f6ee;
    --a-warn: #b7791f;
    --a-warn-bg: #fdf6e3;
    --a-radius: 8px;
    --a-shadow: 0 1px 2px rgba(16, 24, 40, .05);
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    background: var(--a-bg);
    color: var(--a-text);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    font-size: 13px;
    line-height: 1.4;
}

a { color: var(--a-primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---------- Login ---------- */
.a-login {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
}
.a-login__card {
    width: 100%;
    max-width: 360px;
    background: var(--a-surface);
    border: 1px solid var(--a-border);
    border-radius: 14px;
    box-shadow: var(--a-shadow);
    padding: 28px 24px;
}
.a-login__title {
    margin: 0 0 4px;
    font-size: 20px;
    font-weight: 700;
}
.a-login__sub {
    margin: 0 0 20px;
    color: var(--a-muted);
}

/* ---------- Layout ---------- */
.a-shell { display: flex; min-height: 100vh; }
.a-sidebar {
    width: 200px;
    flex: 0 0 200px;
    background: var(--a-surface);
    border-right: 1px solid var(--a-border);
    padding: 14px 10px;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
}
.a-brand {
    font-weight: 800;
    font-size: 16px;
    letter-spacing: .5px;
    padding: 4px 10px 14px;
}
.a-brand span { color: var(--a-primary); }
.a-nav { display: flex; flex-direction: column; gap: 1px; }
.a-nav a {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 7px 10px;
    border-radius: 7px;
    color: var(--a-text);
    font-weight: 500;
    font-size: 13px;
}
.a-nav a:hover { background: var(--a-bg); text-decoration: none; }
.a-nav a.is-active { background: var(--a-primary); color: #fff; }
.a-nav__badge {
    min-width: 18px;
    height: 18px;
    padding: 0 6px;
    border-radius: 20px;
    background: var(--a-danger);
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.a-nav a.is-active .a-nav__badge { background: rgba(255,255,255,.28); }
.a-nav__group {
    text-transform: uppercase;
    font-size: 10px;
    letter-spacing: .6px;
    color: var(--a-muted);
    padding: 12px 10px 4px;
    font-weight: 700;
}

.a-main { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; }
.a-topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 20px;
    background: var(--a-surface);
    border-bottom: 1px solid var(--a-border);
    position: sticky;
    top: 0;
    z-index: 5;
}
.a-topbar__title { font-size: 15px; font-weight: 700; margin: 0; }
.a-topbar__user { display: flex; align-items: center; gap: 12px; color: var(--a-muted); }
.a-content { padding: 20px; flex: 1; max-width: 1200px; width: 100%; }

/* ---------- Cards / grid ---------- */
.a-cards {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 14px;
    margin-bottom: 24px;
}
.a-card {
    background: var(--a-surface);
    border: 1px solid var(--a-border);
    border-radius: var(--a-radius);
    box-shadow: var(--a-shadow);
    padding: 16px 18px;
}
.a-card__label { color: var(--a-muted); font-size: 12px; text-transform: uppercase; letter-spacing: .4px; }
.a-card__value { font-size: 26px; font-weight: 700; margin-top: 6px; }

.a-panel {
    background: var(--a-surface);
    border: 1px solid var(--a-border);
    border-radius: var(--a-radius);
    box-shadow: var(--a-shadow);
    margin-bottom: 20px;
}
.a-panel__head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 11px 16px;
    border-bottom: 1px solid var(--a-border);
}
.a-panel__title { font-weight: 700; font-size: 14px; margin: 0; }
.a-panel__body { padding: 16px; }

/* ---------- Table ---------- */
.a-table { width: 100%; border-collapse: collapse; }
.a-table th, .a-table td {
    text-align: left;
    padding: 9px 14px;
    border-bottom: 1px solid var(--a-border);
    vertical-align: middle;
}
.a-table th { color: var(--a-muted); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: .3px; }
.a-table tbody tr:hover, .a-table tr:hover { background: #fafafa; }
.a-table__empty { text-align: center; color: var(--a-muted); padding: 32px; }

/* ---------- Badges ---------- */
.a-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 9px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    background: var(--a-bg);
    color: var(--a-text);
}
.a-badge--success { background: var(--a-success-bg); color: var(--a-success); }
.a-badge--danger { background: var(--a-danger-bg); color: var(--a-danger); }
.a-badge--warn { background: var(--a-warn-bg); color: var(--a-warn); }
.a-badge--muted { background: var(--a-bg); color: var(--a-muted); }

/* ---------- Forms ---------- */
.a-field { margin-bottom: 14px; }
.a-field label { display: block; margin-bottom: 5px; font-weight: 600; font-size: 13px; }
.a-input, .a-select, .a-textarea {
    width: 100%;
    padding: 8px 10px;
    border: 1px solid var(--a-border);
    border-radius: 7px;
    background: #fff;
    font: inherit;
    font-size: 13px;
    color: var(--a-text);
}
.a-input:focus, .a-select:focus, .a-textarea:focus {
    outline: none;
    border-color: var(--a-primary);
    box-shadow: 0 0 0 3px rgba(139, 61, 255, .12);
}
.a-textarea { min-height: 90px; resize: vertical; }
.a-error { color: var(--a-danger); font-size: 12px; margin-top: 4px; }
.a-check { display: inline-flex; align-items: center; gap: 7px; font-weight: 500; }
.a-check--inline { margin-right: 8px; gap: 0; vertical-align: middle; }
/* Звёзды оценки отзыва (модерация). */
.a-stars { display: inline-flex; gap: 2px; font-size: 15px; letter-spacing: 1px; color: var(--a-border); }
.a-stars .is-on { color: #f5b942; }
.a-hint { color: var(--a-muted); font-size: 12px; margin-top: 4px; }

/* ---------- Buttons ---------- */
.a-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 7px 13px;
    border-radius: 7px;
    border: 1px solid transparent;
    background: var(--a-primary);
    color: #fff;
    font: inherit;
    font-weight: 600;
    font-size: 13px;
    cursor: pointer;
    transition: background .12s, border-color .12s;
}
.a-btn:hover { background: var(--a-primary-dark); text-decoration: none; }
.a-btn--sm { padding: 4px 9px; font-size: 12px; }
.a-btn--ghost { background: #fff; border-color: var(--a-border); color: var(--a-text); }
.a-btn--ghost:hover { background: var(--a-bg); }
.a-btn--danger { background: var(--a-danger); }
.a-btn--danger:hover { background: #c93b3f; }
.a-btn--success { background: var(--a-success); }
.a-btn--success:hover { background: #0f7d3f; }

.a-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* ---------- Icon action buttons (таблицы: действия иконками) ---------- */
.a-iconbtn {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    padding: 0;
    border: 1px solid var(--a-border);
    border-radius: 7px;
    background: #fff;
    color: var(--a-muted);
    cursor: pointer;
    transition: background .12s, border-color .12s, color .12s;
}
.a-iconbtn:hover { background: var(--a-bg); color: var(--a-text); text-decoration: none; }
.a-iconbtn svg { width: 16px; height: 16px; display: block; }
.a-iconbtn--primary:hover { border-color: var(--a-primary); color: var(--a-primary); }
.a-iconbtn--danger:hover { border-color: var(--a-danger); color: var(--a-danger); background: var(--a-danger-bg); }
.a-iconbtn--success:hover { border-color: var(--a-success); color: var(--a-success); background: var(--a-success-bg); }
/* Тултип через data-tip (поясняет действие вместо текста на кнопке) */
.a-iconbtn[data-tip]::after {
    content: attr(data-tip);
    position: absolute;
    bottom: calc(100% + 6px);
    left: 50%;
    transform: translateX(-50%);
    background: var(--a-text);
    color: #fff;
    font-size: 11px;
    font-weight: 500;
    line-height: 1;
    padding: 5px 8px;
    border-radius: 6px;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity .12s;
    z-index: 30;
}
.a-iconbtn[data-tip]:hover::after { opacity: 1; }

/* ---------- Flash / alerts ---------- */
.a-alert {
    padding: 11px 16px;
    border-radius: 8px;
    margin-bottom: 18px;
    font-weight: 500;
}
.a-alert--success { background: var(--a-success-bg); color: var(--a-success); }
.a-alert--error { background: var(--a-danger-bg); color: var(--a-danger); }

/* ---------- Filters / toolbar ---------- */
.a-toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 16px; }
.a-toolbar .a-input, .a-toolbar .a-select { width: auto; min-width: 160px; }
.a-tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 16px; }
.a-tabs a {
    padding: 6px 13px;
    border-radius: 20px;
    background: var(--a-surface);
    border: 1px solid var(--a-border);
    color: var(--a-text);
    font-weight: 500;
    font-size: 13px;
}
.a-tabs a:hover { text-decoration: none; background: var(--a-bg); }
.a-tabs a.is-active { background: var(--a-primary); color: #fff; border-color: var(--a-primary); }

/* ---------- Pagination ---------- */
.a-pagination { margin-top: 18px; }
.a-pagination nav { display: flex; gap: 4px; flex-wrap: wrap; }
.a-pagination a, .a-pagination span {
    padding: 6px 11px;
    border-radius: 7px;
    border: 1px solid var(--a-border);
    background: #fff;
    color: var(--a-text);
    font-size: 13px;
}
.a-pagination a:hover { text-decoration: none; background: var(--a-bg); }

/* ---------- Misc ---------- */
.a-photos { display: flex; gap: 12px; flex-wrap: wrap; }
.a-photos img {
    width: 200px;
    max-width: 100%;
    border-radius: 10px;
    border: 1px solid var(--a-border);
    object-fit: cover;
}
/* Фото, добавленные в текущей правке (модерация) — подсвечены + бейдж «новое». */
.a-photo { position: relative; display: inline-flex; }
.a-photo--new img { border-color: var(--a-success); box-shadow: 0 0 0 3px var(--a-success-bg); }
.a-photo__tag { position: absolute; top: 8px; left: 8px; box-shadow: 0 1px 2px rgba(16,24,40,.15); }
.a-photos__note { margin: 12px 0 0; font-size: 12px; }
.a-kv { display: grid; grid-template-columns: 180px 1fr; gap: 8px 16px; }
.a-kv dt { color: var(--a-muted); }
.a-kv dd { margin: 0; }
.a-inline-form { display: inline; }
.a-muted { color: var(--a-muted); }
.a-mt { margin-top: 18px; }
.a-row { display: flex; gap: 14px; flex-wrap: wrap; }
.a-row > * { flex: 1 1 200px; }
.a-diff {
    background: var(--a-bg);
    border-radius: 8px;
    padding: 12px 14px;
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 12px;
    white-space: pre-wrap;
    word-break: break-word;
    overflow-x: auto;
}

@media (max-width: 720px) {
    .a-sidebar { position: fixed; z-index: 20; transform: translateX(-100%); transition: transform .2s; }
    .a-shell.is-open .a-sidebar { transform: translateX(0); }
    .a-content { padding: 16px; }
}

/* ---------- Dashboard metrics ---------- */
.a-metrics { margin-bottom: 18px; }
.a-metrics__head { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.a-metrics__title { margin: 0; font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .5px; color: var(--a-muted); }
.a-metrics__dot { width: 8px; height: 8px; border-radius: 50%; background: var(--a-primary); }
.a-metrics__dot--violet { background: #8b3dff; }
.a-metrics__dot--blue { background: #2f80ed; }
.a-metrics__dot--amber { background: #f2994a; }
.a-metrics__dot--green { background: #12924a; }
.a-metrics__grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 10px;
}
.a-metric {
    background: var(--a-surface);
    border: 1px solid var(--a-border);
    border-radius: var(--a-radius);
    box-shadow: var(--a-shadow);
    padding: 13px 15px;
    display: flex;
    flex-direction: column;
    gap: 3px;
    min-height: 70px;
    justify-content: center;
    position: relative;
    overflow: hidden;
}
.a-metric::before {
    content: "";
    position: absolute;
    left: 0; top: 0; bottom: 0;
    width: 3px;
    background: var(--a-border);
}
.a-metric--success::before { background: var(--a-success); }
.a-metric--danger::before { background: var(--a-danger); }
.a-metric--warn::before { background: var(--a-warn); }
/* Цифра выше подписи — подпись в одну строку (не переносится, цифра не «скачет»). */
.a-metric__value { font-size: 24px; font-weight: 800; line-height: 1.1; }
.a-metric__label {
    color: var(--a-muted);
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: .4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ---------- Diff table (модерация: было/станет) ---------- */
.a-diff-table td { vertical-align: top; }
.a-diff-table .is-changed { background: #fffbeb; }
.a-diff-table .is-changed:hover { background: #fff6d8; }
.a-diff-old { color: var(--a-muted); text-decoration: line-through; text-decoration-color: rgba(0,0,0,.25); }
.a-diff-new { font-weight: 500; }
.a-diff-tag { margin-left: 8px; vertical-align: middle; }

/* ---------- Category thumbnails ---------- */
.a-cat-thumb {
    width: 40px;
    height: 40px;
    border-radius: 7px;
    border: 1px solid var(--a-border);
    object-fit: cover;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--a-bg);
    flex: 0 0 auto;
}
.a-cat-thumb--sm { width: 32px; height: 32px; }
.a-cat-thumb--wide { width: 96px; height: 48px; }
.a-cat-thumb--empty { color: var(--a-muted); font-size: 16px; }
.a-cat-name { display: flex; align-items: center; gap: 4px; }
.a-cat-imgrow { display: flex; align-items: center; gap: 10px; margin-top: 6px; flex-wrap: wrap; }
.a-input--file { padding: 5px; font-size: 12px; max-width: 220px; }
.a-cat-remove { font-size: 12px; color: var(--a-muted); font-weight: 500; }

/* ---------- Modal (кастомное подтверждение / отклонение) ---------- */
.a-modal {
    position: fixed;
    inset: 0;
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}
.a-modal[hidden] { display: none; }
.a-modal__backdrop {
    position: absolute;
    inset: 0;
    background: rgba(16, 24, 40, .45);
}
.a-modal__card {
    position: relative;
    width: 100%;
    max-width: 440px;
    background: var(--a-surface);
    border-radius: 14px;
    box-shadow: 0 20px 40px rgba(16, 24, 40, .2);
    padding: 24px;
}
.a-modal__title { margin: 0 0 6px; font-size: 17px; font-weight: 700; }
.a-modal__text { margin: 0 0 16px; color: var(--a-muted); }
.a-modal__actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 8px; }

/* ---------- Дерево категорий (раскрывающиеся корни → дети) ---------- */
.a-tree { display: flex; flex-direction: column; }
.a-tree__node { border-bottom: 1px solid var(--a-border); }
.a-tree__node:last-child { border-bottom: none; }
.a-tree__row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 16px;
}
.a-tree__row--child {
    padding-left: 40px;
    background: #fbfbfc;
}
.a-tree__toggle {
    width: 22px;
    height: 22px;
    flex: 0 0 auto;
    border: none;
    background: transparent;
    cursor: pointer;
    color: var(--a-muted);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    border-radius: 6px;
}
.a-tree__toggle:hover { background: var(--a-bg); }
.a-tree__toggle.is-empty { cursor: default; }
.a-tree__caret { display: inline-block; transition: transform .15s; font-size: 11px; }
.a-tree__node.is-open .a-tree__caret { transform: rotate(90deg); }
.a-tree__branch { color: var(--a-muted); width: 14px; flex: 0 0 auto; }
.a-tree__main { flex: 1 1 auto; min-width: 0; }
.a-tree__name { font-weight: 600; display: flex; align-items: center; gap: 8px; }
.a-tree__meta { color: var(--a-muted); font-size: 12px; margin-top: 2px; }
.a-tree__meta span { margin-right: 4px; }
.a-tree__actions { display: flex; gap: 6px; flex-wrap: wrap; flex: 0 0 auto; }
.a-tree__children { border-top: 1px solid var(--a-border); }
.a-tree__empty { text-align: center; color: var(--a-muted); padding: 32px; }

/* Редактор таблицы размеров категории (страница «Опции категории»). */
.a-sizetable { border-top: 1px dashed var(--a-border); padding-top: 16px; margin-top: 20px; }
.a-sizetable__wrap { overflow-x: auto; margin-top: 8px; }
.a-sizetable__table { min-width: 360px; }
.a-sizetable__corner { white-space: nowrap; color: var(--a-muted); font-weight: 600; font-size: 12px; }
.a-sizetable__colh { min-width: 96px; }
.a-sizetable__colh .a-input { margin-bottom: 4px; }
.a-sizetable__delcol { margin: 0 auto; display: flex; }
.a-input--center { text-align: center; }

.a-drag { display: inline-flex; align-items: center; flex: 0 0 auto; color: var(--a-muted); cursor: grab; padding: 2px; }
.a-drag:hover { color: var(--a-text, #111); }
.a-drag svg { width: 16px; height: 16px; }
.is-dragging { opacity: .4; }
