:root {
    --bg: var(--tg-bg, #f4efe6);
    --surface: rgba(255, 252, 247, 0.82);
    --surface-strong: #fff9f2;
    --surface-dark: #101417;
    --text: var(--tg-text, #121315);
    --muted: #5c605f;
    --border: rgba(18, 19, 21, 0.1);
    --accent: #d15e33;
    --accent-strong: #ba431a;
    --accent-soft: rgba(209, 94, 51, 0.12);
    --success: #1e7a4d;
    --warning: #ab6b10;
    --danger: #a6362f;
    --shadow: 0 18px 60px rgba(26, 21, 17, 0.12);
    --radius-lg: 28px;
    --radius-md: 18px;
    --radius-sm: 12px;
    --font-sans: "Manrope", "Segoe UI", sans-serif;
}

* {
    box-sizing: border-box;
}

html, body {
    margin: 0;
    padding: 0;
    font-family: var(--font-sans);
    background:
        radial-gradient(circle at top left, rgba(209, 94, 51, 0.18), transparent 30%),
        radial-gradient(circle at 90% 10%, rgba(26, 122, 93, 0.12), transparent 22%),
        linear-gradient(180deg, #f8f3ea 0%, #efe8de 100%);
    color: var(--text);
    min-height: 100%;
}

body {
    min-height: 100vh;
}

a {
    color: inherit;
    text-decoration: none;
}

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

button,
input,
select,
textarea {
    font: inherit;
}

.app-shell,
.admin-shell {
    position: relative;
    min-height: 100vh;
    padding: 20px 16px 40px;
}

.catalog-layout,
.detail-layout,
.auth-layout,
.error-layout,
.form-shell {
    position: relative;
    z-index: 1;
    max-width: 1120px;
    margin: 0 auto;
}

.bg-orb {
    position: fixed;
    border-radius: 999px;
    pointer-events: none;
    filter: blur(50px);
    opacity: 0.45;
}

.bg-orb-one {
    width: 220px;
    height: 220px;
    background: rgba(209, 94, 51, 0.28);
    top: -60px;
    left: -40px;
}

.bg-orb-two {
    width: 280px;
    height: 280px;
    background: rgba(42, 108, 86, 0.18);
    right: -80px;
    top: 25%;
}

.hero-panel,
.filter-panel,
.detail-card,
.auth-card,
.error-card,
.admin-nav,
.admin-toolbar,
.admin-table-wrap,
.form-shell {
    background: var(--surface);
    backdrop-filter: blur(18px);
    border: 1px solid rgba(255, 255, 255, 0.55);
    box-shadow: var(--shadow);
}

.hero-panel,
.filter-panel,
.detail-card,
.admin-nav,
.admin-toolbar,
.admin-table-wrap,
.form-shell {
    border-radius: var(--radius-lg);
}

.hero-panel {
    padding: 28px 24px;
    margin-bottom: 18px;
}

.hero-panel h1,
.detail-copy h1,
.auth-card h1,
.error-card h1 {
    margin: 8px 0 12px;
    font-size: clamp(2rem, 6vw, 3.5rem);
    line-height: 0.95;
    letter-spacing: -0.04em;
}

.hero-copy,
.detail-block p,
.auth-card p,
.error-card p {
    color: var(--muted);
    line-height: 1.6;
}

.eyebrow {
    margin: 0;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    font-size: 0.78rem;
    color: var(--accent);
    font-weight: 800;
}

.hero-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 18px;
    color: var(--muted);
    font-size: 0.92rem;
}

.hero-meta span,
.meta-chip,
.category-chip,
.size-pill,
.status-pill,
.badge {
    border-radius: 999px;
}

.admin-nav {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    padding: 12px;
    margin-bottom: 18px;
}

.admin-nav-link {
    padding: 11px 16px;
    border-radius: 999px;
    border: 1px solid var(--border);
    background: rgba(255, 255, 255, 0.7);
    font-weight: 700;
}

.admin-nav-link.is-active {
    background: var(--accent-soft);
    color: var(--accent-strong);
    border-color: rgba(209, 94, 51, 0.2);
}

.filter-panel,
.admin-toolbar,
.form-shell {
    padding: 20px;
    margin-bottom: 18px;
}

.admin-toolbar-split {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

.catalog-filters,
.admin-filter-grid,
.form-grid,
.toggle-row,
.form-actions,
.section-head,
.admin-actions,
.table-actions {
    display: grid;
    gap: 14px;
}

.field {
    display: grid;
    gap: 8px;
}

.field span,
.detail-block h2 {
    font-weight: 700;
    font-size: 0.95rem;
}

.field input,
.field select,
.field textarea {
    width: 100%;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 14px 16px;
    background: rgba(255, 255, 255, 0.85);
    color: var(--text);
}

.field textarea {
    resize: vertical;
}

.field-hint {
    color: var(--muted);
    font-size: 0.84rem;
}

.field-error {
    color: var(--danger);
    font-size: 0.85rem;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 13px 18px;
    border-radius: 999px;
    border: 1px solid transparent;
    font-weight: 700;
    cursor: pointer;
}

.btn:disabled {
    cursor: not-allowed;
    opacity: 0.55;
}

.btn-primary {
    background: var(--tg-button, var(--accent));
    color: var(--tg-button-text, #fff6f0);
}

.btn-primary:hover {
    background: var(--accent-strong);
}

.btn-secondary,
.btn-ghost {
    background: rgba(255, 255, 255, 0.8);
    border-color: var(--border);
    color: var(--text);
}

.btn-danger {
    background: rgba(166, 54, 47, 0.1);
    border-color: rgba(166, 54, 47, 0.2);
    color: var(--danger);
}

.category-chip-row,
.size-row,
.badge-row,
.flash-stack,
.product-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.category-chip {
    padding: 10px 14px;
    background: rgba(255, 255, 255, 0.82);
    border: 1px solid var(--border);
    font-size: 0.92rem;
}

.category-chip.is-active,
.meta-chip {
    background: var(--accent-soft);
    color: var(--accent-strong);
}

.product-grid {
    display: grid;
    gap: 16px;
}

.product-card {
    border-radius: 24px;
    overflow: hidden;
    background: var(--surface);
    border: 1px solid rgba(255, 255, 255, 0.55);
    box-shadow: var(--shadow);
}

.product-card-link {
    display: grid;
}

.product-media {
    position: relative;
    aspect-ratio: 4 / 5;
    background: #ddd5cc;
}

.product-media img,
.detail-image-wrap img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.product-copy {
    padding: 18px;
}

.product-copy h3 {
    margin: 10px 0 8px;
    font-size: 1.15rem;
}

.product-price {
    font-weight: 800;
    font-size: 1.1rem;
}

.product-price.large {
    font-size: 1.8rem;
}

.size-pill {
    padding: 6px 10px;
    background: rgba(18, 19, 21, 0.06);
    font-size: 0.82rem;
}

.status-pill {
    padding: 6px 10px;
    font-size: 0.82rem;
    font-weight: 800;
}

.status-in_stock {
    background: rgba(30, 122, 77, 0.1);
    color: var(--success);
}

.status-reserved {
    background: rgba(171, 107, 16, 0.12);
    color: var(--warning);
}

.status-sold,
.status-hidden {
    background: rgba(166, 54, 47, 0.12);
    color: var(--danger);
}

.badge {
    padding: 7px 11px;
    font-size: 0.78rem;
    font-weight: 800;
}

.badge-new {
    background: rgba(26, 122, 93, 0.12);
    color: #116748;
}

.badge-sale {
    background: rgba(209, 94, 51, 0.12);
    color: var(--accent-strong);
}

.badge-row {
    position: absolute;
    top: 14px;
    left: 14px;
}

.detail-badges {
    position: static;
    margin-top: 12px;
}

.overlay-label {
    position: absolute;
    right: 14px;
    bottom: 14px;
    padding: 10px 14px;
    border-radius: 999px;
    background: rgba(16, 20, 23, 0.82);
    color: #fff;
    font-weight: 800;
}

.product-placeholder,
.table-placeholder {
    display: grid;
    place-items: center;
    width: 100%;
    height: 100%;
    min-height: 180px;
    color: var(--muted);
    background: linear-gradient(135deg, #e6ddd3, #d7ccbf);
    font-weight: 700;
}

.detail-layout .back-link {
    display: inline-flex;
    margin-bottom: 16px;
    color: var(--muted);
    font-weight: 700;
}

.detail-card {
    display: grid;
    overflow: hidden;
}

.detail-gallery {
    display: grid;
    gap: 8px;
    padding: 8px;
    background: rgba(255, 255, 255, 0.52);
}

.detail-image-wrap {
    border-radius: 20px;
    overflow: hidden;
    aspect-ratio: 4 / 5;
    background: #ddd5cc;
}

.detail-copy {
    padding: 24px;
}

.detail-block {
    margin-top: 20px;
}

.btn-contact {
    width: 100%;
    margin-top: 24px;
}

.pagination {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    margin-top: 20px;
    padding: 0 4px;
}

.empty-state,
.auth-card,
.error-card {
    text-align: center;
}

.empty-state,
.error-card {
    padding: 36px 24px;
}

.auth-layout,
.error-layout {
    display: grid;
    place-items: center;
    min-height: calc(100vh - 80px);
}

.auth-card {
    width: min(100%, 420px);
    padding: 30px 24px;
    border-radius: 28px;
}

.auth-form {
    display: grid;
    gap: 16px;
    margin-top: 22px;
}

.flash-stack {
    position: sticky;
    top: 12px;
    z-index: 10;
    justify-content: center;
    margin-bottom: 16px;
}

.flash {
    padding: 12px 16px;
    border-radius: 999px;
    font-weight: 700;
    box-shadow: 0 12px 30px rgba(0, 0, 0, 0.08);
}

.flash-success {
    background: rgba(30, 122, 77, 0.12);
    color: var(--success);
}

.flash-error {
    background: rgba(166, 54, 47, 0.12);
    color: var(--danger);
}

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

.admin-identity {
    align-self: center;
    font-weight: 700;
}

.admin-table-wrap {
    overflow-x: auto;
    padding: 10px;
}

.admin-table {
    width: 100%;
    border-collapse: collapse;
}

.admin-table th,
.admin-table td {
    padding: 14px 12px;
    border-bottom: 1px solid var(--border);
    text-align: left;
    vertical-align: top;
}

.table-product {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 220px;
}

.table-product img,
.table-placeholder {
    width: 58px;
    height: 58px;
    border-radius: 16px;
    object-fit: cover;
    min-height: 58px;
}

.table-subtitle {
    margin-top: 4px;
    color: var(--muted);
    font-size: 0.82rem;
}

.form-shell {
    padding: 24px;
}

.section-head {
    grid-template-columns: 1fr auto;
    align-items: center;
    margin-bottom: 20px;
}

.product-form {
    display: grid;
    gap: 18px;
}

.check-field {
    display: inline-flex;
    gap: 10px;
    align-items: center;
    font-weight: 700;
}

.check-field.compact {
    font-size: 0.88rem;
}

.check-field.danger {
    color: var(--danger);
}

.image-manager {
    display: grid;
    gap: 14px;
}

.image-grid {
    display: grid;
    gap: 14px;
}

.image-card {
    display: grid;
    gap: 10px;
    padding: 12px;
    border-radius: 18px;
    border: 1px solid var(--border);
    background: rgba(255, 255, 255, 0.72);
}

.image-card img {
    width: 100%;
    aspect-ratio: 1;
    object-fit: cover;
    border-radius: 16px;
}

@media (min-width: 700px) {
    .app-shell,
    .admin-shell {
        padding: 28px 22px 48px;
    }

    .catalog-filters,
    .admin-filter-grid,
    .form-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .toggle-row,
    .form-actions,
    .admin-actions,
    .table-actions {
        grid-auto-flow: column;
        justify-content: start;
    }

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

    .detail-card {
        grid-template-columns: 1.05fr 0.95fr;
    }

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

    .detail-image-wrap.is-main {
        grid-column: span 2;
    }

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

@media (min-width: 1024px) {
    .catalog-filters {
        grid-template-columns: 2fr 1fr 1fr auto;
        align-items: end;
    }

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

    .admin-filter-grid {
        grid-template-columns: 2fr 1fr 1fr auto;
        align-items: end;
    }
}
