:root {
    --ink: #17223b;
    --ink-soft: #526078;
    --navy: #082660;
    --navy-deep: #04183f;
    --orange: #ef6c18;
    --orange-dark: #c94a06;
    --gold: #ffbd2e;
    --cream: #fff7e8;
    --cream-strong: #ffebc5;
    --white: #ffffff;
    --green: #1b8a5a;
    --red: #c93c3c;
    --line: rgba(8, 38, 96, 0.13);
    --shadow: 0 22px 60px rgba(46, 34, 12, 0.13);
    --small-shadow: 0 10px 30px rgba(46, 34, 12, 0.10);
    --radius-xl: 32px;
    --radius-lg: 22px;
    --radius-md: 15px;
}

* {
    box-sizing: border-box;
}

html {
    min-height: 100%;
    background: var(--cream);
}

body {
    min-height: 100vh;
    margin: 0;
    color: var(--ink);
    background:
        radial-gradient(circle at 15% 4%, rgba(255, 189, 46, 0.24), transparent 31rem),
        radial-gradient(circle at 88% 18%, rgba(239, 108, 24, 0.13), transparent 28rem),
        linear-gradient(180deg, #fffdf8 0%, var(--cream) 44%, #fffaf0 100%);
    font-family: Inter, ui-rounded, "Segoe UI", system-ui, -apple-system, sans-serif;
    line-height: 1.5;
    overflow-x: hidden;
}

button,
input,
textarea {
    font: inherit;
}

button {
    cursor: pointer;
}

img {
    display: block;
    max-width: 100%;
}

.is-hidden {
    display: none !important;
}

.ambient {
    position: fixed;
    z-index: -1;
    width: 23rem;
    height: 23rem;
    border-radius: 50%;
    filter: blur(30px);
    opacity: 0.18;
    pointer-events: none;
}

.ambient-one {
    top: 18rem;
    left: -14rem;
    background: var(--gold);
}

.ambient-two {
    top: 2rem;
    right: -15rem;
    background: var(--orange);
}

.centered-view {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 24px;
}

.loading-card,
.blocked-card {
    width: min(100%, 820px);
    padding: 32px;
    border: 1px solid rgba(255, 255, 255, 0.75);
    border-radius: var(--radius-xl);
    background: rgba(255, 255, 255, 0.88);
    box-shadow: var(--shadow);
    backdrop-filter: blur(16px);
}

.loading-card {
    max-width: 480px;
    text-align: center;
}

.loading-card h1,
.blocked-card h1 {
    margin: 14px 0 6px;
    font-size: clamp(1.8rem, 5vw, 3rem);
    line-height: 1.06;
}

.loading-card p,
.blocked-card p {
    margin: 0;
    color: var(--ink-soft);
}

.coin-loader {
    width: 58px;
    height: 58px;
    margin: 0 auto;
    display: grid;
    place-items: center;
    color: var(--navy);
    background: var(--gold);
    border: 5px solid #ffe68c;
    border-radius: 50%;
    box-shadow: 0 9px 24px rgba(255, 189, 46, 0.38);
    animation: coin-bounce 1.2s ease-in-out infinite;
}

@keyframes coin-bounce {
    0%, 100% { transform: translateY(0) rotate(-5deg); }
    50% { transform: translateY(-9px) rotate(5deg); }
}

.blocked-card {
    display: grid;
    grid-template-columns: minmax(220px, 0.9fr) 1fr;
    align-items: center;
    gap: 28px;
}

.blocked-card img {
    width: 100%;
    border-radius: var(--radius-lg);
}

.app-shell {
    width: min(1180px, calc(100% - 32px));
    margin: 0 auto;
    padding: max(18px, env(safe-area-inset-top)) 0 36px;
}

.topbar {
    min-height: 72px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    padding: 12px 4px 20px;
}

.brand {
    display: inline-flex;
    align-items: center;
    gap: 11px;
    color: inherit;
    text-decoration: none;
}

.brand-mark {
    width: 44px;
    height: 44px;
    display: grid;
    place-items: center;
    color: var(--navy);
    font-size: 1.25rem;
    background: var(--gold);
    border: 4px solid #ffe58c;
    border-radius: 50%;
    box-shadow: 0 7px 18px rgba(255, 189, 46, 0.28);
}

.brand strong,
.brand small,
.profile-chip strong,
.profile-chip small {
    display: block;
}

.brand strong {
    color: var(--navy);
    line-height: 1.1;
}

.brand small,
.profile-chip small {
    color: var(--ink-soft);
    font-size: 0.75rem;
}

.account-summary {
    display: flex;
    align-items: center;
    gap: 10px;
}

.balance-chip,
.profile-chip {
    min-height: 48px;
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 8px 14px;
    border: 1px solid var(--line);
    background: rgba(255, 255, 255, 0.78);
    border-radius: 999px;
    box-shadow: var(--small-shadow);
}

.balance-chip > span {
    color: var(--orange-dark);
}

.balance-chip small {
    color: var(--ink-soft);
}

.profile-chip > span {
    width: 32px;
    height: 32px;
    display: grid;
    place-items: center;
    color: white;
    background: var(--navy);
    border-radius: 50%;
    font-weight: 800;
}

.hero {
    min-height: 420px;
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(360px, 0.9fr);
    align-items: center;
    overflow: hidden;
    position: relative;
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow);
}

