/* Компоненты интерфейса по макету. Цвета — только через токены из tokens.css:
   хардкод сломает тёмную тему, которая переопределяет ровно эти переменные. */

/* ── Оболочка ─────────────────────────────────────────────────────────────── */

.admin {
    display: grid;
    grid-template-columns: var(--sidebar-w) 1fr;
    min-height: 100vh;
}

.side {
    background: var(--surface);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    gap: 18px;
    padding: 14px 12px;
    position: sticky;
    top: 0;
    height: 100vh;
}

.brand {
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 4px 6px;
}

.brand-mark {
    width: 28px;
    height: 28px;
    border-radius: var(--r-xs);
    background: var(--ink);
    color: var(--bg);
    display: grid;
    place-items: center;
    font-family: var(--font-mono);
    font-size: 11px;
    font-weight: 700;
    flex: none;
}

.brand-mark-lg {
    width: 30px;
    height: 30px;
    border-radius: 9px;
    font-size: 12px;
}

.brand-name {
    font-size: 13px;
    font-weight: 800;
    letter-spacing: -0.01em;
}

.brand-name-lg {
    font-size: 13.5px;
}

.side-nav {
    display: grid;
    gap: 2px;
    align-content: start;
}

.side-group {
    font-size: 10px;
    font-weight: 700;
    color: var(--ink-3);
    text-transform: uppercase;
    letter-spacing: .14em;
    padding: 12px 8px 7px;
}

.side-group:first-child {
    padding-top: 0;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    text-align: left;
    border: none;
    cursor: pointer;
    border-radius: 9px;
    padding: 9px 12px;
    font-size: 13px;
    font-weight: 700;
    background: transparent;
    color: var(--ink-2);
    text-decoration: none;
}

.nav-item:hover {
    background: var(--surface-2);
    color: var(--ink);
    text-decoration: none;
}

.nav-item.active {
    background: var(--ink);
    color: var(--bg);
}

.side-bottom {
    margin-top: auto;
    border-top: 1px solid var(--border);
    padding-top: 12px;
}

.side-user {
    display: flex;
    align-items: center;
    gap: 9px;
}

.side-user-text {
    display: grid;
    min-width: 0;
    flex: 1;
}

