/* ==========================================================================
   ELSTICKERS — "Схема" design tokens
   Stage 1: preview only. Load after Bootstrap and legacy CSS when integrating.
   ========================================================================== */

:root {
    /* Ink */
    --es-ink-950: #08121b;
    --es-ink-900: #0b1620;
    --es-ink-800: #142331;
    --es-ink-700: #26343f;
    --es-ink-500: #5b6b7a;
    --es-ink-300: #9aa8b4;
    --es-line: #dce3e6;
    --es-line-strong: #c7d2d7;

    /* Surfaces */
    --es-paper: #ffffff;
    --es-mist-50: #f7f9fa;
    --es-mist-100: #f4f6f7;
    --es-mist-200: #edf1f2;

    /* Brand */
    --es-blue-700: #174ca8;
    --es-blue-600: #1d5fd1;
    --es-blue-500: #2f74e6;
    --es-blue-100: #e6eefc;

    /* Semantic */
    --es-green-600: #1c8c5a;
    --es-green-100: #e4f4ec;
    --es-red-600: #c8372d;
    --es-red-100: #fbe9e7;
    --es-amber-600: #b97a00;
    --es-amber-100: #fdf1d6;

    /* Type */
    --es-font-ui: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
    --es-font-mono: 'JetBrains Mono', ui-monospace, 'Cascadia Mono', Consolas, monospace;
    --es-font-sticker: 'Roboto Condensed', 'Arial Narrow', Arial, sans-serif;

    /* Shape */
    --es-radius-sm: 8px;
    --es-radius-md: 12px;
    --es-radius-lg: 18px;
    --es-radius-xl: 24px;

    /* Elevation */
    --es-shadow-sm: 0 1px 2px rgba(11, 22, 32, 0.05), 0 6px 16px rgba(11, 22, 32, 0.04);
    --es-shadow-md: 0 12px 32px rgba(11, 22, 32, 0.10);
    --es-shadow-lg: 0 28px 70px rgba(11, 22, 32, 0.18);

    /* Layout */
    --es-container: 1280px;
    --es-topbar: 72px;
}

.es-body {
    margin: 0;
    background: var(--es-mist-100);
    color: var(--es-ink-900);
    font-family: var(--es-font-ui);
    font-size: 16px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}

.es-body *,
.es-body *::before,
.es-body *::after {
    box-sizing: border-box;
}

.es-body ::selection {
    background: rgba(29, 95, 209, 0.18);
}

/* ---------- Typography ---------- */

.es-display {
    margin: 0;
    font-size: clamp(2.2rem, 4.4vw, 3.9rem);
    font-weight: 700;
    line-height: 0.98;
    letter-spacing: -0.045em;
}

.es-h1 {
    margin: 0;
    font-size: clamp(1.8rem, 3vw, 2.6rem);
    font-weight: 700;
    line-height: 1.06;
    letter-spacing: -0.035em;
}

.es-h2 {
    margin: 0;
    font-size: 1.55rem;
    font-weight: 650;
    line-height: 1.15;
    letter-spacing: -0.025em;
}

.es-h3 {
    margin: 0;
    font-size: 1.15rem;
    font-weight: 650;
    line-height: 1.25;
    letter-spacing: -0.015em;
}

.es-lead {
    margin: 0;
    max-width: 62ch;
    color: var(--es-ink-500);
    font-size: 1.08rem;
    line-height: 1.55;
}

.es-text {
    margin: 0;
    font-size: 0.95rem;
    line-height: 1.6;
}

.es-text--muted {
    color: var(--es-ink-500);
}

.es-mono {
    font-family: var(--es-font-mono);
    font-size: 0.82em;
    letter-spacing: -0.02em;
    font-feature-settings: 'tnum' 1;
}

.es-eyebrow {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin: 0;
    color: var(--es-blue-600);
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.12em;
    text-transform: uppercase;
}

.es-eyebrow::before {
    content: '';
    width: 18px;
    height: 2px;
    background: currentColor;
}

/* ---------- Buttons ---------- */

