:root {
    /* Тёмная тема, комфортная для долгой работы: глубокий сине-серый фон (не чёрный),
       мягкий не-белый текст, приглушённые акценты — минимум контрастной резкости. */
    --bg: #0f141c;
    --surface: #171e28;
    --surface-2: #1e2732;
    --surface-3: #263140;
    --border: #2a3441;
    --border-strong: #37455680;
    --text: #e3e8f0;
    --text-strong: #f2f5fa;
    --muted: #93a1b5;
    --faint: #6b7891;

    --primary: #4f8ef7;
    --primary-600: #6ea3f9;
    --primary-700: #3b7de3;
    --primary-050: rgba(79, 142, 247, .16);
    --primary-020: rgba(79, 142, 247, .08);

    --danger: #f26b73;
    --danger-700: #ef4a54;
    --danger-050: rgba(242, 107, 115, .15);
    --ok: #4ecb86;
    --ok-050: rgba(78, 203, 134, .15);
    --warn: #e0ab52;
    --warn-050: rgba(224, 171, 82, .15);

    --sidebar-1: #0b0f16;
    --sidebar-2: #10161f;

    --radius: 12px;
    --shadow: 0 1px 2px rgba(0, 0, 0, .35), 0 6px 20px rgba(0, 0, 0, .35);
    --shadow-lg: 0 20px 60px rgba(0, 0, 0, .55);
    --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    background: var(--bg);
    color: var(--text);
    font-family: var(--font);
    font-size: 14px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}

/* Иконки: наследуют цвет текста, не сжимаются во flex-строках */
.ico { flex: 0 0 auto; display: inline-block; vertical-align: middle; }

/* ---------- Shell ---------- */
.app-shell { display: flex; min-height: 100vh; }

.app-sidebar {
    width: 240px;
    flex: 0 0 240px;
    background: linear-gradient(180deg, var(--sidebar-1), var(--sidebar-2));
    color: #aeb9cc;
    padding: 20px 14px;
    position: sticky;
    top: 0;
    height: 100vh;
    border-right: 1px solid #1c2431;
}

.app-sidebar .brand {
    display: flex;
    align-items: center;
    gap: 11px;
    font-size: 20px;
    font-weight: 700;
    color: #fff;
    padding: 6px 10px 6px;
    letter-spacing: .3px;
}

.app-sidebar .brand::before {
    content: "";
    width: 26px; height: 26px;
    border-radius: 7px;
    background: linear-gradient(135deg, #4f8ef7, #22d3ee);
    box-shadow: 0 2px 12px rgba(79, 142, 247, .55);
}

.app-sidebar .brand-sub {
    color: var(--faint);
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .08em;
    padding: 0 10px 16px;
}

.nav-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px; }

.nav-list .nav-caption {
    color: var(--faint);
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .08em;
    padding: 14px 12px 6px;
}

.nav-list .nav-item {
    display: flex;
    align-items: center;
    gap: 11px;
    padding: 10px 12px;
    border-radius: 9px;
    color: #aeb9cc;
    text-decoration: none;
    font-weight: 500;
    transition: background .15s, color .15s;
}

.nav-list .nav-item .nav-ico { display: inline-flex; width: 18px; flex: 0 0 18px; opacity: .85; }
.nav-list .nav-item:hover { background: rgba(255, 255, 255, .05); color: #fff; }
.nav-list .nav-item:hover .nav-ico { opacity: 1; }

.nav-list .nav-item.active {
    background: var(--primary-050);
    color: var(--primary-600);
    box-shadow: inset 0 0 0 1px rgba(79, 142, 247, .28);
}
.nav-list .nav-item.active .nav-ico { opacity: 1; }

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

.app-topbar {
    height: 60px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 14px;
    padding: 0 24px;
    position: sticky;
    top: 0;
    z-index: 5;
}

.app-topbar .user { color: var(--muted); font-weight: 500; display: inline-flex; align-items: center; gap: 7px; }

.app-content { padding: 24px; max-width: 1180px; width: 100%; }

/* ---------- Typography ---------- */
h1 { font-size: 24px; font-weight: 700; margin: 0 0 4px; color: var(--text-strong); }
h2 { font-size: 18px; font-weight: 700; margin: 0; color: var(--text-strong); }
.section-title { font-size: 13px; font-weight: 700; margin: 0 0 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }

/* ---------- Page header ---------- */
.page-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}
.page-head .subtitle { color: var(--muted); margin: 0; max-width: 640px; }
.page-head .actions { display: flex; gap: 10px; flex-wrap: wrap; }

