@import url('https://fonts.googleapis.com/css2?family=Vazirmatn:wght@400;500;600;700&display=swap');

:root {
    --bg: #f3efe6;
    --bg-accent: #e7dfd0;
    --surface: #fffdf8;
    --ink: #1c1915;
    --muted: #6b6358;
    --line: #d9d0c0;
    --gold: #b8892a;
    --gold-deep: #8a6718;
    --green: #1f6b4a;
    --red: #a33b2d;
    --blue: #2a4f6e;
    --shadow: 0 10px 30px rgba(40, 30, 10, 0.08);
    --radius: 14px;
    --sidebar: #241f18;
    --sidebar-text: #f4ebe0;
}

* { box-sizing: border-box; }
html, body {
    margin: 0;
    padding: 0;
    font-family: 'Vazirmatn', Tahoma, sans-serif;
    background:
        radial-gradient(circle at top left, rgba(184, 137, 42, 0.12), transparent 40%),
        linear-gradient(180deg, #f7f2e8 0%, var(--bg) 100%);
    color: var(--ink);
    min-height: 100%;
    overflow-x: hidden;
}
img, svg, video, canvas { max-width: 100%; }

a { color: var(--gold-deep); text-decoration: none; }
a:hover { color: var(--gold); }

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 0.65rem 1rem;
    color: #f8f1e6;
    position: sticky;
    top: 0;
    z-index: 40;
    border-bottom: 1px solid rgba(244, 212, 138, 0.28);
    background:
        radial-gradient(ellipse 50% 120% at 15% 0%, rgba(212, 168, 75, 0.28), transparent 55%),
        radial-gradient(ellipse 40% 100% at 85% 100%, rgba(184, 137, 42, 0.18), transparent 50%),
        linear-gradient(105deg, #1a1510 0%, #2c241b 42%, #3a2e1f 68%, #221c16 100%);
    box-shadow: 0 8px 24px rgba(20, 14, 8, 0.28);
}
.topbar::before {
    content: '';
    position: absolute;
    inset: 0;
    pointer-events: none;
    opacity: 0.08;
    background-image:
        linear-gradient(135deg, rgba(244,212,138,0.35) 1px, transparent 1px),
        linear-gradient(45deg, rgba(244,212,138,0.2) 1px, transparent 1px);
    background-size: 18px 18px;
}
.topbar > * { position: relative; z-index: 1; }

.topbar-start {
    display: flex;
    align-items: center;
    gap: 0.55rem;
    min-width: 0;
}
.nav-toggle {
    display: none;
    flex-direction: column;
    justify-content: center;
    gap: 4px;
    width: 2.35rem;
    height: 2.35rem;
    padding: 0.45rem;
    border: 1px solid rgba(244, 212, 138, 0.35);
    border-radius: 10px;
    background: rgba(184, 137, 42, 0.18);
    cursor: pointer;
    flex-shrink: 0;
}
.nav-toggle-bar {
    display: block;
    height: 2px;
    width: 100%;
    background: #f6d98f;
    border-radius: 2px;
}
.nav-backdrop {
    display: none;
}
.sidebar-head {
    display: none;
}

.brand {
    color: #f6d98f;
    font-weight: 700;
    font-size: 1.1rem;
    letter-spacing: -0.02em;
    text-shadow: 0 1px 0 rgba(0,0,0,0.35);
    white-space: nowrap;
}
.today {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.35rem;
    color: #d8c7ad;
    font-size: 0.78rem;
    margin-top: 0.15rem;
}
.today-time {
    color: #f4d48a;
    font-variant-numeric: tabular-nums;
    font-weight: 600;
}
.today-sep { opacity: 0.55; }

.price-ticker {
    display: flex;
    gap: 0.45rem;
    flex-wrap: wrap;
    justify-content: center;
    align-items: center;
}
.price-item {
    background: linear-gradient(180deg, rgba(255,255,255,0.1), rgba(255,255,255,0.04));
    border: 1px solid rgba(244, 212, 138, 0.28);
    border-radius: 999px;
    padding: 0.32rem 0.75rem 0.32rem 0.55rem;
    display: flex;
    gap: 0.35rem;
    align-items: center;
    backdrop-filter: blur(4px);
}
.price-ico {
    width: 1.05rem;
    height: 1.05rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: #f4d48a;
    flex-shrink: 0;
}
.price-ico svg {
    width: 100%;
    height: 100%;
    fill: currentColor;
}
.price-item .label { color: #d8c3a0; font-size: 0.72rem; }
.price-item .value { color: #fff; font-weight: 600; font-size: 0.84rem; white-space: nowrap; }
.price-updated {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 0.05rem;
    padding: 0.15rem 0.35rem;
    margin-inline-start: 0.15rem;
    border-inline-start: 1px solid rgba(244, 212, 138, 0.22);
    padding-inline-start: 0.65rem;
    line-height: 1.15;
    white-space: nowrap;
}
.price-updated-label {
    color: #c9b08a;
    font-size: 0.62rem;
    opacity: 0.9;
}
.price-updated-value {
    color: #f0e2c4;
    font-size: 0.72rem;
    font-weight: 500;
}
.currency-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2.05rem;
    height: 2.05rem;
    border: 1px solid rgba(244, 212, 138, 0.4);
    background: rgba(184, 137, 42, 0.25);
    color: #f6d98f;
    border-radius: 10px;
    padding: 0;
    font: inherit;
    cursor: pointer;
    flex-shrink: 0;
}
.currency-toggle .currency-unit {
    font-size: 0.95rem;
    font-weight: 800;
    line-height: 1;
}
.currency-toggle:hover {
    background: rgba(184, 137, 42, 0.45);
    color: #fff;
}

.topbar-user {
    display: flex;
    align-items: center;
    gap: 0.45rem;
    color: #e8dcc8;
    font-size: 0.9rem;
    flex-shrink: 0;
}
.topbar-username {
    max-width: 10rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.shell { display: grid; grid-template-columns: 240px 1fr; min-height: calc(100vh - 68px); }
.sidebar {
    background: var(--sidebar);
    color: var(--sidebar-text);
    padding: 1.25rem 0.85rem;
}
.side-nav { display: flex; flex-direction: column; gap: 0.15rem; }
.nav-link {
    display: flex;
    align-items: center;
    gap: 0.55rem;
    color: #e8dcc8;
    padding: 0.65rem 0.85rem;
    border-radius: 10px;
    font-size: 0.95rem;
}
.nav-link:hover, .nav-link.active {
    background: rgba(184, 137, 42, 0.18);
    color: #fff;
}
.nav-ico {
    width: 1.1rem;
    height: 1.1rem;
    fill: currentColor;
    opacity: 0.9;
    flex-shrink: 0;
}
.nav-section { margin-top: 0.15rem; }
.nav-title {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 0.55rem;
    border: none;
    background: transparent;
    color: #f4d48a;
    font: inherit;
    font-weight: 600;
    font-size: 0.92rem;
    padding: 0.7rem 0.85rem;
    border-radius: 10px;
    cursor: pointer;
    text-align: right;
}
.nav-title > span { flex: 1; }
.nav-title::after {
    content: '';
    width: 0.45rem;
    height: 0.45rem;
    border-left: 2px solid #cbbba2;
    border-bottom: 2px solid #cbbba2;
    transform: rotate(-45deg);
    transition: transform 0.2s ease;
    flex-shrink: 0;
    margin-right: auto;
}
.nav-title:hover { background: rgba(255,255,255,0.05); }
.nav-section.open .nav-title::after { transform: rotate(45deg); }
.nav-section.open .nav-title { color: #fff; }
.nav-sub {
    display: none;
    flex-direction: column;
    gap: 0.1rem;
    padding: 0.15rem 0 0.35rem 0.35rem;
    margin-right: 0.55rem;
    border-right: 1px solid rgba(244, 212, 138, 0.2);
}
.nav-section.open .nav-sub { display: flex; }
.nav-sub .nav-link {
    font-size: 0.88rem;
    padding: 0.5rem 0.75rem;
    color: #d8cbb8;
}
.nav-sub .nav-ico { width: 0.95rem; height: 0.95rem; opacity: 0.75; }

.content { padding: 1.1rem 1.25rem 1.5rem; }
.page-head { margin-bottom: 0.85rem; }
.page-head h1 { margin: 0; font-size: 1.2rem; font-weight: 700; }

.card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 12px;
    box-shadow: var(--shadow);
    padding: 0.9rem 1rem;
    margin-bottom: 0.75rem;
}

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0.75rem; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0.75rem; }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 0.75rem; }
/* Lone short fields stay one column wide even with nothing beside them */
.form-row.half {
    width: 100%;
}
@media (min-width: 961px) {
    .form-row.half {
        width: calc((100% - 0.75rem) / 2);
        max-width: calc((100% - 0.75rem) / 2);
    }
}

.stat {
    background: linear-gradient(160deg, #fffdf8, #f4ead7);
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 0.8rem 0.9rem;
}
.stat .label { color: var(--muted); font-size: 0.78rem; font-weight: 500; }
.stat .value { font-size: 1.05rem; font-weight: 700; margin-top: 0.25rem; }
.stat .muted { font-size: 0.78rem; margin-top: 0.2rem; }

.chart-card {
    height: 280px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}
.chart-wrap {
    flex: 1;
    position: relative;
    min-height: 0;
    width: 100%;
}
.chart-wrap canvas {
    position: absolute !important;
    inset: 0;
    width: 100% !important;
    height: 100% !important;
    max-height: none !important;
}
.chart-title {
    margin: 0 0 0.45rem;
    font-size: 0.88rem;
    font-weight: 600;
    color: var(--muted);
    flex-shrink: 0;
}
.dash-row { margin-bottom: 0.75rem; }
.dash-range-bar {
    margin-bottom: 0.85rem;
    align-items: center;
}
.range-switch {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
}
.range-switch .btn {
    min-width: 5.5rem;
    text-align: center;
}
.range-switch .btn[href*="last7"] {
    min-width: 7.5rem;
}

label { display: block; margin-bottom: 0.35rem; color: var(--muted); font-size: 0.9rem; }
.form-row { margin-bottom: 1rem; }
.field-hint {
    margin: 0.35rem 0 0;
    font-size: 0.8rem;
    line-height: 1.45;
    color: var(--muted);
}
.form-row.inline { display: flex; gap: 1rem; flex-wrap: wrap; }
.form-row.inline > * { flex: 1; min-width: 160px; }
.form-row-active {
    margin-top: 1.1rem;
    padding-top: 1rem;
    border-top: 1px solid var(--line);
}

.product-ico {
    width: 1.35rem;
    height: 1.35rem;
    display: block;
    color: var(--gold-deep);
    flex-shrink: 0;
}
.product-ico-cell {
    width: 3.4rem;
    vertical-align: middle;
}
.product-ico-cell .product-ico {
    width: 2.4rem;
    height: 2.4rem;
    margin: 0 auto;
    padding: 0.35rem;
    box-sizing: content-box;
    border-radius: 0.65rem;
    background: #fff8ea;
    color: var(--gold-deep);
}

.icon-picker {
    border: 1px solid var(--line);
    border-radius: 12px;
    background: #fffaf1;
    padding: 0.75rem;
}
.icon-picker-toolbar {
    display: flex;
    gap: 0.75rem;
    align-items: center;
    flex-wrap: wrap;
    margin-bottom: 0.75rem;
}
.icon-picker-search {
    flex: 1 1 14rem;
    min-width: 0;
}
.icon-picker-current {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    padding: 0.45rem 0.7rem;
    border-radius: 999px;
    background: #f3ead8;
    color: var(--ink);
    font-size: 0.85rem;
    font-weight: 600;
    white-space: nowrap;
}
.icon-picker-current .product-ico { width: 1.15rem; height: 1.15rem; }
.icon-picker-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(7.2rem, 1fr));
    gap: 0.5rem;
    max-height: 240px;
    overflow: auto;
}
.icon-picker-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.35rem;
    min-height: 4.4rem;
    padding: 0.55rem 0.4rem;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: #fff;
    color: var(--ink);
    font: inherit;
    font-size: 0.78rem;
    cursor: pointer;
    text-align: center;
}
.icon-picker-item .product-ico { width: 1.55rem; height: 1.55rem; }
.icon-picker-item:hover {
    border-color: var(--gold);
    background: #fff8ea;
}
.icon-picker-item.selected {
    border-color: var(--gold);
    background: linear-gradient(160deg, #fff8ea, #f3ead8);
    box-shadow: inset 0 0 0 1px rgba(184, 137, 42, 0.25);
    font-weight: 700;
}
.icon-picker-item[hidden] { display: none !important; }
.field-row {
    display: flex;
    gap: 0.5rem;
    align-items: stretch;
    flex-wrap: wrap;
}
.field-row > input,
.field-row > select {
    flex: 1 1 12rem;
    min-width: 0;
}
.field-row > .btn {
    flex: 0 0 auto;
    white-space: nowrap;
}

input:not([type]),
input[type="text"],
input[type="password"],
input[type="number"],
input[type="tel"],
input[type="search"],
input[type="email"],
input[type="url"],
select,
textarea {
    width: 100%;
    max-width: 100%;
    border: 1px solid var(--line);
    background: #fff;
    border-radius: 10px;
    padding: 0.7rem 0.85rem;
    font: inherit;
    color: var(--ink);
    box-sizing: border-box;
}
textarea { min-height: 90px; resize: vertical; }
input[type="password"] {
    direction: ltr;
    text-align: left;
    unicode-bidi: isolate;
}
input:focus, select:focus, textarea:focus {
    outline: 2px solid rgba(184, 137, 42, 0.35);
    border-color: var(--gold);
}

.grid-2 > .form-row,
.grid-3 > .form-row,
.grid-4 > .form-row {
    min-width: 0;
    margin-bottom: 0.75rem;
}
.grid-2 > .form-row > input,
.grid-2 > .form-row > select,
.grid-2 > .form-row > textarea,
.grid-3 > .form-row > input,
.grid-3 > .form-row > select,
.grid-4 > .form-row > input,
.grid-4 > .form-row > select {
    width: 100%;
}

.modal .grid-2 {
    margin-bottom: 0.15rem;
}
.modal .actions {
    margin-top: 0.5rem;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.35rem;
    border: none;
    border-radius: 10px;
    padding: 0.7rem 1.1rem;
    font: inherit;
    font-weight: 600;
    cursor: pointer;
    background: var(--gold);
    color: #fff;
}
.btn:hover { background: var(--gold-deep); color: #fff; }
.btn-secondary { background: var(--blue); }
.btn-secondary:hover { background: #1d3d57; }
.btn-danger { background: var(--red); }
.btn-ghost {
    background: transparent;
    border: 1px solid rgba(255,255,255,0.25);
    color: #f4ebe0;
}
.btn-outline {
    background: transparent;
    border: 1px solid var(--line);
    color: var(--ink);
}
.btn-sm { padding: 0.4rem 0.75rem; font-size: 0.85rem; border-radius: 8px; }

.table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-x: contain;
}
table {
    width: 100%;
    border-collapse: collapse;
    background: var(--surface);
    min-width: 560px;
}
th, td {
    padding: 0.75rem 0.85rem;
    border-bottom: 1px solid var(--line);
    text-align: right;
    vertical-align: middle;
}
th { color: var(--muted); font-weight: 600; font-size: 0.85rem; background: #f7f1e6; }
tr:hover td { background: #fbf7ef; }

.table-compact {
    min-width: 0;
    font-size: 0.76rem;
}
.table-compact th,
.table-compact td {
    padding: 0.4rem 0.42rem;
    font-size: 0.76rem;
    white-space: nowrap;
}
.table-compact th { font-size: 0.7rem; }
.table-compact td:nth-child(9) {
    white-space: normal;
    max-width: 8.5rem;
    line-height: 1.3;
}
.table-compact .badge { font-size: 0.66rem; padding: 0.1rem 0.35rem; }
.table-compact .btn-sm {
    padding: 0.2rem 0.4rem;
    font-size: 0.7rem;
    border-radius: 6px;
}
.table-compact .actions {
    display: flex;
    flex-wrap: nowrap;
    gap: 0.22rem;
    justify-content: flex-start;
}

.alert {
    padding: 0.85rem 1rem;
    border-radius: 10px;
    margin-bottom: 1rem;
}
.alert-success { background: #e7f6ee; color: var(--green); border: 1px solid #b9e0cb; }
.alert-error { background: #fdecea; color: var(--red); border: 1px solid #f0c4bd; }
.alert-info { background: #eaf2f8; color: var(--blue); border: 1px solid #c5d8e8; }

.badge {
    display: inline-block;
    padding: 0.2rem 0.55rem;
    border-radius: 999px;
    font-size: 0.78rem;
    background: #efe6d5;
    color: #6a5430;
}
.badge-void { background: #fdecea; color: var(--red); }
.badge-active { background: #e7f6ee; color: var(--green); }

.toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1rem;
    flex-wrap: wrap;
}
.filters-form .form-row { margin-bottom: 0.65rem; }
.filters-form .actions { margin-top: 0.25rem; }

.filters-panel {
    padding: 0;
    overflow: hidden;
}
.filters-toggle {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 0.85rem 1rem;
    border: 0;
    background: transparent;
    color: inherit;
    font: inherit;
    cursor: pointer;
    text-align: right;
}
.filters-toggle:hover { background: #fff8ea; }
.filters-toggle-main {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.5rem 0.65rem;
    min-width: 0;
}
.filters-toggle-title {
    font-weight: 700;
    font-size: 0.98rem;
}
.filters-toggle-hint { font-size: 0.82rem; }
.filters-chevron {
    width: 0.55rem;
    height: 0.55rem;
    border-left: 2px solid var(--muted);
    border-bottom: 2px solid var(--muted);
    transform: rotate(-45deg);
    transition: transform 0.18s ease;
    flex-shrink: 0;
    margin-left: 0.15rem;
}
.filters-panel.open .filters-chevron {
    transform: rotate(135deg);
    margin-top: 0.2rem;
}
.filters-body {
    display: none;
    padding: 0 1rem 1rem;
    border-top: 1px solid var(--line);
}
.filters-panel.open .filters-body {
    display: block;
    padding-top: 0.85rem;
}

.login-page {
    --login-ink: #f6efe3;
    --login-muted: rgba(246, 239, 227, 0.72);
    --login-gold: #d4a84b;
    --login-gold-soft: rgba(212, 168, 75, 0.35);
    --login-panel: rgba(255, 250, 242, 0.94);
    position: relative;
    min-height: 100vh;
    min-height: 100dvh;
    display: grid;
    place-items: center;
    padding: clamp(1.25rem, 4vw, 2.5rem);
    overflow: hidden;
    background: #14110e;
    color: var(--login-ink);
}
.login-atmosphere {
    position: absolute;
    inset: 0;
    pointer-events: none;
    background:
        radial-gradient(ellipse 70% 55% at 80% 15%, rgba(184, 137, 42, 0.28), transparent 58%),
        radial-gradient(ellipse 55% 50% at 12% 85%, rgba(90, 64, 28, 0.55), transparent 60%),
        linear-gradient(155deg, #1a1510 0%, #2a2118 42%, #120f0c 100%);
}
.login-mesh {
    position: absolute;
    inset: 0;
    opacity: 0.14;
    background-image:
        linear-gradient(rgba(244, 212, 138, 0.35) 1px, transparent 1px),
        linear-gradient(90deg, rgba(244, 212, 138, 0.22) 1px, transparent 1px);
    background-size: 42px 42px;
    mask-image: radial-gradient(ellipse 75% 70% at 50% 40%, #000 20%, transparent 75%);
    animation: loginMeshDrift 22s linear infinite;
}
.login-orb {
    position: absolute;
    border-radius: 50%;
    filter: blur(2px);
}
.login-orb-a {
    width: min(48vw, 420px);
    height: min(48vw, 420px);
    top: -12%;
    left: -8%;
    background: radial-gradient(circle, rgba(212, 168, 75, 0.22), transparent 68%);
    animation: loginOrbFloat 14s ease-in-out infinite;
}
.login-orb-b {
    width: min(40vw, 340px);
    height: min(40vw, 340px);
    right: -6%;
    bottom: -10%;
    background: radial-gradient(circle, rgba(139, 105, 20, 0.3), transparent 70%);
    animation: loginOrbFloat 18s ease-in-out infinite reverse;
}
.login-stage {
    position: relative;
    z-index: 1;
    width: min(440px, 100%);
    display: grid;
    gap: clamp(1.5rem, 3.5vw, 2.25rem);
}
.login-hero {
    text-align: center;
    animation: loginRise 0.85s cubic-bezier(0.22, 1, 0.36, 1) both;
}
.login-brand {
    margin: 0;
    font-family: 'Amiri', 'Vazirmatn', serif;
    font-weight: 700;
    font-size: clamp(2.6rem, 7.5vw, 3.7rem);
    line-height: 1.2;
    letter-spacing: 0.06em;
    background: linear-gradient(180deg, #fff6d6 0%, #e8c56a 42%, #c4963a 72%, #f0d78c 100%);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    filter: drop-shadow(0 2px 18px rgba(212, 168, 75, 0.28));
}
.login-rule {
    display: block;
    width: 4.5rem;
    height: 1px;
    margin: 0.95rem auto 0.85rem;
    background: linear-gradient(90deg, transparent, var(--login-gold), transparent);
    transform-origin: center;
    animation: loginRule 1.1s cubic-bezier(0.22, 1, 0.36, 1) 0.2s both;
}
.login-lead {
    margin: 0;
    color: var(--login-muted);
    font-size: 0.98rem;
    font-weight: 500;
    letter-spacing: 0.01em;
}
.login-panel {
    background: var(--login-panel);
    color: var(--ink);
    border: 1px solid rgba(212, 168, 75, 0.28);
    border-radius: 16px;
    padding: clamp(1.35rem, 3vw, 1.85rem);
    backdrop-filter: blur(10px);
    animation: loginRise 0.9s cubic-bezier(0.22, 1, 0.36, 1) 0.12s both;
}
.login-panel .alert {
    margin-bottom: 1rem;
}
.login-form .form-row {
    margin-bottom: 1rem;
}
.login-form label {
    color: #5c5348;
    font-size: 0.86rem;
    font-weight: 600;
}
.login-form input {
    background: #fff;
    border-color: #e0d5c3;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}
.login-form input:focus {
    border-color: var(--gold);
    box-shadow: 0 0 0 3px rgba(184, 137, 42, 0.16);
    outline: none;
}
.login-captcha-row {
    margin-bottom: 0.85rem;
}
.login-captcha {
    display: grid;
    grid-template-columns: 160px 1fr;
    gap: 0.5rem;
    align-items: stretch;
}
.login-captcha-visual {
    display: block;
    margin: 0;
    padding: 0;
    width: 160px;
    height: 48px;
    border-radius: 8px;
    overflow: hidden;
    border: 1px solid rgba(184, 137, 42, 0.4);
    background: #1a1510;
    cursor: pointer;
    user-select: none;
    transition: border-color 0.15s ease, opacity 0.15s ease;
}
.login-captcha-visual:hover {
    border-color: rgba(184, 137, 42, 0.75);
    opacity: 0.92;
}
.login-captcha-visual img {
    display: block;
    width: 160px;
    height: 48px;
    object-fit: cover;
    pointer-events: none;
}
.login-captcha input {
    width: 100%;
    height: 48px;
    direction: ltr;
    text-align: center;
    font-size: 1rem;
    font-weight: 700;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    unicode-bidi: isolate;
    padding: 0.45rem 0.65rem;
    box-sizing: border-box;
}
@media (max-width: 480px) {
    .login-captcha {
        grid-template-columns: 1fr 1fr;
    }
    .login-captcha-visual,
    .login-captcha-visual img {
        width: 100%;
        height: 44px;
    }
    .login-captcha input {
        height: 44px;
    }
}
.login-submit {
    width: 100%;
    margin-top: 0.35rem;
    padding: 0.85rem 1rem;
    font-size: 1rem;
    letter-spacing: 0.02em;
    background: linear-gradient(135deg, #c4973a 0%, #8a6718 100%);
    border: 0;
    transition: transform 0.18s ease, filter 0.18s ease;
}
.login-submit:hover {
    filter: brightness(1.05);
    transform: translateY(-1px);
}
.login-submit:active {
    transform: translateY(0);
}
@keyframes loginRise {
    from { opacity: 0; transform: translateY(18px); }
    to { opacity: 1; transform: translateY(0); }
}
@keyframes loginRule {
    from { opacity: 0; transform: scaleX(0.2); }
    to { opacity: 1; transform: scaleX(1); }
}
@keyframes loginOrbFloat {
    0%, 100% { transform: translate3d(0, 0, 0); }
    50% { transform: translate3d(12px, -16px, 0); }
}
@keyframes loginMeshDrift {
    from { transform: translate3d(0, 0, 0); }
    to { transform: translate3d(42px, 42px, 0); }
}
@media (prefers-reduced-motion: reduce) {
    .login-hero,
    .login-panel,
    .login-rule,
    .login-orb,
    .login-mesh {
        animation: none !important;
    }
}

.autocomplete {
    position: relative;
}
.ac-list {
    position: absolute;
    top: calc(100% + 4px);
    right: 0;
    left: 0;
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 10px;
    box-shadow: var(--shadow);
    z-index: 30;
    max-height: 240px;
    overflow: auto;
    display: none;
}
.ac-list.open { display: block; }
.ac-item {
    padding: 0.7rem 0.85rem;
    cursor: pointer;
    border-bottom: 1px solid #f0e8da;
}
.ac-item.has-ico {
    display: flex;
    align-items: center;
    gap: 0.65rem;
}
.ac-item .ac-ico {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 2.4rem;
    height: 2.4rem;
    border-radius: 0.65rem;
    background: #fff8ea;
}
.ac-item .ac-ico .product-ico {
    width: 1.55rem;
    height: 1.55rem;
}
.ac-item .ac-text { min-width: 0; }
.ac-item:hover, .ac-item.active { background: #f7f0e3; }
.ac-item small { display: block; color: var(--muted); margin-top: 0.15rem; }

.sale-line-title {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    min-width: 0;
}
.sale-line-title .product-ico {
    width: 2.1rem;
    height: 2.1rem;
    padding: 0.3rem;
    box-sizing: content-box;
    border-radius: 0.6rem;
    background: #fff8ea;
}

.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(28, 25, 21, 0.5);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 50;
    padding: 1rem;
    overflow: auto;
}
.modal-backdrop.open { display: flex; }
.modal-backdrop[hidden] { display: none !important; }
.void-confirm-modal { max-width: 420px; }
.void-confirm-modal .btn-danger:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}
.modal {
    width: min(560px, 100%);
    background: var(--surface);
    border-radius: 16px;
    padding: 1.25rem 1.35rem 1.35rem;
    max-height: none;
    overflow: visible;
    box-shadow: 0 20px 50px rgba(28, 25, 21, 0.28);
    position: relative;
    box-sizing: border-box;
}
.modal h2 { margin: 0 0 1rem; font-size: 1.2rem; text-align: right; }

.jdp-input {
    background-color: #fff;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='%238a6718'%3E%3Cpath d='M7 2h2v2h6V2h2v2h3a2 2 0 012 2v14a2 2 0 01-2 2H4a2 2 0 01-2-2V6a2 2 0 012-2h3V2zm13 8H4v10h16V10zM4 8h16V6H4v2z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: left 0.85rem center;
    background-size: 1.15rem;
    padding-left: 2.5rem;
    cursor: pointer;
}

/* element tag used by JalaliDatePicker (not a class) */
jdp-container {
    font-family: 'Vazirmatn', Tahoma, sans-serif !important;
    z-index: 20000 !important;
    border-radius: 14px !important;
    border: 1px solid #e2d6c2 !important;
    box-shadow: 0 16px 40px rgba(40, 30, 10, 0.18) !important;
    overflow: hidden !important;
    background: #fffdf8 !important;
}
jdp-container .jdp-day-name {
    background: #f3ead8 !important;
    color: #6b5430 !important;
}
jdp-container .jdp-day.selected,
jdp-container .jdp-day-name.selected {
    background: #b8892a !important;
    color: #fff !important;
}
jdp-container .jdp-day:not(.disabled-day):hover {
    background: rgba(184, 137, 42, 0.18) !important;
}
jdp-container .jdp-btn-today,
jdp-container .jdp-btn-empty,
jdp-container .jdp-btn-close {
    background: #b8892a !important;
}
jdp-container .jdp-year select,
jdp-container .jdp-month select,
jdp-container .jdp-year input,
jdp-container .jdp-month input {
    font-family: 'Vazirmatn', Tahoma, sans-serif !important;
    font-weight: 600 !important;
    background: #f7f1e6 !important;
    border-radius: 8px !important;
    padding: 0.25rem !important;
}
jdp-overlay {
    z-index: 19990 !important;
}

.line-box {
    border: 1px dashed var(--line);
    border-radius: 12px;
    padding: 1rem;
    margin-bottom: 0.85rem;
    background: #fffaf1;
}
.muted { color: var(--muted); }
.price-delta {
    margin-top: 0.35rem;
    font-size: 0.82rem;
    font-weight: 600;
    line-height: 1.3;
}
.price-delta.up { color: var(--green); }
.price-delta.down { color: var(--red); }
.price-delta.same { color: var(--muted); font-weight: 500; }
.price-field { letter-spacing: 0.01em; }

.num-neg {
    color: var(--red);
    font-weight: 700;
    unicode-bidi: isolate;
    direction: ltr;
    display: inline-block;
}

.date-tip {
    position: relative;
    display: inline-block;
    cursor: help;
    border-bottom: 1px dashed rgba(139, 105, 20, 0.45);
}
.floating-tip {
    position: fixed;
    z-index: 10050;
    min-width: 7.5rem;
    max-width: min(18rem, calc(100vw - 1rem));
    padding: 0.55rem 0.75rem;
    border-radius: 0.7rem;
    background: linear-gradient(160deg, #3a2f22, #1f1913);
    color: #fff8ea;
    font-size: 0.8rem;
    font-weight: 600;
    line-height: 1.45;
    text-align: center;
    white-space: nowrap;
    box-shadow: 0 10px 28px rgba(28, 22, 14, 0.28);
    pointer-events: none;
    opacity: 0;
    visibility: hidden;
    transform: translateY(0.2rem);
    transition: opacity 0.14s ease, transform 0.14s ease, visibility 0.14s ease;
}
.floating-tip.is-open {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.pagination {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.65rem;
    margin-top: 0.85rem;
    padding-top: 0.75rem;
    border-top: 1px solid var(--line);
}
.pagination-info {
    color: var(--muted);
    font-size: 0.85rem;
}
.pagination-links {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.35rem;
}
.pagination-ellipsis {
    color: var(--muted);
    padding: 0 0.2rem;
}
.btn.disabled,
.btn:disabled,
.btn.is-disabled {
    opacity: 0.45;
    cursor: not-allowed;
    pointer-events: none;
}
.btn-tip {
    position: relative;
    display: inline-flex;
    cursor: help;
}
.actions { display: flex; gap: 0.5rem; flex-wrap: wrap; }
.backup-cloud-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.65rem;
    margin-top: 0.85rem;
}
.backup-cloud-actions-extra {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
}
.backup-cloud-actions-extra form {
    display: inline;
    margin: 0;
}

.print-body {
    background:
        radial-gradient(circle at top, rgba(184, 137, 42, 0.12), transparent 45%),
        #ebe4d7;
    padding: 1rem;
    min-height: 100vh;
}
.print-toolbar {
    display: flex;
    gap: 0.5rem;
    justify-content: center;
    margin-bottom: 1rem;
}

/* Classic jewelry invoice (A5) */
.jew-invoice {
    width: 148mm;
    min-height: 210mm;
    margin: 0 auto;
    background: #fffef9;
    color: #2a241c;
    box-shadow: 0 14px 40px rgba(40, 30, 10, 0.16);
    box-sizing: border-box;
}
.jew-frame {
    border: 2px solid #b8892a;
    outline: 1px solid rgba(184, 137, 42, 0.35);
    outline-offset: -5px;
    min-height: 210mm;
    padding: 6mm 5.5mm 5mm;
    box-sizing: border-box;
    position: relative;
}
.jew-invoice.is-void .jew-frame::after {
    content: 'باطل';
    position: absolute;
    inset: 38% 8%;
    display: grid;
    place-items: center;
    font-size: 42pt;
    font-weight: 800;
    color: rgba(163, 59, 45, 0.14);
    transform: rotate(-20deg);
    pointer-events: none;
    z-index: 2;
}
.jew-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    margin-bottom: 0.7rem;
    padding-bottom: 0.55rem;
    border-bottom: 1px solid #d4c3a0;
}
.jew-ornament {
    width: 28px;
    height: 28px;
    border: 1.5px solid #b8892a;
    transform: rotate(45deg);
    background:
        linear-gradient(135deg, transparent 42%, #b8892a 42%, #b8892a 58%, transparent 58%),
        linear-gradient(45deg, transparent 42%, #b8892a 42%, #b8892a 58%, transparent 58%);
    opacity: 0.75;
    flex-shrink: 0;
}
.jew-ornament.flip { opacity: 0.55; }
.jew-title-block { text-align: center; flex: 1; }
.jew-shop {
    font-size: 1.35rem;
    font-weight: 800;
    color: #8a6718;
    letter-spacing: -0.02em;
}
.jew-doc-title {
    margin-top: 0.15rem;
    font-size: 0.86rem;
    color: #5c5348;
    font-weight: 600;
}
.jew-void {
    background: #fdecea;
    color: #a33b2d;
    border: 1px solid #f0c4bd;
    text-align: center;
    padding: 0.35rem 0.5rem;
    margin-bottom: 0.55rem;
    font-weight: 700;
    font-size: 0.8rem;
}
.jew-info {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.5rem;
    margin-bottom: 0.7rem;
}
.jew-box {
    border: 1px solid #d8c7a3;
    background: linear-gradient(180deg, #fffdf8, #f7f0e4);
    padding: 0.45rem 0.55rem 0.5rem;
}
.jew-box-title {
    font-size: 0.72rem;
    font-weight: 700;
    color: #8a6718;
    margin-bottom: 0.35rem;
    padding-bottom: 0.25rem;
    border-bottom: 1px dashed #d4c3a0;
}
.jew-kv {
    display: flex;
    justify-content: space-between;
    gap: 0.5rem;
    font-size: 0.78rem;
    padding: 0.12rem 0;
}
.jew-kv span { color: #6b6358; }
.jew-kv b { font-weight: 700; color: #2a241c; }

.jew-items { display: grid; gap: 0.55rem; }
.jew-item {
    border: 1px solid #d8c7a3;
    background: #fff;
    overflow: hidden;
}
.jew-item-head {
    display: grid;
    grid-template-columns: 1.4rem 1fr auto;
    gap: 0.4rem;
    align-items: center;
    padding: 0.35rem 0.5rem;
    background: linear-gradient(90deg, #f3ead8, #fff8ea);
    border-bottom: 1px solid #e2d6c2;
}
.jew-item-no {
    width: 1.25rem;
    height: 1.25rem;
    border-radius: 999px;
    background: #b8892a;
    color: #fff;
    display: grid;
    place-items: center;
    font-size: 0.7rem;
    font-weight: 700;
}
.jew-item-name { font-weight: 700; font-size: 0.88rem; }
.jew-item-rates { font-size: 0.72rem; color: #6b6358; white-space: nowrap; }
.jew-item-rates span { margin: 0 0.2rem; opacity: 0.6; }

.jew-spec {
    width: 100%;
    min-width: 0 !important;
    border-collapse: collapse;
    font-size: 0.74rem;
}
.jew-spec th,
.jew-spec td {
    border-bottom: 1px solid #eee4d4;
    padding: 0.28rem 0.45rem;
    text-align: right;
    background: #fff;
}
.jew-spec th {
    background: #faf6ee;
    color: #6a5430;
    font-weight: 700;
    font-size: 0.7rem;
}
.jew-spec td:nth-child(3),
.jew-spec td:nth-child(4),
.jew-item-sums b { font-variant-numeric: tabular-nums; }

.jew-item-sums {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 0;
    border-top: 1px solid #e2d6c2;
    background: #fffdf8;
}
.jew-item-sums > div {
    padding: 0.3rem 0.35rem;
    border-left: 1px solid #eee4d4;
    text-align: center;
}
.jew-item-sums > div:last-child { border-left: none; }
.jew-item-sums span {
    display: block;
    font-size: 0.65rem;
    color: #6b6358;
    margin-bottom: 0.1rem;
}
.jew-item-sums b { font-size: 0.72rem; font-weight: 700; }
.jew-item-sums .emph {
    background: linear-gradient(180deg, #f6edd8, #efe2c4);
}
.jew-item-sums .emph b { color: #6e5214; }

.jew-totals {
    margin-top: 0.7rem;
    display: grid;
    grid-template-columns: 1.1fr 0.9fr;
    gap: 0.55rem;
    align-items: start;
}
.jew-totals.single { grid-template-columns: 1fr; }
.jew-totals.single .jew-total-table { max-width: 72%; margin-right: auto; }
.jew-total-table {
    width: 100%;
    min-width: 0 !important;
    border-collapse: collapse;
    border: 1px solid #d8c7a3;
    font-size: 0.8rem;
}
.jew-total-table th,
.jew-total-table td {
    border-bottom: 1px solid #eee4d4;
    padding: 0.32rem 0.5rem;
    text-align: right;
    background: #fff;
}
.jew-total-table th {
    width: 45%;
    background: #faf6ee;
    color: #6a5430;
    font-weight: 600;
}
.jew-total-table tr.grand th,
.jew-total-table tr.grand td {
    background: #f0e3c6;
    border-bottom: none;
    font-size: 0.92rem;
    font-weight: 800;
    color: #5c4312;
}
.jew-notes {
    border: 1px solid #d8c7a3;
    background: #fffdf8;
    padding: 0.45rem 0.55rem;
    min-height: 100%;
}
.jew-notes span {
    display: block;
    font-size: 0.72rem;
    font-weight: 700;
    color: #8a6718;
    margin-bottom: 0.25rem;
}
.jew-notes p {
    margin: 0;
    font-size: 0.8rem;
    color: #2a241c;
}

.jew-footer {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    margin-top: 1.1rem;
}
.jew-sign { text-align: center; }
.jew-sign .line {
    height: 2.2rem;
    border-bottom: 1px solid #b9a784;
    margin-bottom: 0.3rem;
}
.jew-sign span {
    font-size: 0.72rem;
    color: #6b6358;
}
.jew-thanks {
    margin: 0.8rem 0 0;
    text-align: center;
    font-size: 0.75rem;
    color: #8a6718;
    font-weight: 600;
}

@media print {
    .no-print { display: none !important; }
    .print-body {
        background: #fff !important;
        padding: 0 !important;
    }
    .jew-invoice {
        width: 148mm;
        min-height: 210mm;
        margin: 0;
        box-shadow: none;
    }
    .jew-frame { min-height: auto; }
    .jew-spec,
    .jew-total-table,
    table { min-width: 0 !important; }
    @page {
        size: A5 portrait;
        margin: 5mm;
    }
}

@media (max-width: 1100px) {
    .price-ticker { gap: 0.3rem; }
    .price-item { padding: 0.28rem 0.55rem 0.28rem 0.4rem; }
    .price-item .value { font-size: 0.78rem; }
}

@media (max-width: 960px) {
    .nav-toggle { display: inline-flex; }

    .topbar {
        flex-wrap: wrap;
        padding: 0.55rem 0.75rem;
        gap: 0.55rem;
    }
    .topbar-start { flex: 1; min-width: 0; }
    .topbar-brand { min-width: 0; }
    .brand { font-size: 1rem; }
    .today { font-size: 0.7rem; }
    .topbar-username { display: none; }

    .price-ticker {
        order: 3;
        width: 100%;
        justify-content: flex-start;
        flex-wrap: nowrap;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        padding-bottom: 0.1rem;
        gap: 0.35rem;
        scrollbar-width: none;
    }
    .price-ticker::-webkit-scrollbar { display: none; }
    .price-item,
    .price-updated { flex-shrink: 0; }

    .shell { grid-template-columns: 1fr; min-height: calc(100dvh - 7rem); }
    .content { padding: 0.85rem 0.75rem 5rem; }

    .nav-backdrop {
        display: block;
        position: fixed;
        inset: 0;
        background: rgba(20, 14, 8, 0.55);
        z-index: 45;
        opacity: 0;
        pointer-events: none;
        transition: opacity 0.2s ease;
    }
    body.nav-open .nav-backdrop {
        opacity: 1;
        pointer-events: auto;
    }
    body.nav-open { overflow: hidden; }

    .sidebar {
        position: fixed;
        top: 0;
        right: 0;
        bottom: 0;
        width: min(300px, 86vw);
        z-index: 50;
        padding: 0.75rem 0.75rem 1.5rem;
        transform: translateX(105%);
        transition: transform 0.22s ease;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        box-shadow: -12px 0 40px rgba(0, 0, 0, 0.35);
    }
    body.nav-open .sidebar { transform: translateX(0); }

    .sidebar-head {
        display: flex;
        align-items: center;
        justify-content: space-between;
        padding: 0.35rem 0.35rem 0.75rem;
        margin-bottom: 0.35rem;
        border-bottom: 1px solid rgba(244, 212, 138, 0.2);
    }
    .sidebar-title {
        color: #f4d48a;
        font-weight: 700;
    }
    .sidebar-close {
        width: 2.1rem;
        height: 2.1rem;
        border: none;
        border-radius: 10px;
        background: rgba(255, 255, 255, 0.08);
        color: #f4ebe0;
        font-size: 1.4rem;
        line-height: 1;
        cursor: pointer;
    }

    .side-nav { flex-direction: column; }
    .nav-link, .nav-title {
        min-height: 2.6rem;
        padding: 0.7rem 0.85rem;
    }
    .nav-sub {
        border-right: 1px solid rgba(244, 212, 138, 0.2);
        margin-right: 0.55rem;
        padding-right: 0.35rem;
    }

    .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
    .chart-card { height: 240px; }
    .toolbar { align-items: stretch; }
    .toolbar .btn { width: 100%; }
    .actions .btn { flex: 1 1 auto; }
    .form-row.inline > * { min-width: 100%; }
    .field-row > .btn { flex: 1 1 100%; }
    .login-panel { padding: 1.25rem 1.1rem; }
    .login-brand { font-size: clamp(2.1rem, 9vw, 2.8rem); }
    .modal { width: min(560px, 100%); padding: 1rem; }
    .line-box { padding: 0.75rem; }
}

@media (max-width: 640px) {
    .today-sep, .today-date { display: none; }
    .today-time { margin-top: 0; }
    .page-head h1 { font-size: 1.05rem; }
    .stat .value { font-size: 0.95rem; word-break: break-word; }
    .card { padding: 0.75rem; border-radius: 10px; }
    th, td { padding: 0.6rem 0.65rem; font-size: 0.88rem; }
    table { min-width: 520px; }
    .btn { padding: 0.65rem 0.9rem; }
    .currency-toggle { width: 1.9rem; height: 1.9rem; }
    input[type="text"], input[type="password"], input[type="number"], input[type="tel"],
    select, textarea {
        font-size: 16px; /* prevent iOS zoom */
        padding: 0.75rem 0.8rem;
    }
}

@media (max-width: 400px) {
    .brand { font-size: 0.92rem; }
    .topbar-user .btn { padding: 0.35rem 0.55rem; font-size: 0.8rem; }
}
