:root {
    font-family: "Vazirmatn", Tahoma, "Segoe UI", sans-serif;
    color: #1d2b29;
    background: #f4f7f6;
    font-synthesis: none;
    --ink: #1d2b29;
    --muted: #778581;
    --line: #e7edeb;
    --surface: #ffffff;
    --canvas: #f4f7f6;
    --brand: #167c68;
    --brand-dark: #116653;
    --nav: #172d2a;
}

@font-face {
    font-family: "Vazirmatn";
    src: url("../fonts/Vazirmatn-Variable.woff2") format("woff2");
    font-style: normal;
    font-weight: 100 900;
    font-display: swap;
}

* { box-sizing: border-box; }
html { font-family: "Vazirmatn", Tahoma, "Segoe UI", sans-serif; }
body { margin: 0; min-height: 100vh; background: var(--canvas); color: var(--ink); font-family: "Vazirmatn", Tahoma, "Segoe UI", sans-serif; font-size: 14px; }
a { color: var(--brand); }
a:hover { color: var(--brand-dark); }
button, input, select, textarea { font: inherit; }

.topbar {
    position: sticky;
    top: 0;
    z-index: 40;
    height: 72px;
    padding: 0 30px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 22px;
    color: #fff;
    background: #fff;
    border-bottom: 1px solid var(--line);
}
.topbar-start, .topbar-tools, .brand, .user-menu { display: flex; align-items: center; }
.topbar-start { gap: 15px; }
.topbar-tools { gap: 28px; }
.brand { gap: 11px; color: var(--ink); text-decoration: none; font-size: 16px; font-weight: 800; white-space: nowrap; }
.brand:hover { color: var(--ink); }
.brand-mark { width: 39px; height: 39px; display: grid; place-items: center; border-radius: 13px; color: #fff; background: var(--brand); font-size: 19px; box-shadow: 0 5px 12px #167c6826; }
.topbar-search { width: min(340px, 34vw); height: 40px; display: flex; align-items: center; gap: 9px; padding: 0 11px; border: 1px solid var(--line); border-radius: 11px; color: #8b9793; background: #f8faf9; }
.svg-sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
.icon { width: 20px; height: 20px; flex: 0 0 auto; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.search-icon { width: 18px; height: 18px; }
.topbar-search input { min-width: 0; flex: 1; border: 0; outline: 0; color: var(--ink); background: transparent; }
.topbar-search input::placeholder { color: #9aa6a2; }
.topbar-search button { padding: 5px 8px; border: 0; border-radius: 7px; color: var(--brand); background: #e9f4f0; font-size: 11px; font-weight: 700; }
.user-menu { gap: 9px; color: #52615d; white-space: nowrap; }
.user-avatar { width: 34px; height: 34px; display: grid; place-items: center; border-radius: 50%; color: var(--brand-dark); background: #e4f1ed; font-weight: 800; }
.user-name { max-width: 130px; overflow: hidden; text-overflow: ellipsis; }
.user-menu form { margin: 0; }
.logout-button { padding: 7px 11px; border: 1px solid var(--line); border-radius: 8px; color: #65736f; background: #fff; font-size: 12px; }
.logout-button:hover { color: #a13b3b; border-color: #efdada; background: #fff8f8; }
.menu-toggle { display: none; }

.app-shell { display: grid; grid-template-columns: 252px minmax(0, 1fr); min-height: calc(100vh - 72px); }
.sidebar { position: sticky; top: 72px; height: calc(100vh - 72px); display: flex; flex-direction: column; overflow-y: auto; padding: 25px 15px 16px; color: #c0cfcb; background: var(--nav); }
.sidebar-caption { padding: 0 13px 10px; color: #829a94; font-size: 11px; font-weight: 700; }
.sidebar-caption-spaced { margin-top: 25px; }
.sidebar-nav { display: grid; gap: 4px; }
.sidebar-nav a { min-height: 43px; display: flex; align-items: center; gap: 12px; padding: 9px 13px; border-radius: 10px; color: #c2d0cc; text-decoration: none; transition: background .16s ease, color .16s ease; }
.sidebar-nav a:hover { color: #fff; background: #ffffff0e; }
.sidebar-nav a.active { color: #fff; background: #258b75; box-shadow: inset 3px 0 #a6e4d4; }
.nav-icon { width: 19px; height: 19px; color: #92aaa4; }
.sidebar-nav a.active .nav-icon { color: #d6fff3; }
.sidebar-footer { display: flex; align-items: center; gap: 9px; margin: auto 10px 4px; padding: 18px 7px 0; border-top: 1px solid #ffffff16; color: #8fa39e; font-size: 11px; }
.online-dot { width: 8px; height: 8px; border-radius: 50%; background: #4dc599; box-shadow: 0 0 0 4px #4dc5991c; }
.sidebar-backdrop { display: none; }
.main-content { width: 100%; max-width: 1600px; margin: 0 auto; padding: 32px clamp(20px, 3vw, 44px) 48px; }

.page-head { display: flex; align-items: center; justify-content: space-between; gap: 18px; margin-bottom: 25px; }
.page-head h1 { margin: 0; color: var(--ink); font-size: 24px; font-weight: 800; letter-spacing: -.35px; }
.page-head p { margin: 7px 0 0; color: var(--muted); line-height: 1.8; }
.eyebrow { display: block; margin-bottom: 7px; color: var(--brand); font-size: 11px; font-weight: 800; }
.dashboard-heading { margin-bottom: 24px; }
.dashboard-heading h1 { font-size: 27px; }
.dashboard-heading .btn { display: inline-flex; align-items: center; gap: 8px; min-height: 43px; padding-inline: 17px; }

.btn { border-radius: 9px; font-weight: 700; transition: background .15s ease, border-color .15s ease, transform .15s ease; }
.btn:active { transform: translateY(1px); }
.btn-primary { color: #fff; background: var(--brand); border-color: var(--brand); }
.btn-primary:hover, .btn-primary:focus { color: #fff; background: var(--brand-dark); border-color: var(--brand-dark); }
.btn-outline-primary { color: var(--brand); border-color: #c8ded7; }
.btn-outline-primary:hover { color: #fff; border-color: var(--brand); background: var(--brand); }
.btn-outline-secondary { color: #53615d; border-color: #dce5e1; }
.btn-outline-secondary:hover { color: var(--ink); border-color: #bdcbc6; background: #f5f8f7; }
.btn-outline-danger { border-color: #efd4d4; }
.btn-sm { border-radius: 8px; }

.panel, .quick-access { margin-bottom: 20px; padding: 22px; border: 1px solid var(--line); border-radius: 15px; background: var(--surface); box-shadow: 0 4px 15px #243b3510; }
.panel h2, .quick-access h2 { margin: 0; color: var(--ink); font-size: 16px; font-weight: 800; }
.panel > h2 { margin-bottom: 16px; }
.panel form > h2 { margin: 21px 0 14px; }
.panel form > h2:first-of-type { margin-top: 0; }
.section-head h2 { margin: 0; }
.section-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 17px; }
.section-head p { margin: 6px 0 0; color: var(--muted); font-size: 12px; }
.text-link { color: var(--brand); font-size: 12px; font-weight: 800; text-decoration: none; white-space: nowrap; }
.text-link:hover { color: var(--brand-dark); }

.stats-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 15px; margin-bottom: 19px; }
.stat-card { position: relative; min-height: 165px; overflow: hidden; display: flex; flex-direction: column; align-items: flex-start; padding: 19px; border: 1px solid var(--line); border-radius: 15px; color: var(--ink); background: #fff; box-shadow: 0 4px 15px #243b3509; text-decoration: none; transition: transform .18s ease, box-shadow .18s ease; }
.stat-card:hover { color: var(--ink); transform: translateY(-2px); box-shadow: 0 10px 24px #243b3514; }
.stat-icon { position: absolute; top: 17px; left: 17px; width: 39px; height: 39px; display: grid; place-items: center; border-radius: 12px; color: #167c68; background: #e9f5f1; }
.stat-icon .icon { width: 20px; height: 20px; }
.stat-orders .stat-icon { color: #5974c6; background: #eef1fc; }
.stat-stock .stat-icon { color: #c08230; background: #fff4e4; }
.stat-categories .stat-icon { color: #9460b1; background: #f5edfa; }
.stat-label { color: #74817d; font-size: 12px; font-weight: 700; }
.stat-card > strong { margin-top: 11px; color: var(--ink); font-size: 29px; font-weight: 800; line-height: 1.1; }
.stat-foot { display: flex; align-items: center; gap: 6px; margin-top: auto; padding-top: 13px; color: #8a9692; font-size: 10px; }
.stat-foot .icon { width: 14px; height: 14px; color: var(--brand); }

.dashboard-grid { display: grid; grid-template-columns: minmax(0, 1.45fr) minmax(300px, .85fr); gap: 18px; align-items: stretch; }
.dashboard-panel { min-width: 0; margin-bottom: 19px; }
.dashboard-panel .table-responsive { margin: 0 -8px; }
.dashboard-table { min-width: 610px; }
.dashboard-table td:first-child small, .dashboard-table td:nth-child(2) small { display: block; }
.dashboard-table td small { margin-top: 5px; color: #929e9a; font-size: 10px; }
.dashboard-table td .currency { display: inline; margin: 0; }
.order-number { color: #40534d; font-size: 12px; font-weight: 700; }
.stock-list { display: grid; }
.stock-row { min-height: 67px; display: grid; grid-template-columns: minmax(0,1fr) auto 34px; align-items: center; gap: 11px; border-bottom: 1px solid #edf1ef; }
.stock-row:last-child { border-bottom: 0; }
.stock-product { min-width: 0; display: grid; gap: 5px; }
.stock-product strong { overflow: hidden; color: #33423e; font-size: 12px; text-overflow: ellipsis; white-space: nowrap; }
.stock-product .code { color: #98a39f; font-size: 10px; }
.stock-quantity { display: grid; justify-items: center; gap: 2px; min-width: 45px; color: #ad772e; }
.stock-quantity strong { font-size: 14px; }
.stock-quantity span { color: #99a49f; font-size: 9px; }
.stock-quantity.is-empty { color: #c45b5b; }
.icon-link { width: 32px; height: 32px; display: grid; place-items: center; border-radius: 9px; color: var(--brand); background: #eff7f4; text-decoration: none; }
.icon-link .icon { width: 16px; height: 16px; }
.icon-link:hover { color: #fff; background: var(--brand); }
.empty-state { min-height: 170px; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 22px 10px; color: #8b9893; text-align: center; }
.empty-state > span { width: 39px; height: 39px; display: grid; place-items: center; margin-bottom: 10px; border-radius: 50%; color: var(--brand); background: #eaf5f1; }
.empty-state > span .icon { width: 19px; height: 19px; }
.empty-state strong { color: #465651; font-size: 12px; }
.empty-state p { margin: 6px 0 0; font-size: 11px; }

.quick-access { padding-bottom: 19px; }
.quick-grid { display: grid; grid-template-columns: repeat(4, minmax(0,1fr)); gap: 10px; }
.quick-card { min-width: 0; display: flex; align-items: center; gap: 11px; padding: 13px; border: 1px solid #edf1ef; border-radius: 11px; color: var(--ink); background: #fff; text-decoration: none; transition: border-color .15s ease, background .15s ease; }
.quick-card:hover { color: var(--ink); border-color: #cfe2db; background: #fbfdfc; }
.quick-icon { width: 36px; height: 36px; flex: 0 0 36px; display: grid; place-items: center; border-radius: 10px; color: var(--brand); background: #edf6f3; }
.quick-icon .icon { width: 18px; height: 18px; }
.quick-card > span:nth-child(2) { min-width: 0; display: grid; gap: 4px; }
.quick-card strong { overflow: hidden; font-size: 11px; text-overflow: ellipsis; white-space: nowrap; }
.quick-card small { overflow: hidden; color: var(--muted); font-size: 9px; text-overflow: ellipsis; white-space: nowrap; }
.quick-arrow { width: 16px; height: 16px; margin-right: auto; color: #93a09b; }

.table { margin: 0; color: #394943; vertical-align: middle; }
.table > :not(caption) > * > * { padding: 13px 10px; border-bottom-color: #edf1ef; }
.table thead th { color: #85918d; background: #fafcfb; font-size: 11px; font-weight: 700; white-space: nowrap; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr:hover { background: #fbfdfc; }
.table td { font-size: 12px; }
.table td strong { color: #35443f; }
.form-label { color: #44534e; font-size: 12px; font-weight: 700; }
.form-control, .form-select { min-height: 41px; border-color: #dce5e1; border-radius: 9px; color: #33413d; font-size: 13px; }
.form-control:focus, .form-select:focus { border-color: #65b29e; box-shadow: 0 0 0 .2rem #167c6818; }
.form-check-input:checked { border-color: var(--brand); background-color: var(--brand); }
.status { display: inline-flex; align-items: center; border-radius: 999px; padding: 5px 9px; color: #50615b; background: #eff3f1; font-size: 10px; font-weight: 700; white-space: nowrap; }
.status-success { color: #23775f; background: #e9f5ef; }
.status-warning { color: #a56a1e; background: #fff3df; }
.status-danger { color: #ab4c4c; background: #fceded; }
.status-neutral { color: #687772; background: #eff2f1; }
.empty { padding: 35px !important; color: #8d9994 !important; text-align: center; }
.empty-state-table { color: #84918c; text-align: center; }
.validation-summary-errors { margin-bottom: 15px; padding: 11px 14px; border-radius: 10px; color: #a84747; background: #fff0ef; font-size: 12px; }
.validation-summary-errors:empty { display: none; }
.validation-summary-errors ul { margin: 0; padding-right: 20px; }
.actions { display: flex; align-items: center; gap: 7px; flex-wrap: wrap; }
.actions form, .inline-form { margin: 0; }
.inline-form { display: flex; align-items: center; gap: 6px; min-width: 190px; }
.inline-form .form-select { width: auto; min-width: 115px; min-height: 34px; padding: 5px 25px 5px 8px; font-size: 10px; }
.shipping-cell { display: flex; align-items: center; gap: 7px; min-width: 170px; }
.shipping-cell form { margin: 0; }
.shipping-cell .btn { padding: 5px 8px; font-size: 10px; white-space: nowrap; }
.code { direction: ltr; text-align: left; font-family: Consolas, "Courier New", monospace; }
.product-cell { display: flex; align-items: center; gap: 10px; min-width: 190px; }
.product-thumb { width: 40px; height: 40px; flex: 0 0 40px; object-fit: cover; border: 1px solid var(--line); border-radius: 9px; background: #f5f8f7; }
.product-thumb-placeholder { display: grid; place-items: center; color: #9ba8a3; }
.product-thumb-placeholder .icon { width: 19px; height: 19px; }
.pagination-bar { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 17px; color: #82908a; font-size: 11px; }
.pagination-bar .btn.disabled { pointer-events: none; opacity: .45; }
.filter-row { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin-bottom: 16px; }
.filter-search { display: flex; flex: 1; gap: 8px; }
.filter-search .form-control { max-width: 430px; }
.filter-check { display: inline-flex; align-items: center; gap: 6px; margin: 0; color: #61706b; font-size: 11px; white-space: nowrap; }
.filter-check .form-check-input { float: none; margin: 0; }
.filter-count { color: #87938e; font-size: 11px; white-space: nowrap; }

.tile-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 13px; }
.tile { display: block; min-height: 105px; padding: 18px; border: 1px solid var(--line); border-radius: 13px; color: var(--ink); background: #fff; text-decoration: none; transition: transform .16s ease, box-shadow .16s ease; }
.tile:hover { color: var(--ink); transform: translateY(-2px); box-shadow: 0 9px 22px #243b3512; }
.tile strong { display: block; margin-bottom: 8px; font-size: 15px; }
.tile span { color: var(--muted); font-size: 12px; }
.image-preview { max-width: min(100%, 280px); border: 1px solid var(--line); border-radius: 10px; }
.copy-status { margin-right: 10px; color: var(--brand-dark); font-size: 12px; }
.form-check-label { color: #53615d; }
.validation-message { display: block; margin-top: 5px; color: #ae4e4e; font-size: 11px; }
.return-card .section-head { align-items: flex-start; }
.return-card .section-head h2 { margin: 0; }
.return-card .section-head p { margin-top: 6px; }
.return-reason { margin: 0 0 12px; color: #475650; line-height: 1.9; }
.return-note { padding: 11px 13px; border-radius: 9px; color: #62716b; background: #f7f9f8; font-size: 12px; line-height: 1.9; }
.return-items { display: grid; gap: 7px; margin: 15px 0; padding: 0; list-style: none; }
.return-items li { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 12px; border: 1px solid #edf1ef; border-radius: 9px; font-size: 12px; }
.return-form { margin-top: 16px; padding-top: 16px; border-top: 1px solid var(--line); }
.return-form-fields { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: end; gap: 12px; }
.return-actions { display: flex; flex-wrap: wrap; gap: 7px; }
.terminal-note { padding: 11px 13px; border-radius: 9px; color: #75827d; background: #f5f7f6; font-size: 11px; }
.upload-dropzone { display: grid; justify-items: center; gap: 8px; padding: 28px 20px; border: 1px dashed #cadbd4; border-radius: 13px; background: #fbfdfc; text-align: center; }
.upload-dropzone > strong { color: #40504a; font-size: 13px; }
.upload-dropzone > span:not(.upload-icon) { color: var(--muted); font-size: 11px; }
.upload-icon { width: 44px; height: 44px; display: grid; place-items: center; margin-bottom: 2px; border-radius: 13px; color: var(--brand); background: #eaf5f1; }
.upload-icon .icon { width: 21px; height: 21px; }
.upload-dropzone .form-control { width: min(100%, 430px); min-height: auto; padding: 8px; background: #fff; text-align: right; }
.upload-preview { display: block; max-height: 320px; object-fit: contain; }
.copy-group .form-control { min-width: 0; }
.review-product-search, .review-product-select { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: end; gap: 10px; }
.review-product-search { padding-bottom: 17px; border-bottom: 1px solid var(--line); }
.review-product-select { margin-top: 17px; }
.search-result-count { margin: 12px 0 0; color: var(--muted); font-size: 11px; }
.review-results .section-head { margin-bottom: 12px; }
.review-card { padding: 17px 0; border-top: 1px solid #edf1ef; }
.review-card:first-of-type { border-top: 0; }
.review-card-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.review-card-heading > div { display: grid; gap: 6px; }
.review-card h3 { margin: 0; color: #34433e; font-size: 14px; font-weight: 700; }
.review-rating { display: inline-flex; align-items: center; gap: 5px; color: #a87931; font-size: 11px; }
.review-rating .icon { width: 14px; height: 14px; fill: #e4b85b; stroke: #c79536; }
.review-body { margin: 12px 0; color: #596762; line-height: 1.9; white-space: pre-line; }
:focus-visible { outline: 3px solid #48a99080; outline-offset: 2px; }
.sidebar-nav a:focus-visible, .btn:focus-visible, .quick-card:focus-visible, .stat-card:focus-visible { outline-offset: 3px; }
.text-muted { color: var(--muted) !important; }
.alert { border-radius: 11px; font-size: 12px; }

.auth-shell { min-height: 100vh; display: grid; place-items: center; padding: 22px; }
.auth-card { width: min(100%, 430px); padding: 32px; border: 1px solid var(--line); border-radius: 17px; background: #fff; box-shadow: 0 16px 50px #1d332b12; }
.auth-card h1 { margin: 0 0 8px; font-size: 23px; font-weight: 800; }
.auth-card p { margin-bottom: 24px; color: var(--muted); line-height: 1.8; }

@media (max-width: 1180px) {
    .stats-grid { grid-template-columns: repeat(2, minmax(0,1fr)); }
    .dashboard-grid { grid-template-columns: minmax(0,1fr); }
    .quick-grid { grid-template-columns: repeat(2, minmax(0,1fr)); }
}

@media (max-width: 900px) {
    .topbar { height: 64px; padding: 0 17px; }
    .app-shell { display: block; min-height: calc(100vh - 64px); }
    .sidebar { position: fixed; z-index: 60; top: 64px; right: 0; bottom: 0; width: min(285px, 85vw); height: auto; transform: translateX(105%); transition: transform .2s ease; box-shadow: -15px 0 35px #0a201b20; }
    body.sidebar-open .sidebar { transform: translateX(0); }
    .sidebar-backdrop { position: fixed; z-index: 55; inset: 64px 0 0; width: 100%; display: block; border: 0; background: #10252155; opacity: 0; pointer-events: none; transition: opacity .2s ease; }
    body.sidebar-open .sidebar-backdrop { opacity: 1; pointer-events: auto; }
    .menu-toggle { width: 37px; height: 37px; display: flex; flex-direction: column; justify-content: center; gap: 5px; padding: 8px; border: 1px solid var(--line); border-radius: 9px; background: #fff; }
    .menu-toggle span { height: 2px; width: 100%; border-radius: 2px; background: #53645e; }
    .main-content { padding: 25px 20px 38px; }
    .sidebar-footer { margin-top: 28px; }
}

@media (max-width: 600px) {
    .topbar { padding: 0 12px; }
    .topbar-tools { gap: 10px; }
    .topbar-search { display: none; }
    .brand { gap: 8px; font-size: 13px; }
    .brand-mark { width: 34px; height: 34px; border-radius: 10px; font-size: 16px; }
    .user-menu { gap: 6px; }
    .user-name, .user-avatar { display: none; }
    .logout-button { padding: 6px 8px; }
    .main-content { padding: 20px 13px 30px; }
    .page-head { align-items: flex-start; flex-direction: column; gap: 13px; margin-bottom: 19px; }
    .page-head h1, .dashboard-heading h1 { font-size: 21px; }
    .page-head p { font-size: 12px; }
    .stats-grid { grid-template-columns: repeat(2, minmax(0,1fr)); gap: 9px; }
    .stat-card { min-height: 147px; padding: 14px; }
    .stat-icon { top: 12px; left: 12px; width: 32px; height: 32px; border-radius: 10px; }
    .stat-label { max-width: calc(100% - 37px); font-size: 10px; }
    .stat-card > strong { font-size: 25px; }
    .stat-foot { font-size: 9px; }
    .panel, .quick-access { padding: 16px 13px; border-radius: 13px; }
    .section-head { align-items: flex-start; }
    .section-head p { font-size: 10px; line-height: 1.7; }
    .quick-grid { grid-template-columns: 1fr; }
    .quick-card { padding: 11px; }
    .filter-row { align-items: stretch; flex-direction: column; }
    .filter-search { width: 100%; }
    .filter-search .form-control { min-width: 0; }
    .filter-count { align-self: flex-start; }
    .pagination-bar { align-items: flex-start; flex-direction: column; }
    .inline-form { min-width: 0; }
    .return-form-fields { grid-template-columns: 1fr; }
    .return-items li { align-items: flex-start; }
    .upload-dropzone { padding: 22px 12px; }
    .review-product-search, .review-product-select { grid-template-columns: 1fr; }
    .review-product-search .btn, .review-product-select .btn { justify-self: start; }
    .review-card-heading { align-items: flex-start; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; }
}