.customer-hero {
    color: white;
    background:
        linear-gradient(120deg, rgba(4, 24, 63, 0.98), rgba(8, 38, 96, 0.94)),
        var(--navy);
}

.admin-hero {
    background: linear-gradient(130deg, #fff0cd, #fffaf0 68%);
    border: 1px solid rgba(239, 108, 24, 0.16);
}

.hero::before {
    content: "";
    position: absolute;
    width: 18rem;
    height: 18rem;
    top: -9rem;
    right: 28%;
    border-radius: 50%;
    background: rgba(255, 189, 46, 0.22);
}

.hero-copy {
    z-index: 1;
    padding: clamp(30px, 6vw, 68px);
}

.eyebrow {
    display: block;
    color: var(--orange-dark);
    font-size: 0.72rem;
    font-weight: 850;
    letter-spacing: 0.14em;
    text-transform: uppercase;
}

.customer-hero .eyebrow {
    color: #ffd468;
}

.hero h1 {
    max-width: 650px;
    margin: 10px 0 16px;
    font-size: clamp(2.35rem, 5.4vw, 4.6rem);
    letter-spacing: -0.045em;
    line-height: 0.98;
}

.hero p {
    max-width: 590px;
    margin: 0 0 26px;
    color: inherit;
    opacity: 0.8;
    font-size: 1.04rem;
}

.hero-balance {
    width: fit-content;
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 11px 18px;
    border: 1px solid rgba(255, 255, 255, 0.22);
    background: rgba(255, 255, 255, 0.11);
    border-radius: 999px;
}

.hero-balance span {
    color: rgba(255, 255, 255, 0.78);
}

.hero-balance strong {
    color: #ffd468;
    font-size: 1.2rem;
}

.hero-art {
    align-self: stretch;
    min-height: 360px;
    display: flex;
    align-items: flex-end;
    position: relative;
    overflow: hidden;
    background: white;
}

.hero-art img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center;
}

.customer-hero .hero-art {
    clip-path: ellipse(78% 84% at 72% 50%);
}

.admin-art img {
    object-fit: cover;
    object-position: 68% center;
}

.section-tabs {
    display: flex;
    gap: 8px;
    margin: 24px 0 0;
    padding: 6px;
    width: fit-content;
    max-width: 100%;
    overflow-x: auto;
    border: 1px solid var(--line);
    background: rgba(255, 255, 255, 0.76);
    border-radius: 999px;
    box-shadow: var(--small-shadow);
}

.tab-button {
    flex: 0 0 auto;
    padding: 10px 18px;
    color: var(--ink-soft);
    border: 0;
    background: transparent;
    border-radius: 999px;
    font-weight: 750;
}