.es-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    height: 44px;
    padding: 0 18px;
    border: 1px solid transparent;
    border-radius: var(--es-radius-md);
    background: transparent;
    color: var(--es-ink-900);
    font: 600 0.94rem/1 var(--es-font-ui);
    text-decoration: none;
    white-space: nowrap;
    cursor: pointer;
    transition: background-color 0.16s ease, border-color 0.16s ease, color 0.16s ease, box-shadow 0.16s ease, transform 0.16s ease;
}

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

.es-btn:active {
    transform: translateY(1px);
}

.es-btn:focus-visible {
    outline: 0;
    box-shadow: 0 0 0 3px rgba(29, 95, 209, 0.28);
}

.es-btn--primary {
    background: var(--es-blue-600);
    color: #ffffff;
    box-shadow: 0 1px 2px rgba(11, 22, 32, 0.12);
}

.es-btn--primary:hover {
    background: var(--es-blue-700);
    color: #ffffff;
}

.es-btn--secondary {
    background: var(--es-blue-100);
    color: var(--es-blue-700);
}

.es-btn--secondary:hover {
    background: #d8e5fb;
    color: var(--es-blue-700);
}

.es-btn--ghost {
    border-color: var(--es-line);
    background: var(--es-paper);
    color: var(--es-ink-800);
}

.es-btn--ghost:hover {
    border-color: var(--es-line-strong);
    background: var(--es-mist-50);
    color: var(--es-ink-900);
}

.es-btn--danger {
    background: var(--es-red-600);
    color: #ffffff;
}

.es-btn--danger:hover {
    background: #a92b23;
    color: #ffffff;
}

.es-btn--quiet {
    color: var(--es-ink-500);
}

.es-btn--quiet:hover {
    background: var(--es-mist-100);
    color: var(--es-ink-900);
}

.es-btn--sm {
    height: 34px;
    padding: 0 12px;
    border-radius: var(--es-radius-sm);
    font-size: 0.8rem;
}

.es-btn--lg {
    height: 52px;
    padding: 0 24px;
    border-radius: 14px;
    font-size: 1rem;
}

.es-btn--icon {
    width: 40px;
    height: 40px;
    padding: 0;
}

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

.es-btn[disabled],
.es-btn.is-disabled {
    opacity: 0.5;
    pointer-events: none;
}

/* ---------- Forms ---------- */

.es-field {
    display: grid;
    gap: 6px;
}

.es-label {
    color: var(--es-ink-700);
    font-size: 0.8rem;
    font-weight: 600;
    letter-spacing: 0.01em;
}

.es-input,
.es-select,
.es-textarea {
    width: 100%;
    min-height: 44px;
    padding: 10px 14px;
    border: 1px solid var(--es-line);
    border-radius: var(--es-radius-md);
    background: var(--es-paper);
    color: var(--es-ink-900);
    font: 400 0.94rem/1.4 var(--es-font-ui);
    transition: border-color 0.16s ease, box-shadow 0.16s ease;
}

.es-textarea {
    min-height: 110px;
    resize: vertical;
}

.es-input::placeholder,
.es-textarea::placeholder {
    color: var(--es-ink-300);
}

.es-input:hover,
.es-select:hover,
.es-textarea:hover {
    border-color: var(--es-line-strong);
}

.es-input:focus,
.es-select:focus,
.es-textarea:focus {
    outline: 0;
    border-color: var(--es-blue-600);
    box-shadow: 0 0 0 3px rgba(29, 95, 209, 0.12);
}

.es-hint {
    color: var(--es-ink-500);
    font-size: 0.76rem;
    line-height: 1.4;
}

.es-check {
    display: inline-flex;
    align-items: center;
    gap: 9px;
    color: var(--es-ink-700);
    font-size: 0.88rem;
    cursor: pointer;
}

.es-check input {
    width: 18px;
    height: 18px;
    accent-color: var(--es-blue-600);
}

.es-switch {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    font-size: 0.9rem;
}

.es-switch input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.es-switch__track {
    position: relative;
    width: 42px;
    height: 24px;
    border-radius: 999px;
    background: var(--es-line-strong);
    transition: background-color 0.16s ease;
}

