@font-face {
    font-family: "Vazir";
    src: url("../fonts/vazir/Vazir-Regular.woff2") format("woff2");
    font-weight: 400;
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: "Vazir";
    src: url("../fonts/vazir/Vazir-Medium.woff2") format("woff2");
    font-weight: 500;
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: "Vazir";
    src: url("../fonts/vazir/Vazir-Bold.woff2") format("woff2");
    font-weight: 700;
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: "Vazir";
    src: url("../fonts/vazir/Vazir-Black.woff2") format("woff2");
    font-weight: 800 900;
    font-style: normal;
    font-display: swap;
}

:root {
    --ink: #18201f;
    --muted: #66706e;
    --line: #dfe4e2;
    --paper: #ffffff;
    --soft: #f4f7f6;
    --green: #12665a;
    --green-dark: #0d4e46;
    --red: #b33a34;
    --amber: #a76816;
    --shadow: 0 12px 32px rgba(20, 39, 35, .08);
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
    margin: 0;
    color: var(--ink);
    background: var(--paper);
    font-family: "Vazir", Tahoma, Arial, sans-serif;
    line-height: 1.7;
    letter-spacing: 0;
}

button, input, textarea, select { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
img { display: block; max-width: 100%; }
a { color: inherit; text-decoration: none; }

.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;
}

.topbar {
    min-height: 72px;
    padding: 10px clamp(18px, 4vw, 64px);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
    background: rgba(255, 255, 255, .97);
    border-bottom: 1px solid var(--line);
    position: sticky;
    top: 0;
    z-index: 50;
}

.brand {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
}

.brand-mark {
    display: grid;
    place-items: center;
    flex: 0 0 42px;
    width: 42px;
    height: 42px;
    color: #fff;
    background: var(--green);
    border: 3px solid #dceeea;
    border-radius: 50%;
    font-size: 23px;
    font-weight: 800;
}

.brand-mark.large { width: 58px; height: 58px; font-size: 30px; margin-inline: auto; }
.brand strong, .brand small { display: block; }
.brand strong { font-size: 15px; }
.brand small { color: var(--muted); font-size: 10px; margin-top: -2px; }

.icon-link, .icon-button {
    display: inline-grid;
    place-items: center;
    width: 40px;
    height: 40px;
    padding: 0;
    color: var(--ink);
    background: var(--soft);
    border: 1px solid var(--line);
    border-radius: 6px;
    cursor: pointer;
    font-size: 21px;
}

.icon-link:hover, .icon-button:hover { border-color: var(--green); color: var(--green); }
.icon-button.danger:hover { border-color: var(--red); color: var(--red); }

.catalog-intro {
    position: relative;
    height: min(54vh, 540px);
    min-height: 390px;
    overflow: hidden;
    color: #fff;
    background: #27302d;
}

.catalog-intro::after {
    content: "";
    position: absolute;
    inset: 0;
    background: rgba(7, 22, 19, .35);
}

.catalog-intro img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center 52%;
}

.catalog-intro-copy {
    position: absolute;
    z-index: 2;
    right: clamp(20px, 8vw, 120px);
    bottom: clamp(28px, 7vw, 80px);
    max-width: 560px;
    text-shadow: 0 2px 16px rgba(0, 0, 0, .28);
}

.catalog-intro-copy span {
    display: inline-block;
    padding-bottom: 7px;
    border-bottom: 3px solid #d3a644;
    font-weight: 700;
    font-size: 13px;
}

.catalog-intro-copy h1 {
    margin: 12px 0 6px;
    font-size: clamp(34px, 6vw, 70px);
    line-height: 1.25;
}

.catalog-intro-copy p { margin: 0; font-size: clamp(15px, 2vw, 20px); }

.catalog-shell, .product-page, .admin-main {
    width: min(1240px, calc(100% - 36px));
    margin-inline: auto;
}

.catalog-shell { padding: 46px 0 80px; }