.tab-button.is-active {
    color: white;
    background: var(--navy);
    box-shadow: 0 7px 18px rgba(8, 38, 96, 0.22);
}

.content-section {
    min-height: 300px;
    padding: 34px 0 18px;
}

.section-heading {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 18px;
    margin-bottom: 20px;
}

.section-heading h2 {
    margin: 4px 0 0;
    font-size: clamp(1.7rem, 4vw, 2.5rem);
    letter-spacing: -0.035em;
}

.primary-button,
.secondary-button,
.ghost-button,
.danger-button,
.success-button {
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 17px;
    border-radius: 12px;
    border: 1px solid transparent;
    font-weight: 800;
    transition: transform 150ms ease, box-shadow 150ms ease, opacity 150ms ease;
}

.primary-button {
    color: white;
    background: linear-gradient(135deg, var(--orange), var(--orange-dark));
    box-shadow: 0 10px 24px rgba(201, 74, 6, 0.24);
}

.secondary-button {
    color: var(--navy);
    border-color: var(--line);
    background: white;
}

.ghost-button {
    color: var(--navy);
    border-color: var(--line);
    background: rgba(255, 255, 255, 0.72);
}

.danger-button {
    color: white;
    background: var(--red);
}

.success-button {
    color: white;
    background: var(--green);
}

.primary-button:hover,
.secondary-button:hover,
.ghost-button:hover,
.danger-button:hover,
.success-button:hover {
    transform: translateY(-1px);
}

button:disabled {
    cursor: not-allowed;
    opacity: 0.48;
    transform: none !important;
}

.product-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 18px;
}

.product-card {
    min-width: 0;
    overflow: hidden;
    border: 1px solid var(--line);
    background: rgba(255, 255, 255, 0.9);
    border-radius: var(--radius-lg);
    box-shadow: var(--small-shadow);
}

.product-visual {
    aspect-ratio: 4 / 3;
    position: relative;
    display: grid;
    place-items: center;
    overflow: hidden;
    background: linear-gradient(135deg, #fff1ce, #fffaf0);
}

.product-visual img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.product-placeholder {
    width: 86px;
    height: 86px;
    display: grid;
    place-items: center;
    color: var(--navy);
    background: var(--gold);
    border: 9px solid #ffe89a;
    border-radius: 50%;
    font-size: 2rem;
    box-shadow: 0 12px 28px rgba(255, 189, 46, 0.28);
}

.locked-visual::after {
    content: "Закрыто";
    position: absolute;
    right: 12px;
    bottom: 12px;
    padding: 7px 11px;
    color: white;
    background: rgba(4, 24, 63, 0.88);
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 800;
}

.product-body {
    padding: 18px;
}

.product-body h3 {
    margin: 0 0 6px;
    font-size: 1.2rem;
}

.product-body p {
    min-height: 3em;
    margin: 0 0 16px;
    color: var(--ink-soft);
}

.product-meta,
.product-actions,
.admin-product-actions,
.order-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    flex-wrap: wrap;
}

.price {
    color: var(--orange-dark);
    font-size: 1.12rem;
    font-weight: 900;
}

.stock {
    color: var(--ink-soft);
    font-size: 0.86rem;
}

.product-actions {
    margin-top: 14px;
}

.product-actions button {
    width: 100%;
}

.empty-state {
    min-height: 330px;
    display: grid;
    grid-template-columns: minmax(240px, 0.8fr) 1fr;
    align-items: center;
    gap: 28px;
    padding: 28px;
    overflow: hidden;
    border: 1px dashed rgba(8, 38, 96, 0.22);
    background: rgba(255, 255, 255, 0.72);
    border-radius: var(--radius-xl);
}

.empty-state img {
    width: 100%;
    max-height: 320px;
    object-fit: contain;
    border-radius: var(--radius-lg);
}

.empty-state h3 {
    margin: 5px 0 8px;
    font-size: clamp(1.5rem, 4vw, 2.4rem);
}

.empty-state p {
    max-width: 500px;
    color: var(--ink-soft);
}