.es-switch__track::after {
    content: '';
    position: absolute;
    top: 3px;
    left: 3px;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #ffffff;
    box-shadow: 0 1px 3px rgba(11, 22, 32, 0.2);
    transition: transform 0.16s ease;
}

.es-switch input:checked + .es-switch__track {
    background: var(--es-blue-600);
}

.es-switch input:checked + .es-switch__track::after {
    transform: translateX(18px);
}

/* ---------- Tabs, badges, chips ---------- */

.es-tabs {
    display: inline-flex;
    gap: 4px;
    padding: 4px;
    border: 1px solid var(--es-line);
    border-radius: var(--es-radius-md);
    background: var(--es-mist-100);
}

.es-tab {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    height: 34px;
    padding: 0 14px;
    border: 0;
    border-radius: var(--es-radius-sm);
    background: transparent;
    color: var(--es-ink-500);
    font: 600 0.82rem/1 var(--es-font-ui);
    cursor: pointer;
    transition: background-color 0.16s ease, color 0.16s ease, box-shadow 0.16s ease;
}

.es-tab:hover {
    color: var(--es-ink-900);
}

.es-tab.is-active {
    background: var(--es-paper);
    color: var(--es-ink-900);
    box-shadow: var(--es-shadow-sm);
}

.es-badge {
    display: inline-flex;
    align-items: center;
    height: 24px;
    padding: 0 9px;
    border-radius: 999px;
    background: var(--es-blue-100);
    color: var(--es-blue-700);
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    line-height: 1;
    text-transform: uppercase;
}

.es-badge--green {
    background: var(--es-green-100);
    color: var(--es-green-600);
}

.es-badge--red {
    background: var(--es-red-100);
    color: var(--es-red-600);
}

.es-badge--amber {
    background: var(--es-amber-100);
    color: var(--es-amber-600);
}

.es-chip {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    height: 30px;
    padding: 0 11px;
    border: 1px solid var(--es-line);
    border-radius: 999px;
    background: var(--es-paper);
    color: var(--es-ink-700);
    font-size: 0.78rem;
    font-weight: 500;
}

.es-chip__dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--es-blue-600);
}

/* ---------- Cards and panels ---------- */

.es-card {
    border: 1px solid var(--es-line);
    border-radius: var(--es-radius-lg);
    background: var(--es-paper);
    box-shadow: var(--es-shadow-sm);
}

.es-card__body {
    padding: 22px;
}

.es-card__head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 18px 22px;
    border-bottom: 1px solid var(--es-line);
}

.es-card__foot {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
    padding: 14px 22px;
    border-top: 1px solid var(--es-line);
    background: var(--es-mist-50);
    border-radius: 0 0 var(--es-radius-lg) var(--es-radius-lg);
}

.es-panel {
    border: 1px solid var(--es-line);
    border-radius: var(--es-radius-lg);
    background: var(--es-paper);
}

.es-panel--muted {
    background: var(--es-mist-50);
}

.es-divider {
    height: 1px;
    border: 0;
    margin: 20px 0;
    background: var(--es-line);
}

/* ---------- Topbar / brand ---------- */

.es-topbar {
    position: sticky;
    top: 0;
    z-index: 50;
    height: var(--es-topbar);
    border-bottom: 1px solid var(--es-line);
    background: rgba(255, 255, 255, 0.92);
    backdrop-filter: blur(14px);
}

.es-topbar__inner {
    display: flex;
    align-items: center;
    gap: 26px;
    width: 100%;
    max-width: var(--es-container);
    height: 100%;
    margin: 0 auto;
    padding: 0 24px;
}

.es-brand {
    display: inline-flex;
    align-items: center;
    gap: 11px;
    color: var(--es-ink-900);
    text-decoration: none;
}

.es-brand:hover {
    color: var(--es-ink-900);
    text-decoration: none;
}

.es-brand__mark {
    width: 38px;
    height: 38px;
    flex: none;
}

.es-brand__text {
    display: grid;
    gap: 2px;
}

.es-brand__name {
    font-size: 1.16rem;
    font-weight: 750;
    letter-spacing: -0.035em;
    line-height: 1;
}

.es-brand__name span {
    color: var(--es-blue-600);
}