/* ---------- Callout (guidance strip) ---------- */
.callout {
    display: flex;
    gap: 12px;
    align-items: flex-start;
    background: var(--primary-020);
    border: 1px solid rgba(79, 142, 247, .28);
    border-radius: var(--radius);
    padding: 14px 16px;
    margin-bottom: 20px;
    color: #bcd4fb;
}
.callout .callout-ico { color: var(--primary-600); margin-top: 1px; }
.callout p { margin: 0; }
.callout b { color: #dbe8fd; }

/* ---------- Cards ---------- */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    margin-bottom: 20px;
    overflow: hidden;
}
.card-pad { padding: 18px; }
.card-head {
    display: flex; align-items: center; justify-content: space-between; gap: 12px;
    padding: 14px 18px; border-bottom: 1px solid var(--border);
}
.card-head h2 { font-size: 15px; }
.card-head .count {
    color: var(--muted); font-weight: 600; font-size: 12px;
    background: var(--surface-2); border: 1px solid var(--border);
    padding: 2px 9px; border-radius: 999px;
}

/* ---------- Toolbar (filter row) ---------- */
.toolbar {
    display: flex; flex-wrap: wrap; gap: 10px; align-items: center;
    padding: 14px 18px; border-bottom: 1px solid var(--border); background: var(--surface-2);
}
.toolbar .grow { flex: 1; }

/* ---------- Dashboard tiles ---------- */
.tiles {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
    gap: 16px;
    margin-top: 8px;
}
.tile {
    display: flex;
    flex-direction: column;
    gap: 8px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 18px;
    text-decoration: none;
    color: var(--text);
    transition: transform .12s, box-shadow .12s, border-color .12s;
}
.tile:hover { transform: translateY(-2px); border-color: rgba(79, 142, 247, .5); box-shadow: 0 10px 28px rgba(0, 0, 0, .45); }
.tile-ico {
    width: 40px; height: 40px; border-radius: 10px;
    display: inline-flex; align-items: center; justify-content: center;
    background: var(--primary-050); color: var(--primary-600);
}
.tile-title { font-size: 16px; font-weight: 700; color: var(--text-strong); }
.tile-desc { color: var(--muted); font-size: 13px; }

/* ---------- Guided steps (home) ---------- */
.steps { display: flex; flex-direction: column; gap: 0; }
.step {
    display: flex; gap: 16px; align-items: flex-start;
    padding: 16px 18px; text-decoration: none; color: var(--text);
    border-bottom: 1px solid var(--border); transition: background .12s;
}
.step:last-child { border-bottom: 0; }
.step:hover { background: var(--surface-2); }
.step-num {
    flex: 0 0 34px; width: 34px; height: 34px; border-radius: 50%;
    background: var(--primary-050); color: var(--primary-600);
    display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 15px;
}
.step-body { flex: 1; }
.step-body .t { font-weight: 700; font-size: 15px; display: flex; align-items: center; gap: 9px; color: var(--text-strong); }
.step-body .t .ico { color: var(--primary-600); }
.step-body .d { color: var(--muted); font-size: 13px; margin-top: 3px; }
.step-arrow { color: var(--faint); align-self: center; display: inline-flex; }