.catalog-heading, .admin-title-row {
    display: flex;
    align-items: end;
    justify-content: space-between;
    gap: 24px;
    margin-bottom: 28px;
}

.catalog-heading h2, .admin-title-row h1 {
    margin: 0 0 2px;
    font-size: clamp(24px, 3vw, 36px);
    line-height: 1.4;
}

.catalog-heading p, .admin-title-row p { margin: 0; color: var(--muted); }

.search-form {
    display: grid;
    grid-template-columns: minmax(0, 250px) 44px;
    border: 1px solid var(--line);
    border-radius: 6px;
    overflow: hidden;
    background: #fff;
}

.search-form:focus-within { border-color: var(--green); box-shadow: 0 0 0 3px rgba(18, 102, 90, .1); }
.search-form input { min-width: 0; padding: 10px 13px; border: 0; outline: 0; background: transparent; }
.search-form button { border: 0; border-right: 1px solid var(--line); color: var(--green); background: var(--soft); cursor: pointer; font-size: 22px; }

.category-filters {
    display: flex;
    gap: 8px;
    margin: -8px 0 26px;
    padding-bottom: 4px;
    overflow-x: auto;
    scrollbar-width: thin;
}
.category-filters a {
    flex: 0 0 auto;
    padding: 7px 13px;
    border: 1px solid var(--line);
    border-radius: 5px;
    color: var(--muted);
    background: #fff;
    font-size: 12px;
}
.category-filters a:hover { color: var(--green); border-color: var(--green); }
.category-filters a.active { color: #fff; border-color: var(--green); background: var(--green); font-weight: 700; }

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

.product-card {
    min-width: 0;
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
    transition: transform .2s ease, box-shadow .2s ease;
}

.product-card:hover { transform: translateY(-3px); box-shadow: var(--shadow); }
.product-image { display: block; position: relative; aspect-ratio: 4 / 3; overflow: hidden; background: var(--soft); }
.product-image img { width: 100%; height: 100%; object-fit: cover; transition: transform .35s ease; }
.product-card:hover .product-image img { transform: scale(1.025); }

.stock-badge {
    position: absolute;
    top: 12px;
    right: 12px;
    padding: 5px 9px;
    color: #fff;
    background: var(--red);
    border-radius: 4px;
    font-size: 11px;
    font-weight: 700;
}

.product-card-copy { padding: 18px; }
.eyebrow { color: var(--green); font-size: 11px; font-weight: 700; }
.product-card-copy .eyebrow { margin: 0 0 4px; }
.product-card h3 { margin: 0; font-size: 19px; line-height: 1.5; }
.product-card h3 a:hover { color: var(--green); }
.product-card-copy > p:not(.eyebrow) { min-height: 52px; margin: 7px 0 18px; color: var(--muted); font-size: 13px; }
.product-card-footer { display: flex; align-items: center; justify-content: space-between; padding-top: 14px; border-top: 1px solid var(--line); }
.product-card-footer strong { font-size: 18px; }
.arrow-link { color: var(--green); font-size: 24px; line-height: 1; }

.empty-state {
    padding: 70px 20px;
    text-align: center;
    border: 1px dashed #b7c4c1;
    background: var(--soft);
    border-radius: 8px;
}
.empty-state strong { display: block; font-size: 21px; }
.empty-state p { margin: 5px 0 20px; color: var(--muted); }

.button {
    display: inline-flex;
    min-height: 44px;
    padding: 9px 18px;
    align-items: center;
    justify-content: center;
    gap: 8px;
    border: 1px solid var(--green);
    border-radius: 6px;
    color: #fff;
    background: var(--green);
    font-weight: 700;
    cursor: pointer;
}
.button:hover { background: var(--green-dark); }
.button.secondary { color: var(--ink); background: #fff; border-color: var(--line); }
.button.secondary:hover { color: var(--green); border-color: var(--green); }

.footer {
    display: flex;
    justify-content: space-between;
    gap: 20px;
    padding: 24px clamp(18px, 4vw, 64px);
    color: #d4dcda;
    background: #17201e;
    font-size: 12px;
}

.product-page { padding: 34px 0 80px; }
.back-link { display: inline-block; margin-bottom: 22px; color: var(--muted); font-size: 13px; }
.back-link:hover { color: var(--green); }
.product-detail { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(330px, .9fr); gap: clamp(32px, 6vw, 78px); align-items: start; }
.gallery-main { aspect-ratio: 1 / 1; overflow: hidden; background: var(--soft); border: 1px solid var(--line); border-radius: 8px; }
.gallery-main img { width: 100%; height: 100%; object-fit: cover; }
.gallery-thumbs { display: grid; grid-template-columns: repeat(5, 72px); gap: 10px; margin-top: 12px; }
.gallery-thumb { width: 72px; height: 72px; padding: 3px; border: 1px solid var(--line); border-radius: 6px; background: #fff; cursor: pointer; }
.gallery-thumb.active { border: 2px solid var(--green); padding: 2px; }
.gallery-thumb img { width: 100%; height: 100%; object-fit: cover; border-radius: 3px; }
.product-info { padding-top: 16px; }
.category-link {
    display: inline-block;
    margin-bottom: 5px;
    color: var(--green);
    font-size: 12px;
    font-weight: 700;
}
.category-link:hover { text-decoration: underline; }
.product-info h1 { margin: 4px 0 12px; font-size: clamp(30px, 4vw, 46px); line-height: 1.35; }
.lead { margin: 0 0 22px; color: var(--muted); font-size: 16px; }
.price-row { display: flex; align-items: center; justify-content: space-between; gap: 15px; padding: 18px 0; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.price-row > strong { font-size: 26px; }
.available { color: var(--green); font-size: 13px; font-weight: 700; }
.available::before { content: ""; display: inline-block; width: 8px; height: 8px; margin-left: 6px; border-radius: 50%; background: #2a9d69; }
.product-description { margin-top: 26px; }
.prose { overflow-wrap: anywhere; }
.prose h2, .prose h3 { margin-top: 1.4em; line-height: 1.5; }
.prose p { margin: .7em 0; }
.prose ul, .prose ol { padding-right: 24px; }
.prose img { height: auto; border-radius: 6px; }
.prose a { color: var(--green); text-decoration: underline; }

.auth-page {
    min-height: calc(100vh - 145px);
    display: grid;
    place-items: center;
    padding: 40px 18px;
    background: var(--soft);
}
.auth-panel { width: min(100%, 430px); padding: clamp(25px, 5vw, 42px); background: #fff; border: 1px solid var(--line); border-radius: 8px; box-shadow: var(--shadow); }
.auth-heading { text-align: center; margin-bottom: 26px; }
.auth-heading h1 { margin: 12px 0 2px; font-size: 25px; }
.auth-heading p { margin: 0; color: var(--muted); font-size: 13px; }

.stack-form { display: grid; gap: 18px; }
label { color: #323b39; font-size: 13px; font-weight: 700; }
input:not([type="checkbox"]):not([type="file"]), textarea, select {
    display: block;
    width: 100%;
    margin-top: 6px;
    padding: 11px 12px;
    border: 1px solid #cbd3d1;
    border-radius: 5px;
    outline: 0;
    color: var(--ink);
    background: #fff;
}
textarea { resize: vertical; }
input:focus, textarea:focus, select:focus { border-color: var(--green); box-shadow: 0 0 0 3px rgba(18, 102, 90, .1); }
.form-error { width: min(1240px, calc(100% - 36px)); margin: 18px auto; padding: 12px 14px; color: #7c231f; background: #fff1ef; border: 1px solid #edc1bd; border-radius: 6px; font-size: 13px; }
.form-error p { margin: 3px 0; }
.flash { position: fixed; z-index: 100; left: 18px; bottom: 18px; max-width: min(420px, calc(100% - 36px)); padding: 12px 16px; border-radius: 6px; box-shadow: var(--shadow); font-size: 13px; animation: flash-in .25s ease; }
.flash-success { color: #0d4e46; background: #e8f6f1; border: 1px solid #a7d9ca; }
.flash-error { color: #7c231f; background: #fff1ef; border: 1px solid #edc1bd; }
@keyframes flash-in { from { opacity: 0; transform: translateY(8px); } }

.admin-body { background: var(--soft); }
.admin-nav { display: flex; align-items: center; gap: 6px; }
.admin-nav a { padding: 7px 10px; border-radius: 4px; color: var(--muted); font-size: 12px; }
.admin-nav a:hover { color: var(--green); background: #eef5f3; }
.admin-main { min-height: calc(100vh - 145px); padding: 42px 0 80px; }
.admin-title-row .eyebrow { margin-bottom: 1px; }
.stats-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 22px; }
.stats-grid > div { display: flex; min-height: 92px; padding: 16px; align-items: center; justify-content: space-between; gap: 12px; border: 1px solid var(--line); border-radius: 7px; background: #fff; }
.stats-grid span { color: var(--muted); font-size: 12px; }
.stats-grid strong { font-size: 25px; color: var(--green); }
.admin-list, .form-section { border: 1px solid var(--line); border-radius: 8px; background: #fff; }
.list-head { display: flex; align-items: center; justify-content: space-between; padding: 17px 20px; border-bottom: 1px solid var(--line); }
.list-head h2 { margin: 0; font-size: 17px; }
.list-head span { color: var(--muted); font-size: 12px; }
.admin-product-row { display: grid; grid-template-columns: minmax(250px, 1.5fr) minmax(105px, .5fr) 90px 100px 112px; gap: 20px; padding: 14px 18px; align-items: center; border-bottom: 1px solid var(--line); }
.admin-product-row:last-child { border-bottom: 0; }
.admin-product-main { display: flex; align-items: center; min-width: 0; gap: 12px; }
.admin-product-main img, .image-placeholder { flex: 0 0 62px; width: 62px; height: 62px; border-radius: 5px; object-fit: cover; background: var(--soft); }
.image-placeholder { display: grid; place-items: center; color: var(--muted); text-align: center; font-size: 9px; }
.admin-product-main h3 { margin: 0; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; font-size: 14px; }
.admin-product-main p { margin: 1px 0 0; color: var(--muted); font-size: 10px; }
.row-metric span, .row-metric strong { display: block; }
.row-metric span { color: var(--muted); font-size: 10px; }
.row-metric strong { font-size: 13px; }
.status { justify-self: start; padding: 4px 8px; color: #6c3c08; background: #fff1dc; border-radius: 4px; font-size: 10px; font-weight: 700; }
.status.active { color: #0e594b; background: #e4f4ef; }
.row-actions { display: flex; gap: 6px; justify-content: end; }
.row-actions form { margin: 0; }
.row-actions .icon-button { width: 32px; height: 32px; font-size: 17px; }

.category-admin-layout {
    display: grid;
    grid-template-columns: minmax(280px, .7fr) minmax(0, 1.3fr);
    gap: 18px;
    align-items: start;
}
.category-form { position: sticky; top: 94px; }
.category-form-actions { display: flex; gap: 8px; }
.category-form-actions .button { flex: 1; }
.category-row {
    display: grid;
    grid-template-columns: minmax(180px, 1fr) 80px 80px 82px;
    gap: 18px;
    padding: 15px 18px;
    align-items: center;
    border-bottom: 1px solid var(--line);
}
.category-row:last-child { border-bottom: 0; }
.category-row h3 { margin: 0; font-size: 14px; }
.category-row p { margin: 1px 0 0; color: var(--muted); font-size: 10px; }

.product-form { display: grid; gap: 18px; }
.form-section { padding: clamp(18px, 3vw, 28px); }
.section-heading { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; margin-bottom: 20px; padding-bottom: 12px; border-bottom: 1px solid var(--line); }
.section-heading h2 { margin: 0; font-size: 17px; }
.section-heading span { color: var(--muted); font-size: 11px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
.span-2 { grid-column: 1 / -1; }

.editor { overflow: hidden; border: 1px solid #cbd3d1; border-radius: 6px; }
.editor-tabs { display: flex; background: var(--soft); border-bottom: 1px solid var(--line); }
.editor-tabs button { padding: 9px 13px; color: var(--muted); background: transparent; border: 0; border-left: 1px solid var(--line); cursor: pointer; font-size: 11px; }
.editor-tabs button.active { color: var(--green); background: #fff; font-weight: 700; }
.editor-toolbar { display: flex; gap: 4px; padding: 7px; border-bottom: 1px solid var(--line); }
.editor-toolbar button { min-width: 32px; height: 30px; padding: 0 6px; border: 1px solid var(--line); border-radius: 4px; background: #fff; cursor: pointer; }
.visual-editor, .source-editor { width: 100%; min-height: 280px; padding: 18px; border: 0; outline: 0; }
.source-editor { display: none; margin: 0; border-radius: 0; direction: ltr; text-align: left; font-family: Consolas, monospace; font-size: 13px; }
.editor.source-mode .visual-editor, .editor.source-mode .editor-toolbar { display: none; }
.editor.source-mode .source-editor { display: block; }

.existing-images { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 12px; margin-bottom: 16px; }
.existing-image { position: relative; overflow: hidden; aspect-ratio: 1 / 1; border: 1px solid var(--line); border-radius: 6px; }
.existing-image img { width: 100%; height: 100%; object-fit: cover; }
.existing-image span { position: absolute; right: 5px; left: 5px; bottom: 5px; padding: 5px; color: #fff; background: rgba(25, 31, 30, .82); border-radius: 4px; font-size: 9px; text-align: center; }
.upload-zone { display: grid; min-height: 130px; place-items: center; align-content: center; gap: 3px; border: 1px dashed #9eafab; border-radius: 6px; color: var(--green); background: #f7fbfa; cursor: pointer; text-align: center; }
.upload-zone input { width: 1px; height: 1px; opacity: 0; position: absolute; }
.upload-zone span { color: var(--muted); font-size: 10px; }
.upload-zone.has-files { border-style: solid; border-color: var(--green); background: #eef8f5; }

.toggle-row { display: flex; min-height: 66px; padding: 10px 12px; align-items: center; justify-content: space-between; gap: 15px; border: 1px solid var(--line); border-radius: 6px; }
.toggle-row span, .toggle-row strong, .toggle-row small { display: block; }
.toggle-row small { max-width: 430px; color: var(--muted); font-weight: 400; line-height: 1.5; }
.toggle-row input { width: 44px; height: 24px; accent-color: var(--green); cursor: pointer; }
.pricing-formula {
    padding: 14px;
    border-right: 3px solid var(--green);
    color: var(--muted);
    background: var(--soft);
    border-radius: 5px;
}
.pricing-formula span, .pricing-formula strong { display: block; }
.pricing-formula span { font-size: 10px; }
.pricing-formula strong { margin-top: 3px; color: var(--ink); font-size: 12px; overflow-wrap: anywhere; }
.form-actions { display: flex; justify-content: end; gap: 10px; padding-top: 5px; }
.narrow { width: min(620px, calc(100% - 36px)); }
.narrow .form-error { width: 100%; }

@media (max-width: 900px) {
    .product-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .product-detail { grid-template-columns: 1fr; }
    .product-info { padding-top: 0; }
    .stats-grid { grid-template-columns: repeat(2, 1fr); }
    .admin-product-row { grid-template-columns: minmax(220px, 1fr) 100px 90px 100px; }
    .admin-product-row .row-metric:first-of-type { display: none; }
    .existing-images { grid-template-columns: repeat(4, 1fr); }
    .category-admin-layout { grid-template-columns: 1fr; }
    .category-form { position: static; }
}

@media (max-width: 680px) {
    .topbar { min-height: 62px; padding: 8px 14px; }
    .brand-mark { flex-basis: 38px; width: 38px; height: 38px; font-size: 20px; }
    .brand small { display: none; }
    .catalog-intro { height: 51vh; min-height: 360px; }
    .catalog-intro img { object-position: 57% center; }
    .catalog-intro-copy { right: 18px; left: 18px; bottom: 26px; }
    .catalog-intro-copy h1 { font-size: 35px; }
    .catalog-shell, .product-page, .admin-main { width: min(100% - 28px, 1240px); }
    .catalog-shell { padding: 30px 0 60px; }
    .catalog-heading, .admin-title-row { align-items: stretch; flex-direction: column; gap: 15px; }
    .search-form { grid-template-columns: minmax(0, 1fr) 44px; width: 100%; }
    .category-filters {
        margin-top: -4px;
        margin-inline: -14px;
        padding-inline: 14px;
    }
    .product-grid { grid-template-columns: 1fr; gap: 16px; }
    .product-card { display: grid; grid-template-columns: 42% minmax(0, 1fr); min-height: 190px; }
    .product-image { height: 100%; min-height: 190px; aspect-ratio: auto; }
    .product-card-copy { display: flex; min-width: 0; padding: 13px; flex-direction: column; }
    .product-card h3 { font-size: 16px; }
    .product-card-copy > p:not(.eyebrow) { min-height: 0; margin: 5px 0 10px; font-size: 11px; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
    .product-card-footer { margin-top: auto; padding-top: 10px; }
    .product-card-footer strong { font-size: 15px; }
    .stock-badge { top: 8px; right: 8px; font-size: 9px; }
    .footer { flex-direction: column; gap: 2px; }
    .product-page { padding-top: 20px; }
    .gallery-thumbs { grid-template-columns: repeat(4, 58px); }
    .gallery-thumb { width: 58px; height: 58px; }
    .product-info h1 { font-size: 29px; }
    .admin-nav { max-width: 58vw; overflow-x: auto; justify-content: start; }
    .admin-nav a { white-space: nowrap; }
    .admin-title-row .button { width: 100%; }
    .stats-grid { gap: 8px; }
    .stats-grid > div { min-height: 78px; padding: 12px; }
    .stats-grid strong { font-size: 21px; }
    .admin-list { border: 0; background: transparent; }
    .list-head { padding: 0 0 12px; }
    .admin-product-row { grid-template-columns: 1fr auto; gap: 9px 14px; margin-bottom: 10px; padding: 13px; border: 1px solid var(--line); border-radius: 7px; background: #fff; }
    .admin-product-main { grid-column: 1 / -1; }
    .admin-product-main img, .image-placeholder { flex-basis: 56px; width: 56px; height: 56px; }
    .admin-product-row .row-metric { display: block; }
    .admin-product-row .row-metric:first-of-type { display: none; }
    .status { align-self: center; }
    .row-actions { grid-column: 2; grid-row: 2; }
    .category-row {
        grid-template-columns: 1fr auto;
        gap: 9px 14px;
        margin-bottom: 10px;
        padding: 13px;
        border: 1px solid var(--line);
        border-radius: 7px;
        background: #fff;
    }
    .category-row > div:first-child { grid-column: 1 / -1; }
    .category-row .row-metric { display: none; }
    .category-row .row-actions { grid-column: 2; grid-row: 2; }
    .form-grid { grid-template-columns: 1fr; }
    .span-2 { grid-column: auto; }
    .existing-images { grid-template-columns: repeat(2, 1fr); }
    .toggle-row { align-items: flex-start; }
    .section-heading { align-items: flex-start; flex-direction: column; gap: 2px; }
    .form-actions { position: sticky; bottom: 0; z-index: 20; margin-inline: -14px; padding: 10px 14px; background: rgba(244, 247, 246, .96); border-top: 1px solid var(--line); }
    .form-actions .button { flex: 1; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; animation: none !important; }
}