.es-brand__sub {
    color: var(--es-ink-500);
    font-size: 0.58rem;
    font-weight: 600;
    letter-spacing: 0.09em;
    line-height: 1;
    text-transform: uppercase;
    white-space: nowrap;
}

.es-nav {
    display: flex;
    align-items: center;
    gap: 2px;
    margin-left: 8px;
}

.es-nav__link {
    display: inline-flex;
    align-items: center;
    height: 38px;
    padding: 0 13px;
    border-radius: var(--es-radius-sm);
    color: var(--es-ink-500);
    font-size: 0.86rem;
    font-weight: 500;
    text-decoration: none;
    transition: background-color 0.16s ease, color 0.16s ease;
}

.es-nav__link:hover {
    background: var(--es-mist-100);
    color: var(--es-ink-900);
    text-decoration: none;
}

.es-nav__link.is-active {
    background: var(--es-mist-100);
    color: var(--es-ink-900);
    font-weight: 600;
}

.es-topbar__actions {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-left: auto;
}

/* ---------- Rail / toolbar ---------- */

.es-rail {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    width: 60px;
    padding: 9px 0;
    border-radius: var(--es-radius-lg);
    background: var(--es-ink-900);
    box-shadow: var(--es-shadow-md);
}

.es-rail__btn {
    display: grid;
    place-items: center;
    width: 42px;
    height: 42px;
    border: 0;
    border-radius: var(--es-radius-md);
    background: transparent;
    color: rgba(255, 255, 255, 0.72);
    cursor: pointer;
    transition: background-color 0.16s ease, color 0.16s ease;
}

.es-rail__btn:hover {
    background: rgba(255, 255, 255, 0.10);
    color: #ffffff;
}

.es-rail__btn.is-active {
    background: var(--es-blue-600);
    color: #ffffff;
}

.es-rail__btn--danger {
    color: #ff8a80;
}

.es-rail__btn--danger:hover {
    background: rgba(200, 55, 45, 0.22);
    color: #ffb4ad;
}

.es-rail__sep {
    width: 28px;
    height: 1px;
    margin: 4px 0;
    background: rgba(255, 255, 255, 0.14);
}

/* ---------- Palette ---------- */

.es-palette {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(38px, 1fr));
    gap: 8px;
}

.es-swatch {
    aspect-ratio: 1;
    border: 1px solid rgba(11, 22, 32, 0.12);
    border-radius: 9px;
    background: var(--es-mist-100);
    cursor: pointer;
    transition: transform 0.12s ease, box-shadow 0.12s ease;
}

.es-swatch:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 10px rgba(11, 22, 32, 0.14);
}

.es-swatch.is-active {
    outline: 2px solid var(--es-blue-600);
    outline-offset: 2px;
}

/* ---------- Toast / modal ---------- */

.es-toast {
    display: flex;
    align-items: center;
    gap: 10px;
    max-width: 360px;
    padding: 13px 16px;
    border-radius: var(--es-radius-md);
    background: var(--es-ink-900);
    color: #ffffff;
    box-shadow: var(--es-shadow-md);
    font-size: 0.86rem;
}

.es-toast--success {
    background: var(--es-green-600);
}

.es-toast--error {
    background: var(--es-red-600);
}

.es-toast__dot {
    width: 8px;
    height: 8px;
    flex: none;
    border-radius: 50%;
    background: currentColor;
    opacity: 0.8;
}

.es-modal {
    width: 100%;
    max-width: 480px;
    border-radius: var(--es-radius-lg);
    background: var(--es-paper);
    box-shadow: var(--es-shadow-lg);
    overflow: hidden;
}

.es-modal__head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 18px 22px 12px;
}

.es-modal__title {
    margin: 0;
    font-size: 1.15rem;
    font-weight: 650;
    letter-spacing: -0.02em;
}

.es-modal__close {
    display: grid;
    place-items: center;
    width: 34px;
    height: 34px;
    border: 0;
    border-radius: var(--es-radius-sm);
    background: transparent;
    color: var(--es-ink-500);
    font-size: 1.4rem;
    line-height: 1;
    cursor: pointer;
}

.es-modal__close:hover {
    background: var(--es-mist-100);
    color: var(--es-ink-900);
}

