:root {
    --black: #111;
    --charcoal: #262626;
    --white: #fff;
    --soft: #f3f3f1;
    --muted: #6c6c68;
    --line: #ddddda;
    --yellow: #feed00;
    --red: #b42318;
    --green: #16794a;
    --shadow: 0 16px 38px rgba(0, 0, 0, .08);
}

* { box-sizing: border-box; }
html { min-height: 100%; }
body { min-height: 100%; margin: 0; color: var(--black); background: var(--soft); font-family: Inter, Arial, sans-serif; line-height: 1.45; }
img { display: block; max-width: 100%; }
a { color: inherit; }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }

.panel-shell { display: grid; grid-template-columns: 224px minmax(0, 1fr); min-height: 100vh; }
.panel-sidebar { position: sticky; z-index: 30; top: 0; display: flex; flex-direction: column; height: 100vh; color: #ddd; background: var(--black); border-right: 1px solid #2d2d2d; }
.panel-brand { display: grid; place-items: center; min-height: 110px; padding: 14px 20px; border-bottom: 1px solid #2d2d2d; }
.panel-brand img { width: 174px; height: 78px; object-fit: contain; }
.panel-nav { display: grid; gap: 5px; padding: 22px 13px; }
.panel-nav a { position: relative; padding: 13px 15px; color: #cfcfcb; border-radius: 5px; text-decoration: none; font-size: 13px; }
.panel-nav a:hover { color: var(--white); background: #202020; }
.panel-nav a.is-active { color: var(--black); background: var(--yellow); font-weight: 700; }
.panel-nav .admin-panel-shortcut { margin-top: 14px; color: var(--white); border: 1px solid #4b4b4b; }
.panel-kind { margin: 15px 17px 0; padding: 8px 9px; color: var(--yellow); border-left: 3px solid var(--yellow); font-size: 9px; font-weight: 700; letter-spacing: .11em; }
.logout-form { margin: auto 13px 17px; }
.logout-form button { width: 100%; min-height: 43px; color: #bbb; background: transparent; border: 1px solid #3a3a3a; border-radius: 4px; }
.logout-form button:hover { color: var(--white); border-color: #777; }

.panel-content { min-width: 0; }
.panel-topbar { position: sticky; z-index: 20; top: 0; display: flex; align-items: center; min-height: 72px; padding: 0 28px; background: rgba(255,255,255,.96); border-bottom: 1px solid var(--line); backdrop-filter: blur(10px); }
.panel-topbar > div { display: grid; }
.panel-topbar strong { font-size: 14px; }
.panel-topbar small { color: var(--muted); font-size: 10px; }
.panel-topbar > a { margin-left: auto; color: var(--muted); text-decoration: none; font-size: 12px; font-weight: 700; }
.panel-topbar > a:hover { color: var(--black); }
.panel-menu-toggle { display: none; }
.panel-main { width: min(1220px, calc(100% - 48px)); margin: 0 auto; padding: 36px 0 64px; }

.panel-page-heading, .surface-heading { display: flex; align-items: end; justify-content: space-between; gap: 24px; margin-bottom: 24px; }
.panel-page-heading h1 { margin: 0; font-family: Georgia, "Times New Roman", serif; font-size: clamp(34px, 4.2vw, 52px); line-height: 1; font-weight: 400; }
.panel-page-heading p, .surface-heading p { margin: 8px 0 0; color: var(--muted); font-size: 13px; }

.panel-button { display: inline-flex; align-items: center; justify-content: center; min-height: 44px; padding: 0 17px; border: 1px solid transparent; border-radius: 4px; text-decoration: none; font-size: 12px; font-weight: 700; }
.panel-button-yellow { color: var(--black); background: var(--yellow); }
.panel-button-dark { color: var(--white); background: var(--black); }
.panel-button-light { color: var(--black); background: var(--white); border-color: var(--line); }
.panel-button-block { width: 100%; }
.panel-button:hover { filter: brightness(.96); }

.panel-alert { margin: 0 0 20px; padding: 13px 15px; background: #fffbe3; border-left: 4px solid var(--yellow); font-size: 13px; }
.panel-alert-success { color: #105c39; background: #eaf8f0; border-color: var(--green); }
.panel-alert-error { color: #7d1b14; background: #fff0ee; border-color: var(--red); }

.stats-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-bottom: 16px; }
.stats-row > div { display: flex; align-items: center; justify-content: space-between; min-height: 92px; padding: 19px 21px; background: var(--white); border: 1px solid var(--line); }
.stats-row span { color: var(--muted); font-size: 12px; }
.stats-row strong { font-family: Georgia, "Times New Roman", serif; font-size: 32px; font-weight: 400; }

.product-filters { display: grid; grid-template-columns: minmax(220px, 1fr) 250px auto; gap: 9px; margin-bottom: 16px; padding: 13px; background: var(--white); border: 1px solid var(--line); }
.product-filters input, .product-filters select { width: 100%; height: 44px; padding: 0 12px; color: var(--black); background: var(--white); border: 1px solid var(--line); border-radius: 3px; }

.product-list { display: grid; gap: 9px; }
.product-row { display: grid; grid-template-columns: 150px minmax(210px, 1fr) 140px minmax(240px, auto); gap: 18px; align-items: center; min-height: 112px; padding: 11px; background: var(--white); border: 1px solid var(--line); }
.product-row-image { aspect-ratio: 16/9; background: #e9e9e7; }
.product-row-image span { display: grid; place-items: center; width: 100%; height: 100%; color: var(--muted); font-size: 11px; }
.product-row-main small { color: var(--muted); font-size: 10px; text-transform: uppercase; letter-spacing: .08em; }
.product-row-main h2 { margin: 4px 0 8px; font-size: 15px; line-height: 1.3; }
.row-badges { display: flex; flex-wrap: wrap; gap: 5px; }
.row-badges span { padding: 3px 7px; border-radius: 20px; font-size: 9px; font-weight: 700; }
.status-live { color: #10613b; background: #e6f7ee; }
.status-hidden { color: #6d6d69; background: #eeeeeb; }
.status-featured { color: var(--black); background: #fff6a8; }
.product-row-price { font-size: 12px; }
.product-row-price span { color: var(--muted); }
.row-actions { display: flex; align-items: center; justify-content: flex-end; flex-wrap: wrap; gap: 5px 10px; }
.row-actions a, .row-actions button, .existing-image-actions button { padding: 0; color: var(--black); background: transparent; border: 0; text-decoration: underline; text-underline-offset: 3px; font-size: 11px; }
.row-actions form, .existing-image-actions form { margin: 0; }
.row-actions .danger-link, .existing-image-actions .danger-link { color: var(--red); }

.panel-surface { margin-bottom: 16px; padding: 24px; background: var(--white); border: 1px solid var(--line); }
.panel-surface h2 { margin: 0 0 21px; font-size: 17px; }
.panel-fields { display: grid; gap: 17px; }
.panel-field { display: grid; gap: 7px; }
.panel-field > span, .category-admin-row label > span { font-size: 12px; font-weight: 700; }
.panel-field input, .panel-field select, .panel-field textarea, .category-admin-row input { width: 100%; min-height: 45px; padding: 10px 12px; color: var(--black); background: var(--white); border: 1px solid #cfcfcb; border-radius: 3px; outline: none; }
.panel-field textarea { resize: vertical; }
.panel-field input:focus, .panel-field select:focus, .panel-field textarea:focus, .category-admin-row input:focus { border-color: var(--black); box-shadow: 0 0 0 2px rgba(229,207,0,.35); }
.panel-field small { color: var(--muted); font-size: 10px; }
.price-fields { display: grid; grid-template-columns: minmax(200px, 1fr) 1fr; gap: 18px; align-items: end; }
.check-row { display: flex; align-items: center; gap: 8px; min-height: 45px; font-size: 12px; }
.check-row input, .setting-row input { width: 18px; height: 18px; accent-color: var(--black); }

.upload-box { position: relative; display: block; overflow: hidden; min-height: 260px; margin-bottom: 18px; background: #ededeb; border: 2px dashed #c7c7c2; cursor: pointer; }
.upload-box:hover { border-color: var(--black); }
.upload-box > input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.upload-preview { position: absolute; inset: 0; display: grid; place-content: center; justify-items: center; gap: 7px; padding: 20px; text-align: center; }
.upload-preview b { font-size: 15px; }
.upload-preview small { max-width: 440px; color: var(--muted); font-size: 11px; }
.upload-preview.has-image { display: block; padding: 0; overflow: hidden; }
.upload-preview.has-image::after, .admin-media.orientation-portrait::after, .admin-media.orientation-square::after { content: ""; position: absolute; z-index: 1; inset: 0; background: rgba(255,255,255,.17); pointer-events: none; }
.upload-preview .preview-blur { position: absolute; z-index: 0; inset: -30px; width: calc(100% + 60px); height: calc(100% + 60px); object-fit: cover; filter: blur(25px); opacity: .5; transform: scale(1.04); }
.upload-preview .preview-main { position: relative; z-index: 2; width: 100%; height: 100%; object-fit: cover; }
.upload-preview.orientation-portrait .preview-main, .upload-preview.orientation-square .preview-main { object-fit: contain; }
.upload-preview .preview-label { position: absolute; z-index: 4; right: 10px; bottom: 10px; padding: 7px 9px; color: var(--white); background: rgba(17,17,17,.86); font-size: 10px; }
.gallery-upload { margin-top: 3px; }
.upload-gallery-preview { display: grid; grid-template-columns: repeat(6, 1fr); gap: 8px; margin-top: 12px; }
.upload-gallery-preview:empty { display: none; }
.upload-gallery-preview figure { position: relative; overflow: hidden; aspect-ratio: 16/9; margin: 0; background: #e8e8e5; }
.upload-gallery-preview img { width: 100%; height: 100%; object-fit: cover; }
.upload-gallery-preview figure.orientation-portrait img, .upload-gallery-preview figure.orientation-square img { object-fit: contain; }
.upload-gallery-preview small { position: absolute; right: 4px; bottom: 4px; padding: 2px 5px; color: var(--white); background: rgba(17,17,17,.82); font-size: 8px; }
.publish-settings { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 24px; }
.setting-row { display: flex; align-items: center; justify-content: space-between; gap: 15px; min-height: 55px; padding: 12px 14px; background: var(--soft); font-size: 12px; font-weight: 700; }
.setting-row span { display: grid; gap: 3px; }
.setting-row small { color: var(--muted); font-size: 10px; font-weight: 400; }
.setting-note { display: grid; gap: 3px; min-height: 55px; padding: 12px 14px; color: var(--muted); background: var(--soft); font-size: 11px; }
.setting-note strong { color: var(--black); font-size: 12px; }
.form-actions { display: flex; justify-content: flex-end; gap: 9px; margin: 20px 0; }

.existing-images { margin-top: 26px; }
.existing-image-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
.existing-image { overflow: hidden; border: 1px solid var(--line); }
.existing-image.is-cover { border-color: var(--yellow); box-shadow: inset 0 0 0 2px var(--yellow); }
.admin-media { position: relative; display: block; overflow: hidden; background: #e9e9e7; }
.admin-media img { position: relative; z-index: 2; width: 100%; height: 100%; object-fit: cover; }
.admin-media.orientation-portrait img, .admin-media.orientation-square img { object-fit: contain; }
.existing-image .admin-media { aspect-ratio: 16/9; }
.existing-image-actions { display: flex; align-items: center; justify-content: space-between; min-height: 42px; padding: 8px 10px; }
.existing-image-actions strong { padding: 3px 7px; background: var(--yellow); font-size: 9px; }

.settings-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.settings-grid .panel-surface { margin: 0; }
.settings-grid .form-actions { grid-column: 1 / -1; margin-top: 0; }
.password-form { margin-top: 28px; }
.password-fields { display: grid; grid-template-columns: 1fr 1fr auto; gap: 12px; align-items: end; }
.category-add form { display: grid; grid-template-columns: 1fr auto; gap: 10px; align-items: end; }
.category-admin-list { display: grid; gap: 8px; }
.category-admin-row { display: grid; grid-template-columns: minmax(220px, 1fr) 90px 110px 80px auto; gap: 12px; align-items: end; padding: 12px; background: var(--soft); }
.category-admin-row label:not(.check-row) { display: grid; gap: 5px; }
.category-count { align-self: center; color: var(--muted); font-size: 11px; text-align: center; }

.panel-empty { padding: 65px 24px; background: var(--white); border: 1px solid var(--line); text-align: center; }
.panel-empty h2 { margin: 0; font-family: Georgia, "Times New Roman", serif; font-size: 34px; font-weight: 400; }
.panel-empty p { color: var(--muted); }

.login-page { display: grid; place-items: center; min-height: 100vh; padding: 22px; background: var(--black); }
.login-box { display: grid; grid-template-columns: 300px minmax(330px, 430px); width: min(760px, 100%); overflow: hidden; background: var(--white); box-shadow: 0 30px 70px rgba(0,0,0,.38); }
.login-box > img { align-self: stretch; width: 100%; height: 100%; padding: 45px 30px; object-fit: contain; background: #080808; }
.login-form-wrap { padding: 42px; }
.login-form-wrap h1 { margin: 0 0 8px; font-family: Georgia, "Times New Roman", serif; font-size: 36px; font-weight: 400; }
.login-form-wrap > p { margin: 0 0 25px; color: var(--muted); font-size: 12px; }
.login-form-wrap form { display: grid; gap: 15px; }
.back-home { display: inline-block; margin-top: 20px; color: var(--muted); text-decoration: none; font-size: 11px; }
.login-kicker { display: block; margin-bottom: 7px; color: #8a7a00; font-size: 9px; font-weight: 700; letter-spacing: .12em; }

.homepage-admin-form { display: grid; gap: 1px; }
.homepage-admin-form .panel-surface { margin-bottom: 15px; }
.color-settings { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.color-field { display: grid; grid-template-columns: 1fr 52px; gap: 5px 12px; align-items: center; padding: 14px; background: var(--soft); border: 1px solid var(--line); }
.color-field > span { display: grid; }
.color-field b { font-size: 12px; }
.color-field small { color: var(--muted); font-size: 9px; }
.color-field input[type="color"] { grid-row: 1 / 3; grid-column: 2; width: 52px; height: 52px; padding: 3px; background: var(--white); border: 1px solid var(--line); cursor: pointer; }
.color-field output { color: var(--muted); font-family: monospace; font-size: 10px; }
.theme-mini-preview { overflow: hidden; margin-top: 14px; border: 1px solid var(--line); }
.preview-topbar { padding: 7px 18px; color: #eee; background: var(--preview-topbar, #111); text-align: center; font-size: 8px; }
.preview-header { display: flex; align-items: center; justify-content: space-between; min-height: 54px; padding: 12px 18px; color: var(--preview-dark, #111); background: var(--preview-header, #fff); font-size: 12px; font-weight: 700; letter-spacing: .06em; }
.preview-header span { font-size: 9px; }
.preview-body { display: flex; align-items: center; justify-content: space-between; gap: 18px; min-height: 105px; padding: 21px; color: var(--preview-dark, #111); background: var(--preview-surface, #f3f3f1); }
.preview-body strong { font-family: Georgia, "Times New Roman", serif; font-size: 25px; font-weight: 400; }
.preview-body button { min-height: 38px; padding: 0 13px; color: var(--preview-dark, #111); background: var(--preview-accent, #feed00); border: 0; font-size: 9px; font-weight: 700; }
.preview-page { padding: 13px 18px; color: var(--preview-dark, #111); background: var(--preview-background, #fff); border-top: 1px solid var(--line); font-family: Georgia,"Times New Roman",serif; font-size: 15px; }
.standalone-setting { max-width: 680px; }
.home-product-slots { display: grid; grid-template-columns: 1fr 1fr; gap: 13px; }
.home-category-settings { display: grid; gap: 9px; }
.home-category-row { display: grid; grid-template-columns: minmax(190px, .7fr) minmax(260px, 1.3fr); gap: 20px; align-items: end; padding: 13px 15px; background: var(--soft); border: 1px solid #e5e5e2; }
.two-column-fields { grid-template-columns: 1fr 1fr; }
.field-span { grid-column: 1 / -1; }
.admin-copy-sections { display: grid; grid-template-columns: 1fr 1fr; gap: 13px; }
.admin-copy-sections fieldset { display: grid; gap: 13px; min-width: 0; margin: 0; padding: 17px; border: 1px solid var(--line); }
.admin-copy-sections legend { padding: 0 7px; font-size: 12px; font-weight: 700; }
.admin-save-bar { position: sticky; z-index: 12; bottom: 10px; padding: 11px; background: rgba(243,243,241,.95); border: 1px solid var(--line); box-shadow: 0 10px 28px rgba(0,0,0,.12); backdrop-filter: blur(8px); }

@media (max-width: 1080px) {
    .product-row { grid-template-columns: 135px minmax(190px, 1fr) 120px; }
    .row-actions { grid-column: 2 / -1; justify-content: flex-start; padding-top: 2px; }
    .existing-image-grid { grid-template-columns: repeat(3, 1fr); }
}

@media (max-width: 820px) {
    .panel-shell { display: block; }
    .panel-sidebar { position: fixed; left: 0; width: min(290px, 86vw); transform: translateX(-102%); transition: transform .22s ease; box-shadow: 20px 0 40px rgba(0,0,0,.28); }
    .panel-sidebar.is-open { transform: translateX(0); }
    .panel-topbar { min-height: 64px; padding-inline: 15px; }
    .panel-menu-toggle { display: inline-flex; align-items: center; justify-content: center; min-height: 40px; margin-right: 12px; padding: 0 12px; color: var(--white); background: var(--black); border: 0; border-radius: 3px; font-size: 11px; font-weight: 700; }
    .panel-main { width: min(100% - 30px, 700px); padding-top: 25px; }
    .settings-grid { grid-template-columns: 1fr; }
    .color-settings { grid-template-columns: 1fr; }
    .admin-copy-sections { grid-template-columns: 1fr; }
    .settings-grid .form-actions { grid-column: auto; }
    .password-fields { grid-template-columns: 1fr; }
    .category-admin-row { grid-template-columns: 1fr 80px; }
    .category-admin-row .check-row, .category-admin-row .category-count { justify-self: start; text-align: left; }
    .category-admin-row button { justify-self: end; }
    .login-box { grid-template-columns: 1fr; max-width: 450px; }
    .login-box > img { height: 150px; padding: 20px 65px; }
}

@media (max-width: 620px) {
    .panel-topbar > div { display: none; }
    .panel-main { width: calc(100% - 22px); }
    .panel-page-heading { align-items: stretch; flex-direction: column; }
    .stats-row { grid-template-columns: 1fr; }
    .stats-row > div { min-height: 68px; }
    .product-filters { grid-template-columns: 1fr; }
    .product-row { grid-template-columns: 110px minmax(0,1fr); gap: 12px; }
    .product-row-price { grid-column: 2; }
    .row-actions { grid-column: 1 / -1; padding: 8px 3px 2px; }
    .panel-surface { padding: 18px; }
    .price-fields, .publish-settings { grid-template-columns: 1fr; }
    .home-product-slots, .two-column-fields { grid-template-columns: 1fr; }
    .field-span { grid-column: auto; }
    .home-category-row { grid-template-columns: 1fr; gap: 7px; }
    .upload-box { min-height: 220px; }
    .upload-gallery-preview { grid-template-columns: repeat(3,1fr); }
    .existing-image-grid { grid-template-columns: 1fr 1fr; }
    .category-add form { grid-template-columns: 1fr; }
    .category-admin-row { grid-template-columns: 1fr 70px; }
    .category-admin-row .check-row, .category-admin-row .category-count, .category-admin-row button { justify-self: start; }
    .form-actions { position: sticky; z-index: 10; bottom: 8px; padding: 9px; background: rgba(243,243,241,.94); backdrop-filter: blur(8px); }
    .login-page { padding: 12px; }
    .login-form-wrap { padding: 27px 22px; }
}