/* ---------- Forms ---------- */
.form-grid { display: flex; flex-direction: column; gap: 16px; }
.form-row { display: flex; gap: 16px; flex-wrap: wrap; }
.form-row > .field { flex: 1; min-width: 200px; }

.field { display: flex; flex-direction: column; gap: 5px; }
.field > label { color: var(--text); font-weight: 600; font-size: 13px; display: flex; align-items: center; gap: 5px; }
.field .req { color: var(--danger); font-weight: 700; }
.field .hint { color: var(--muted); font-size: 12px; line-height: 1.4; }
.field.check { flex-direction: row; align-items: center; gap: 9px; }
.field.check > label { font-weight: 500; }

input, select, textarea {
    font: inherit;
    color: var(--text);
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 9px;
    padding: 9px 11px;
    outline: none;
    transition: border-color .15s, box-shadow .15s;
    width: 100%;
}
input::placeholder, textarea::placeholder { color: var(--faint); }
input[type="checkbox"] { width: auto; accent-color: var(--primary); }
input[type="date"] { color-scheme: dark; }
input:focus, select:focus, textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-050); }
select option { background: var(--surface-2); color: var(--text); }
textarea { min-height: 150px; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 13px; }

.toolbar input, .toolbar select { width: auto; min-width: 200px; }

/* ---------- Buttons ---------- */
button, .btn {
    font: inherit;
    font-weight: 600;
    cursor: pointer;
    border: 1px solid transparent;
    border-radius: 9px;
    padding: 9px 15px;
    background: var(--primary);
    color: #08121f;
    display: inline-flex;
    align-items: center;
    gap: 7px;
    text-decoration: none;
    white-space: nowrap;
    transition: background .15s, border-color .15s, color .15s, transform .02s;
}
button:hover, .btn:hover { background: var(--primary-600); }
button:active, .btn:active { transform: translateY(1px); }
button:disabled, .btn:disabled { opacity: .45; cursor: not-allowed; }