.es-modal__body {
    padding: 6px 22px 18px;
    color: var(--es-ink-700);
    font-size: 0.92rem;
    line-height: 1.55;
}

.es-modal__foot {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    padding: 14px 22px;
    border-top: 1px solid var(--es-line);
    background: var(--es-mist-50);
}

/* ---------- Workspace mock ---------- */

.es-workspace {
    display: grid;
    grid-template-columns: 60px minmax(0, 1fr) 300px;
    gap: 16px;
    align-items: start;
}

.es-canvas {
    min-height: 430px;
    padding: 28px;
    border: 1px solid var(--es-line);
    border-radius: var(--es-radius-lg);
    background:
        linear-gradient(rgba(29, 95, 209, 0.035) 1px, transparent 1px),
        linear-gradient(90deg, rgba(29, 95, 209, 0.035) 1px, transparent 1px),
        var(--es-mist-100);
    background-size: 24px 24px, 24px 24px, auto;
    overflow: hidden;
}

.es-paper {
    position: relative;
    min-height: 340px;
    padding: 34px 34px 30px 54px;
    border: 1px solid var(--es-line);
    border-radius: 3px;
    background: var(--es-paper);
    box-shadow: 0 18px 44px rgba(11, 22, 32, 0.12);
}

.es-paper::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 28px;
    height: 100%;
    border-right: 1px solid var(--es-line);
    background: repeating-linear-gradient(to bottom, transparent 0 9px, var(--es-line) 9px 10px);
    opacity: 0.8;
}

.es-paper::after {
    content: '';
    position: absolute;
    top: 0;
    left: 28px;
    right: 0;
    height: 18px;
    border-bottom: 1px solid var(--es-line);
    background: repeating-linear-gradient(to right, transparent 0 9px, var(--es-line) 9px 10px);
    opacity: 0.8;
}

.es-strip {
    display: flex;
    gap: 3px;
    margin-bottom: 14px;
}

.es-block {
    flex: 1 1 0;
    min-width: 0;
    border: 1px solid var(--es-line-strong);
    background: var(--es-paper);
}

.es-block__head {
    height: 20px;
    background: var(--es-blue-600);
}

.es-block__body {
    display: grid;
    place-items: center;
    min-height: 62px;
    padding: 6px;
    color: var(--es-ink-900);
    font-family: var(--es-font-sticker);
    font-size: 0.78rem;
    line-height: 1.05;
    text-align: center;
}

.es-block--red .es-block__head { background: #c62828; }
.es-block--yellow .es-block__head { background: #f2b705; }
.es-block--green .es-block__head { background: #1f8a4c; }

.es-inspector {
    display: grid;
    gap: 12px;
}

.es-inspector__section {
    padding: 16px;
    border: 1px solid var(--es-line);
    border-radius: var(--es-radius-md);
    background: var(--es-paper);
}

.es-inspector__title {
    margin: 0 0 10px;
    color: var(--es-ink-500);
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

/* ---------- Helpers ---------- */

.es-stack {
    display: grid;
    gap: 14px;
}

.es-row {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.es-muted {
    color: var(--es-ink-500);
}

.es-mono-value {
    font-family: var(--es-font-mono);
    font-size: 0.82em;
    font-variant-numeric: tabular-nums;
}

@media (max-width: 900px) {
    .es-workspace {
        grid-template-columns: 60px minmax(0, 1fr);
    }

    .es-inspector {
        grid-column: 1 / -1;
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 720px) {
    .es-topbar {
        height: auto;
    }

    .es-topbar__inner {
        flex-wrap: wrap;
        gap: 10px 16px;
        padding: 12px 16px;
    }

    .es-nav {
        order: 3;
        width: 100%;
        margin-left: 0;
        overflow-x: auto;
    }

    .es-workspace {
        grid-template-columns: 1fr;
    }

    .es-rail {
        flex-direction: row;
        width: auto;
        justify-content: center;
    }

    .es-canvas {
        padding: 14px;
    }

    .es-paper {
        padding: 30px 18px 20px 38px;
    }

    .es-inspector {
        grid-template-columns: 1fr;
    }
}