.compact-empty {
    min-height: 260px;
}

.compact-empty img {
    max-height: 240px;
}

.admin-product-list,
.order-list {
    display: grid;
    gap: 12px;
}

.admin-product-card,
.order-card {
    display: grid;
    grid-template-columns: 94px minmax(0, 1fr) auto;
    align-items: center;
    gap: 16px;
    padding: 14px;
    border: 1px solid var(--line);
    background: rgba(255, 255, 255, 0.88);
    border-radius: var(--radius-md);
    box-shadow: 0 7px 22px rgba(46, 34, 12, 0.07);
}

.admin-product-card img,
.admin-product-image,
.order-card img,
.order-image {
    width: 94px;
    height: 78px;
    object-fit: contain;
    background: #fff4db;
    border-radius: 12px;
}

.admin-product-image,
.order-image {
    display: grid;
    place-items: center;
    color: var(--navy);
    font-size: 1.5rem;
    font-weight: 900;
}

.admin-product-info h3,
.order-info h3 {
    margin: 0 0 4px;
}

.admin-product-info p,
.order-info p {
    margin: 0;
    color: var(--ink-soft);
    font-size: 0.9rem;
}

.status-badge {
    display: inline-flex;
    align-items: center;
    width: fit-content;
    padding: 5px 9px;
    margin-top: 7px;
    border-radius: 999px;
    font-size: 0.74rem;
    font-weight: 850;
}