.side-user-name {
    font-size: 12.5px;
    font-weight: 700;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.side-user-role {
    font-size: 11px;
    font-weight: 500;
    color: var(--ink-3);
}

.side-logout-form {
    margin: 0;
}

.avatar {
    width: 30px;
    height: 30px;
    border-radius: 9px;
    display: grid;
    place-items: center;
    font-family: var(--font-mono);
    font-size: 11px;
    font-weight: 700;
    flex: none;
}

/* Категориальные пары для аватаров. Не инвертируются по теме намеренно:
   это метки-идентичности, а не элементы поверхности. */
.avatar-coffee { background: #EAD9C6; color: #6B3E21; }
.avatar-drinks { background: #D5E0F3; color: #2F5DAB; }
.avatar-bakery { background: #F4E2C0; color: #B86D12; }
.avatar-dessert { background: #F0D5E4; color: #A83478; }
.avatar-snacks { background: #D6E8DD; color: #2D7A4F; }
.avatar-weight { background: #E6E0D0; color: #4A4338; }

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

.topbar {
    position: sticky;
    top: 0;
    z-index: 20;
    height: var(--topbar-h);
    padding: 0 28px;
    background: var(--bg);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 16px;
}

.topbar-title {
    font-size: 21px;
    font-weight: 800;
    letter-spacing: -0.02em;
    margin: 0;
}

.topbar-search {
    position: relative;
    flex: 1;
    max-width: 320px;
    margin-left: 10px;
}

.topbar-search svg {
    position: absolute;
    left: 11px;
    top: 9px;
    color: var(--ink-4);
}

.topbar-search input {
    width: 100%;
    border: 1px solid var(--border-strong);
    background: var(--pure);
    color: var(--ink);
    border-radius: var(--r-sm);
    padding: 8px 12px 8px 32px;
    font-size: 12.5px;
    font-weight: 600;
    outline: none;
}

.topbar-search input:focus {
    border-color: var(--ink);
}

.topbar-right {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 10px;
}

.page {
    padding: 30px 36px 40px;
    max-width: var(--page-max);
    width: 100%;
    display: grid;
    gap: 14px;
    align-content: start;
}

.fade-page {
    animation: fadeUp .2s ease both;
}

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

.btn {
    border-radius: var(--r-sm);
    padding: 9px 16px;
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    text-decoration: none;
}

.btn:hover {
    text-decoration: none;
}

.btn-primary {
    border: none;
    background: var(--ink);
    color: var(--bg);
}

.btn-primary:hover {
    opacity: .88;
    color: var(--bg);
}

.btn-secondary {
    border: 1px solid var(--border-strong);
    background: var(--pure);
    color: var(--ink);
}

.btn-secondary:hover {
    background: var(--surface-2);
    color: var(--ink);
}

.btn-block {
    width: 100%;
}

.icon-btn {
    width: 32px;
    height: 32px;
    display: grid;
    place-items: center;
    border: 1px solid var(--border-strong);
    background: var(--pure);
    color: var(--ink-2);
    border-radius: var(--r-sm);
    cursor: pointer;
    flex: none;
}

.icon-btn:hover {
    background: var(--surface-2);
    color: var(--ink);
}

.icon-btn-danger {
    width: 28px;
    height: 28px;
    border: none;
    background: transparent;
    color: var(--ink-4);
}

.icon-btn-danger:hover {
    background: var(--surface-2);
    color: var(--danger);
}

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

.field {
    display: grid;
    margin-bottom: 14px;
}

.field-label {
    font-size: 11.5px;
    font-weight: 700;
    color: var(--ink-3);
    margin-bottom: 5px;
}

/* Пояснение под полем: чем «пусто» отличается от нуля и т. п. */
.field-hint {
    display: block;
    margin-top: 4px;
    font-size: 11.5px;
    font-weight: 500;
    color: var(--ink-3);
}

.input {
    width: 100%;
    border: 1px solid var(--border-strong);
    background: var(--bg);
    border-radius: var(--r-sm);
    padding: 9px 12px;
    font-size: 13px;
    font-weight: 600;
    color: var(--ink);
    outline: none;
}

.input:focus {
    border-color: var(--ink);
}

.input-mono {
    font-family: var(--font-mono);
    letter-spacing: .14em;
}

.input.invalid,
.input.modified.invalid {
    border-color: var(--danger);
}

.checkbox {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12.5px;
    font-weight: 600;
    color: var(--ink-2);
    cursor: pointer;
}

.checkbox input {
    accent-color: var(--positive);
    width: 14px;
    height: 14px;
}

.form-error {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 11.5px;
    font-weight: 600;
    color: var(--danger);
    background: var(--danger-soft);
    border: 1px solid var(--danger);
    border-radius: var(--r-md);
    padding: 9px 12px;
    margin-bottom: 14px;
}

/* ── Карточки и метрики ───────────────────────────────────────────────────── */

.card {
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    background: var(--pure);
    padding: 14px 18px;
    box-shadow: var(--shadow-sm);
}

.cards-4 {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
}

@media (max-width: 1100px) {
    .cards-4 { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 640px) {
    .cards-4 { grid-template-columns: 1fr; }
    .admin { grid-template-columns: 1fr; }
    .side { position: static; height: auto; }
}

.kpi-label {
    font-size: 11px;
    font-weight: 700;
    color: var(--ink-3);
    text-transform: uppercase;
    letter-spacing: .07em;
}

.kpi-value {
    font-family: var(--font-mono);
    font-size: 21px;
    font-weight: 700;
    margin-top: 5px;
}

.kpi-of {
    color: var(--ink-4);
}

.kpi-delta {
    font-size: 11.5px;
    font-weight: 700;
    margin-top: 3px;
}

.kpi-delta.positive { color: var(--positive); }
.kpi-delta.warn { color: var(--warn); }
.kpi-delta.danger { color: var(--danger); }

.bar {
    height: 6px;
    border-radius: var(--r-pill);
    background: var(--surface-2);
    overflow: hidden;
    margin-top: 8px;
}

.bar-sm {
    height: 5px;
    margin-top: 4px;
    margin-bottom: 10px;
}

.bar-fill {
    height: 100%;
    background: var(--ink);
}

.section-head {
    font-size: 11px;
    font-weight: 700;
    color: var(--ink-3);
    text-transform: uppercase;
    letter-spacing: .08em;
    margin-bottom: 12px;
}

.dist-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 13px;
}

.dist-count {
    font-family: var(--font-mono);
    font-weight: 700;
}

.empty-state {
    font-size: 12.5px;
    font-weight: 500;
    color: var(--ink-3);
    padding: 8px 0;
}

.skeleton-card {
    height: 84px;
    background: var(--surface);
    border-style: dashed;
    border-color: var(--border-strong);
}

/* ── Бейджи ───────────────────────────────────────────────────────────────── */

.pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 11px;
    font-weight: 700;
    padding: 3px 10px;
    border-radius: var(--r-pill);
    white-space: nowrap;
}

.pill .dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: currentColor;
}

.pill-positive { background: var(--positive-soft); color: var(--positive); }
.pill-warn { background: var(--warn-soft); color: var(--warn); }
.pill-danger { background: var(--danger-soft); color: var(--danger); }
.pill-neutral { background: var(--surface-2); color: var(--ink-4); }

.info-block {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    background: var(--info-soft);
    border: 1px solid var(--info);
    border-radius: var(--r-md);
    padding: 10px 14px;
    font-size: 12.5px;
    font-weight: 500;
    color: var(--ink-2);
    line-height: 1.5;
}

.info-block svg {
    flex: none;
    margin-top: 1px;
    color: var(--info);
}

/* ── Ошибки ───────────────────────────────────────────────────────────────── */

.err-banner {
    border: 1px solid var(--danger);
    background: var(--danger-soft);
    border-radius: var(--r-lg);
    padding: 16px 18px;
    color: var(--ink);
}

.err-banner-title {
    font-size: 15px;
    font-weight: 800;
    margin-bottom: 4px;
}

.err-banner-text {
    font-size: 12.5px;
    font-weight: 500;
    color: var(--ink-2);
}

.err-banner-reload {
    display: inline-block;
    margin-top: 10px;
    font-weight: 700;
}

.validation-message {
    color: var(--danger);
    font-size: 11.5px;
    font-weight: 600;
}

#blazor-error-ui {
    background: var(--warn-soft);
    color: var(--ink);
    border-top: 1px solid var(--warn);
    bottom: 0;
    display: none;
    left: 0;
    padding: 10px 16px;
    position: fixed;
    width: 100%;
    z-index: 1000;
    font-size: 12.5px;
    font-weight: 600;
}

#blazor-error-ui .dismiss {
    cursor: pointer;
    position: absolute;
    right: 14px;
    top: 8px;
}