.btn-primary { background: var(--primary); color: #08121f; border-color: transparent; }
.btn-primary:hover { background: var(--primary-600); }
.btn-secondary { background: var(--surface-3); color: var(--text); border-color: var(--border); }
.btn-secondary:hover { background: #2f3d4f; border-color: var(--border-strong); }
.btn-danger { background: transparent; color: var(--danger); border-color: rgba(242, 107, 115, .4); }
.btn-danger:hover { background: var(--danger-050); border-color: var(--danger); color: var(--danger); }
.btn-ghost { background: transparent; color: var(--muted); border-color: var(--border); }
.btn-ghost:hover { background: var(--surface-2); color: var(--text); }
.btn-sm { padding: 6px 11px; font-size: 13px; }
.btn-lg { padding: 11px 20px; font-size: 15px; }
.btn-block { width: 100%; justify-content: center; }

/* В подтверждении удаления главная кнопка — сплошная красная */
.modal-foot .btn-danger { background: var(--danger); color: #1b0709; border-color: transparent; }
.modal-foot .btn-danger:hover { background: var(--danger-700); color: #1b0709; }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; }
table { border-collapse: separate; border-spacing: 0; width: 100%; }
table thead th {
    text-align: left;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: var(--muted);
    background: var(--surface-2);
    padding: 11px 16px;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}
table tbody td { padding: 12px 16px; border-bottom: 1px solid var(--border); vertical-align: middle; }
table tbody tr:last-child td { border-bottom: 0; }
table tbody tr:hover td { background: var(--surface-2); }
td.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12px; color: var(--muted); }
td .primary-text { font-weight: 600; color: var(--text-strong); }

.row-actions { display: flex; gap: 6px; justify-content: flex-end; flex-wrap: wrap; }

/* ---------- Badges ---------- */
.badge {
    display: inline-flex; align-items: center; gap: 5px;
    padding: 3px 9px; border-radius: 999px; font-size: 12px; font-weight: 600;
    background: var(--surface-3); color: var(--muted); border: 1px solid var(--border);
}
.badge-ok { background: var(--ok-050); color: var(--ok); border-color: rgba(78, 203, 134, .35); }
.badge-warn { background: var(--warn-050); color: var(--warn); border-color: rgba(224, 171, 82, .35); }
.badge-danger { background: var(--danger-050); color: var(--danger); border-color: rgba(242, 107, 115, .35); }
.badge::before { content: "●"; font-size: 8px; }

/* ---------- Empty state ---------- */
.empty { text-align: center; padding: 48px 24px; color: var(--muted); }
.empty-ico {
    width: 56px; height: 56px; margin: 0 auto 14px; border-radius: 14px;
    display: flex; align-items: center; justify-content: center;
    background: var(--surface-2); color: var(--faint); border: 1px solid var(--border);
}
.empty h3 { font-size: 17px; color: var(--text-strong); margin: 0 0 6px; }
.empty p { margin: 0 auto 18px; max-width: 400px; }

/* ---------- Alert / toast ---------- */
.alert {
    display: flex; align-items: flex-start; gap: 10px;
    padding: 12px 14px; border-radius: 10px; margin-bottom: 18px;
    border: 1px solid var(--border); background: var(--surface-2);
    animation: alert-in .18s ease-out;
}
@keyframes alert-in { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: none; } }
.alert .alert-ico { margin-top: 1px; }
.alert .alert-msg { flex: 1; }
.alert .alert-x { background: transparent; border: 0; color: inherit; opacity: .6; font-size: 18px; line-height: 1; padding: 0 4px; cursor: pointer; }
.alert .alert-x:hover { opacity: 1; background: transparent; }
.alert-ok { background: var(--ok-050); border-color: rgba(78, 203, 134, .35); color: #8fe3b4; }
.alert-ok .alert-ico { color: var(--ok); }
.alert-error { background: var(--danger-050); border-color: rgba(242, 107, 115, .35); color: #f7a9ad; }
.alert-error .alert-ico { color: var(--danger); }
.alert-info { background: var(--primary-020); border-color: rgba(79, 142, 247, .35); color: #bcd4fb; }
.alert-info .alert-ico { color: var(--primary-600); }

/* ---------- Modal ---------- */
.modal-overlay {
    position: fixed; inset: 0; z-index: 1000;
    background: rgba(3, 6, 12, .66);
    backdrop-filter: blur(2px);
    display: flex; align-items: flex-start; justify-content: center;
    padding: 48px 16px; overflow-y: auto;
    animation: overlay-in .15s ease-out;
}
@keyframes overlay-in { from { opacity: 0; } to { opacity: 1; } }
.modal-card {
    background: var(--surface); border: 1px solid var(--border); border-radius: 14px; box-shadow: var(--shadow-lg);
    width: 100%; max-width: 560px; max-height: calc(100vh - 96px);
    display: flex; flex-direction: column; overflow: hidden;
    animation: modal-in .18s ease-out;
}
.modal-card.wide { max-width: 820px; }
@keyframes modal-in { from { opacity: 0; transform: translateY(-8px) scale(.99); } to { opacity: 1; transform: none; } }
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 18px 22px; border-bottom: 1px solid var(--border); }
.modal-head h2 { font-size: 18px; }
.modal-x { background: transparent; color: var(--muted); border: 0; font-size: 24px; line-height: 1; padding: 0 4px; cursor: pointer; }
.modal-x:hover { background: transparent; color: var(--text); }
.modal-body { padding: 22px; overflow-y: auto; }
.modal-body > .lead { margin: 0 0 18px; color: var(--muted); }
.modal-foot { display: flex; justify-content: flex-end; gap: 10px; padding: 16px 22px; border-top: 1px solid var(--border); background: var(--surface-2); }
.modal-danger-note {
    display: flex; gap: 10px; align-items: flex-start; background: var(--danger-050); border: 1px solid rgba(242, 107, 115, .35);
    color: #f7a9ad; border-radius: 10px; padding: 12px 14px; margin-top: 4px;
}
.modal-danger-note .ico { color: var(--danger); margin-top: 1px; }

/* ---------- Access denied ---------- */
.access-denied {
    max-width: 640px; margin: 48px auto; padding: 32px;
    background: var(--surface); border: 1px solid var(--border);
    border-left: 4px solid var(--danger); border-radius: var(--radius); box-shadow: var(--shadow);
}
.access-denied h1 { color: var(--danger); }
.access-denied p { color: var(--muted); }

/* ---------- Blazor error / reconnect UI ---------- */
#blazor-error-ui {
    display: none; position: fixed; bottom: 0; left: 0; right: 0; z-index: 2000;
    background: #2a2413; color: #f2d98a; border-top: 1px solid #57431a;
    padding: 12px 20px; box-shadow: 0 -2px 12px rgba(0, 0, 0, .5);
}
#blazor-error-ui .reload { color: var(--primary-600); font-weight: 600; }
#blazor-error-ui .dismiss { cursor: pointer; float: right; font-weight: 700; }
#components-reconnect-modal { display: none; }

/* ---------- Responsive ---------- */
@media (max-width: 820px) {
    .app-sidebar { width: 62px; flex-basis: 62px; padding: 16px 6px; }
    .app-sidebar .brand span, .app-sidebar .brand-sub, .nav-list .nav-item span:not(.nav-ico), .nav-list .nav-caption { display: none; }
    .app-content { padding: 16px; }
}

/* Страница входа: логин и пароль, ничего лишнего. */
.login-page { display: flex; align-items: center; justify-content: center; min-height: 100vh; padding: 24px; }
.login-card { width: 100%; max-width: 360px; display: flex; flex-direction: column; gap: 8px;
    background: var(--surface, #fff); border: 1px solid var(--border, #e2e5ea); border-radius: 12px; padding: 28px; }
.login-brand { font-size: 22px; font-weight: 700; letter-spacing: .04em; }
.login-title { color: var(--muted, #6b7280); margin-bottom: 12px; }
.login-card label { font-size: 13px; color: var(--muted, #6b7280); margin-top: 8px; }
.login-card input[type="text"], .login-card input[name="UserName"], .login-card input[type="password"] {
    padding: 10px 12px; border: 1px solid var(--border, #e2e5ea); border-radius: 8px; font-size: 15px; }
.login-remember { display: flex; align-items: center; gap: 8px; margin-top: 12px; }
.login-submit { margin-top: 16px; justify-content: center; }
.login-error { background: #fdecec; color: #a12222; border: 1px solid #f3c3c3; border-radius: 8px; padding: 10px 12px; font-size: 14px; }

/* ---------- Предпросмотр шаблона экрана ---------- */
.tpl-preview {
    position: relative; width: 100%; max-width: 560px; background: #111; border: 1px solid var(--border);
    border-radius: 8px; overflow: hidden; margin: 8px 0;
}
.tpl-block {
    position: absolute; border: 1px dashed rgba(255, 255, 255, .45); border-radius: 4px;
    display: flex; align-items: center; justify-content: center; font-size: 12px; text-align: center;
    background: rgba(255, 255, 255, .06); overflow: hidden;
}
.tpl-photo { background: rgba(120, 180, 255, .12); }
.tpl-price { background: rgba(255, 80, 80, .14); font-weight: 700; }
.tpl-kop { background: rgba(255, 80, 80, .10); }
.tpl-name { background: rgba(255, 255, 255, .10); }
.tpl-preview-note { color: var(--muted); font-size: 13px; margin-bottom: 8px; }
.tpl-preview-error {
    background: #fdecec; color: #a12222; border: 1px solid #f3c3c3; border-radius: 8px;
    padding: 10px 12px; font-size: 14px; margin: 8px 0;
}
.tpl-presets { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 8px; }
.tpl-preset { text-align: left; }