.status-pending { color: #7a5000; background: #fff0b8; }
.status-fulfilled { color: #0c6540; background: #cdeedc; }
.status-cancelled { color: #8a2222; background: #ffd7d7; }
.status-inactive { color: #5b6472; background: #e7e9ed; }
.status-locked { color: var(--navy); background: #dce6ff; }

.modal {
    width: min(720px, calc(100% - 28px));
    max-height: min(88vh, 900px);
    padding: 0;
    overflow: auto;
    color: var(--ink);
    border: 0;
    background: white;
    border-radius: var(--radius-lg);
    box-shadow: 0 30px 90px rgba(4, 24, 63, 0.28);
}

.modal::backdrop {
    background: rgba(4, 24, 63, 0.56);
    backdrop-filter: blur(5px);
}

.modal form,
.modal > div,
.modal > p,
.modal > label {
    margin-left: 26px;
    margin-right: 26px;
}

.modal form {
    margin: 0;
    padding: 26px;
}

.small-modal {
    width: min(520px, calc(100% - 28px));
    padding: 26px;
}

.small-modal > div,
.small-modal > p,
.small-modal > label {
    margin-left: 0;
    margin-right: 0;
}

.modal-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 18px;
    margin-bottom: 20px;
}

.modal-header h2 {
    margin: 4px 0 0;
}

.icon-button {
    width: 38px;
    height: 38px;
    flex: 0 0 auto;
    border: 1px solid var(--line);
    color: var(--ink-soft);
    background: white;
    border-radius: 50%;
    font-size: 1.5rem;
    line-height: 1;
}

.form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
}

.field {
    display: grid;
    gap: 6px;
    margin-bottom: 15px;
}

.field-wide {
    grid-column: 1 / -1;
}

.field > span {
    font-size: 0.87rem;
    font-weight: 800;
}

.field small,
.switch-field small {
    color: var(--ink-soft);
    font-size: 0.76rem;
}

.field input,
.field textarea {
    width: 100%;
    padding: 11px 12px;
    color: var(--ink);
    border: 1px solid rgba(8, 38, 96, 0.2);
    background: #fffdf8;
    border-radius: 11px;
    outline: none;
}

.field input:focus,
.field textarea:focus {
    border-color: var(--orange);
    box-shadow: 0 0 0 3px rgba(239, 108, 24, 0.12);
}

.switch-field {
    grid-column: 1 / -1;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: 12px;
}

.switch-field input {
    position: absolute;
    opacity: 0;
}

.switch-field > span:last-child {
    display: grid;
}

.switch {
    width: 46px;
    height: 26px;
    flex: 0 0 auto;
    position: relative;
    background: #c8ced8;
    border-radius: 999px;
    transition: background 150ms ease;
}

.switch::after {
    content: "";
    position: absolute;
    width: 20px;
    height: 20px;
    top: 3px;
    left: 3px;
    background: white;
    border-radius: 50%;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.18);
    transition: transform 150ms ease;
}

.switch-field input:checked + .switch {
    background: var(--orange);
}

.switch-field input:checked + .switch::after {
    transform: translateX(20px);
}

.check-field {
    grid-column: 1 / -1;
    color: var(--ink-soft);
}

.image-preview {
    grid-column: 1 / -1;
    min-height: 150px;
    place-items: center;
    overflow: hidden;
    border: 1px dashed var(--line);
    background: var(--cream);
    border-radius: 12px;
}

.image-preview:not(.is-hidden) {
    display: grid;
}

.image-preview img {
    max-width: 100%;
    max-height: 230px;
    object-fit: contain;
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 22px;
}

.dialog-copy {
    color: var(--ink-soft);
}

.toast-region {
    position: fixed;
    z-index: 100;
    right: max(16px, env(safe-area-inset-right));
    bottom: max(16px, env(safe-area-inset-bottom));
    display: grid;
    gap: 9px;
    width: min(380px, calc(100% - 32px));
}

.toast {
    padding: 13px 15px;
    color: white;
    background: var(--navy-deep);
    border-left: 5px solid var(--gold);
    border-radius: 12px;
    box-shadow: 0 15px 38px rgba(4, 24, 63, 0.28);
    animation: toast-in 180ms ease-out;
}

.toast.error {
    border-left-color: #ff6c6c;
}

@keyframes toast-in {
    from { transform: translateY(12px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

footer {
    display: flex;
    justify-content: space-between;
    gap: 18px;
    padding: 28px 4px 8px;
    color: var(--ink-soft);
    font-size: 0.82rem;
}

@media (max-width: 900px) {
    .hero {
        min-height: 0;
        grid-template-columns: 1fr;
    }

    .hero-art {
        min-height: 310px;
    }

    .customer-hero .hero-art {
        clip-path: none;
    }

    .product-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 640px) {
    .app-shell {
        width: min(100% - 20px, 1180px);
    }

    .topbar {
        align-items: flex-start;
    }

    .brand small,
    .profile-chip div,
    .balance-chip small {
        display: none;
    }

    .brand-mark {
        width: 38px;
        height: 38px;
    }

    .balance-chip,
    .profile-chip {
        min-height: 42px;
        padding: 5px 10px;
    }

    .profile-chip > span {
        width: 30px;
        height: 30px;
    }

    .hero-copy {
        padding: 30px 24px;
    }

    .hero h1 {
        font-size: clamp(2.1rem, 12vw, 3.3rem);
    }

    .hero-art {
        min-height: 250px;
    }

    .product-grid {
        grid-template-columns: 1fr;
    }

    .section-heading {
        align-items: center;
    }

    .empty-state,
    .blocked-card {
        grid-template-columns: 1fr;
        text-align: center;
    }

    .empty-state img,
    .blocked-card img {
        max-height: 230px;
        margin: 0 auto;
    }

    .admin-product-card,
    .order-card {
        grid-template-columns: 70px minmax(0, 1fr);
    }

    .admin-product-card img,
    .admin-product-image,
    .order-card img,
    .order-image {
        width: 70px;
        height: 66px;
    }

    .admin-product-actions,
    .order-actions {
        grid-column: 1 / -1;
        justify-content: stretch;
    }

    .admin-product-actions button,
    .order-actions button {
        flex: 1 1 120px;
    }

    .form-grid {
        grid-template-columns: 1fr;
    }

    .field-wide,
    .switch-field,
    .check-field,
    .image-preview {
        grid-column: 1;
    }

    .modal form,
    .small-modal {
        padding: 20px;
    }

    footer {
        flex-direction: column;
        text-align: center;
    }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        scroll-behavior: auto !important;
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}
