/* =========================================================
   eris - استایل‌شیت اختصاصی پیور (تم سرمه‌ای و سفید)
   ========================================================= */
:root {
    --navy-900: #0f172a;
    --navy-800: #1e3a8a;
    --navy-700: #1d4ed8;
    --navy-50:  #eff6ff;
    --white:    #ffffff;
    --slate-50: #f8fafc;
    --slate-100:#f1f5f9;
    --slate-200:#e2e8f0;
    --slate-300:#cbd5e1;
    --slate-400:#94a3b8;
    --slate-500:#64748b;
    --slate-600:#475569;
    --slate-800:#1e293b;
    --emerald:  #10b981;
    --emerald-light: #34d399;
    --rose:     #e11d48;
    --rose-light:#fb7185;
    --radius-lg: 16px;
    --radius-md: 12px;
    --radius-sm: 8px;
}

*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: Tahoma, "Segoe UI", system-ui, -apple-system, sans-serif;
    background-color: var(--slate-50);
    color: var(--slate-800);
    line-height: 1.6;
    min-height: 100vh;
    padding-bottom: 48px;
}

/* اسکرول‌بار سفارشی */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--slate-100); }
::-webkit-scrollbar-thumb { background: var(--navy-800); border-radius: 4px; }

.ltr { direction: ltr; text-align: left; }
.hidden { display: none !important; }

/* ---------------- هدر و نوار مظنه ---------------- */
.app-header {
    background: linear-gradient(270deg, var(--navy-900), var(--navy-800));
    color: var(--white);
    box-shadow: 0 4px 14px rgba(15, 23, 42, 0.16);
    position: relative;
}

.header-inner {
    max-width: 1280px;
    margin: 0 auto;
    padding: 12px 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.header-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.brand-wrap {
    display: flex;
    align-items: center;
    gap: 10px;
}

.brand-badge {
    background: rgba(255, 255, 255, 0.14);
    border: 1px solid rgba(255, 255, 255, 0.25);
    padding: 6px 14px;
    border-radius: var(--radius-md);
    font-weight: 700;
    font-size: 1.05rem;
    letter-spacing: 0.5px;
}

.user-welcome {
    font-size: 0.85rem;
    color: #bfdbfe;
}

.mobile-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

/* پنل مظنه */
.mazane-bar {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.18);
    padding: 8px 10px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

.gram18-pill {
    flex: 1;
    background: rgba(15, 23, 42, 0.65);
    border: 1px solid rgba(147, 197, 253, 0.25);
    padding: 7px 12px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    font-size: 0.82rem;
    color: #bfdbfe;
}

.gram18-pill strong {
    color: var(--white);
    font-size: 0.92rem;
}

.btn-refresh-api {
    background: rgba(59, 130, 246, 0.38);
    color: var(--white);
    border: 1px solid rgba(147, 197, 253, 0.3);
    padding: 8px 14px;
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
    transition: background 0.15s;
}
.btn-refresh-api:hover {
    background: rgba(59, 130, 246, 0.6);
}

/* ---------------- دکمه‌ها ---------------- */
.btn {
    border: none;
    border-radius: var(--radius-sm);
    padding: 7px 13px;
    font-family: inherit;
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: 0.15s ease;
}

.btn-white { background: var(--white); color: var(--navy-900); }
.btn-white:hover { background: var(--navy-50); }

.btn-logout { background: rgba(225, 29, 72, 0.22); color: #fecdd3; }
.btn-logout:hover { background: var(--rose); color: var(--white); }

.btn-primary {
    background: var(--navy-900);
    color: var(--white);
    padding: 11px 18px;
    border-radius: var(--radius-md);
    font-size: 0.88rem;
}
.btn-primary:hover { background: var(--navy-800); }

.btn-secondary {
    background: var(--navy-800);
    color: var(--white);
    padding: 9px 14px;
    border-radius: var(--radius-md);
    font-size: 0.8rem;
}
.btn-secondary:hover { background: var(--navy-900); }

/* ---------------- کانتینر اصلی و تب‌ها ---------------- */
.container {
    max-width: 1280px;
    margin: 0 auto;
    padding: 20px 16px;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.tab-content {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.tabs-nav {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    background: var(--white);
    padding: 6px;
    border-radius: 14px;
    border: 1px solid var(--slate-200);
    box-shadow: 0 2px 6px rgba(15, 23, 42, 0.03);
}

.tab-btn {
    width: 100%;
    border: none;
    padding: 11px 16px;
    border-radius: 10px;
    font-family: inherit;
    font-size: 0.88rem;
    font-weight: 600;
    color: var(--slate-600);
    background: transparent;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: all 0.15s ease;
}

.tab-btn:hover {
    background: var(--slate-50);
    color: var(--navy-900);
}

.tab-btn.active {
    background: var(--navy-900);
    color: var(--white);
    font-weight: 700;
    box-shadow: 0 4px 10px rgba(15, 23, 42, 0.14);
}

.tab-count-badge {
    padding: 2px 8px;
    border-radius: 99px;
    font-size: 0.74rem;
    font-weight: 700;
    background: var(--slate-200);
    color: var(--navy-900);
}

.tab-btn.active .tab-count-badge {
    background: rgba(255, 255, 255, 0.22);
    color: var(--white);
}

/* ---------------- کارت‌های گزارش و موجودی ---------------- */
.summary-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
}

.card-hero {
    grid-column: span 2;
    background: var(--navy-900);
    color: var(--white);
    padding: 22px;
    border-radius: var(--radius-lg);
    box-shadow: 0 6px 18px rgba(15, 23, 42, 0.12);
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.card-hero-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    font-size: 0.85rem;
    color: #bfdbfe;
}

.month-select {
    background: rgba(255, 255, 255, 0.12);
    color: var(--white);
    border: 1px solid rgba(255, 255, 255, 0.25);
    padding: 5px 10px;
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 0.8rem;
    outline: none;
}
.month-select option { color: var(--navy-900); }

.net-gold-value {
    font-size: 1.75rem;
    font-weight: 800;
    margin-top: 16px;
    display: flex;
    align-items: baseline;
    gap: 8px;
}
.net-gold-value span.unit {
    font-size: 0.95rem;
    font-weight: 400;
    color: var(--white);
}
.text-positive { color: var(--emerald-light); }
.text-negative { color: var(--rose-light); }

.rial-sub {
    font-size: 0.85rem;
    color: #bfdbfe;
    margin-top: 6px;
}
.rial-sub strong { color: var(--white); }

.stat-card {
    background: var(--white);
    border: 1px solid var(--slate-200);
    border-radius: var(--radius-lg);
    padding: 18px;
    box-shadow: 0 2px 6px rgba(15, 23, 42, 0.03);
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    gap: 12px;
}

.stat-label {
    font-size: 0.82rem;
    color: var(--slate-500);
    font-weight: 600;
}

.stat-number {
    font-size: 1.35rem;
    font-weight: 800;
    color: var(--navy-900);
    display: flex;
    align-items: baseline;
    justify-content: flex-start;
    gap: 6px;
    direction: rtl;
}
.stat-number.out { color: var(--navy-800); }
.stat-number small {
    font-size: 0.8rem;
    font-weight: 400;
    color: var(--slate-400);
}

/* موجودی به تفکیک دسته طلا */
.category-balances-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
}

.cat-balance-card {
    border: 1px solid var(--slate-200);
    background: var(--slate-50);
    padding: 11px 14px;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all 0.15s ease;
}

.cat-balance-card:hover {
    border-color: var(--slate-300);
    background: var(--white);
}

.cat-balance-card.selected {
    border: 1.5px solid var(--navy-800);
    background: var(--navy-50);
}

.cat-balance-label {
    font-size: 0.76rem;
    color: var(--slate-600);
    margin-bottom: 4px;
}

.cat-balance-val {
    font-size: 0.96rem;
    font-weight: 800;
    direction: rtl;
    text-align: right;
}

/* ---------------- باکس سفید و فرم ثبت تراکنش ---------------- */
.panel {
    background: var(--white);
    border: 1px solid var(--slate-200);
    border-radius: var(--radius-lg);
    padding: 20px;
    box-shadow: 0 2px 8px rgba(15, 23, 42, 0.03);
}

.panel-title {
    font-size: 1rem;
    font-weight: 700;
    color: var(--navy-900);
    margin-bottom: 16px;
}

.tx-form {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
    align-items: end;
}

.form-group label {
    display: block;
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--slate-600);
    margin-bottom: 5px;
}

.form-control {
    width: 100%;
    border: 1px solid var(--slate-300);
    border-radius: var(--radius-md);
    padding: 9px 12px;
    font-family: inherit;
    font-size: 0.88rem;
    background: var(--white);
    color: var(--slate-800);
    outline: none;
    transition: border-color 0.15s, box-shadow 0.15s;
}
.form-control:focus {
    border-color: var(--navy-800);
    box-shadow: 0 0 0 3px rgba(30, 58, 138, 0.08);
}

.col-full { grid-column: span 2; }

/* ---------------- لیست معاملات و نوار فیلتر ---------------- */
.table-panel {
    background: var(--white);
    border: 1px solid var(--slate-200);
    border-radius: var(--radius-lg);
    box-shadow: 0 2px 8px rgba(15, 23, 42, 0.03);
    overflow: hidden;
}

.table-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--slate-200);
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.filter-bar {
    background: var(--slate-50);
    padding: 14px 16px;
    border-bottom: 1px solid var(--slate-200);
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.filter-bar-2col {
    grid-template-columns: 1fr;
}

.filter-search {
    grid-column: span 2;
}

.filter-bar .form-control {
    padding: 8px 11px;
    font-size: 0.84rem;
}

.filter-summary-bar {
    background: var(--navy-50);
    border-bottom: 1px solid var(--slate-200);
    padding: 10px 20px;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    font-size: 0.83rem;
    color: var(--navy-900);
}

.empty-state {
    padding: 40px 16px;
    text-align: center;
    color: var(--slate-400);
    font-size: 0.88rem;
}

/* ---------------- تب موجودی کالاها (گرید کارت‌ها) ---------------- */
.inventory-grid {
    padding: 18px 20px;
    display: grid;
    grid-template-columns: 1fr;
    gap: 16px;
}

.inventory-card {
    border: 1px solid var(--slate-200);
    border-radius: var(--radius-lg);
    background: var(--white);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    box-shadow: 0 3px 10px rgba(15, 23, 42, 0.04);
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.inventory-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(15, 23, 42, 0.08);
}

.inv-card-img {
    height: 155px;
    background: var(--slate-100);
    cursor: zoom-in;
    overflow: hidden;
    border-bottom: 1px solid var(--slate-200);
}

.inv-card-img img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.inv-card-body {
    padding: 14px 16px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.inv-card-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.inv-card-date {
    font-size: 0.78rem;
    color: var(--slate-500);
}

.inv-weight-row {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    padding: 4px 0;
}

.inv-weight-row span {
    font-size: 0.82rem;
    color: var(--slate-600);
}

.inv-weight-row strong {
    font-size: 1.08rem;
    color: var(--navy-900);
    direction: rtl;
}

.inv-specs-box {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    background: var(--slate-50);
    border: 1px solid var(--slate-100);
    padding: 10px 12px;
    border-radius: var(--radius-md);
    font-size: 0.8rem;
    color: var(--slate-600);
}

.inv-specs-box strong {
    color: var(--slate-800);
}

.inv-price-tag {
    font-size: 0.84rem;
    font-weight: 700;
    color: var(--navy-800);
    background: var(--navy-50);
    padding: 7px 10px;
    border-radius: var(--radius-sm);
}

.inv-meta-text {
    font-size: 0.78rem;
    color: var(--slate-600);
    line-height: 1.5;
}

.inv-card-actions {
    padding: 10px 14px;
    border-top: 1px solid var(--slate-200);
    background: var(--slate-50);
    display: flex;
    align-items: center;
    gap: 8px;
}

.inv-btn-sell {
    flex: 1;
    padding: 8px 12px;
    font-size: 0.8rem;
}

/* کارت‌های موبایل لیست معاملات */
.mobile-list {
    display: flex;
    flex-direction: column;
}

.mobile-tx-card {
    padding: 14px 16px;
    border-bottom: 1px solid var(--slate-100);
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.mobile-tx-card:last-child { border-bottom: none; }

.mob-card-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.mob-card-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 700;
    font-size: 0.9rem;
}

.mob-specs {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
    background: var(--slate-50);
    padding: 8px 10px;
    border-radius: var(--radius-sm);
    font-size: 0.78rem;
    color: var(--slate-500);
}
.mob-specs strong { color: var(--slate-800); }

.mob-card-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 0.78rem;
    color: var(--slate-400);
}

/* جدول دسکتاپ */
.desktop-table-wrap {
    display: none;
    overflow-x: auto;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    text-align: right;
    font-size: 0.85rem;
}

.data-table thead {
    background: var(--navy-900);
    color: var(--white);
    font-size: 0.79rem;
    white-space: nowrap;
}

.data-table th, .data-table td {
    padding: 13px 12px;
}

.data-table tbody tr {
    border-bottom: 1px solid var(--slate-100);
}
.data-table tbody tr:hover { background: var(--slate-50); }

.badge {
    padding: 3px 9px;
    border-radius: 6px;
    font-size: 0.76rem;
    font-weight: 600;
    display: inline-block;
}
.badge-in { background: #ecfdf5; color: #047857; border: 1px solid #a7f3d0; }
.badge-out { background: var(--navy-50); color: var(--navy-800); border: 1px solid #bfdbfe; }

.weight-pos { color: var(--emerald); font-weight: 700; }
.weight-neg { color: var(--rose); font-weight: 700; }

.btn-delete {
    background: none;
    border: none;
    color: var(--rose);
    font-family: inherit;
    font-size: 0.78rem;
    font-weight: 600;
    cursor: pointer;
    padding: 4px 6px;
}
.btn-delete:hover { text-decoration: underline; }

/* ---------------- مودال‌ها ---------------- */
.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.6);
    display: flex;
    align-items: flex-end;
    justify-content: center;
    z-index: 50;
}

.modal-box {
    background: var(--white);
    width: 100%;
    max-width: 460px;
    border-radius: 20px 20px 0 0;
    padding: 24px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.25);
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

.btn-cancel {
    background: var(--slate-100);
    border: 1px solid var(--slate-200);
    border-radius: var(--radius-sm);
    color: var(--slate-600);
    font-family: inherit;
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    padding: 7px 12px;
    transition: 0.15s;
}
.btn-cancel:hover {
    background: var(--slate-200);
    color: var(--navy-900);
}

/* ---------------- صفحه لاگین ---------------- */
.login-page {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
}

.login-card {
    width: 100%;
    max-width: 410px;
    background: var(--white);
    border: 1px solid var(--slate-200);
    border-radius: 20px;
    overflow: hidden;
    box-shadow: 0 12px 30px rgba(15, 23, 42, 0.1);
}

.login-header {
    background: linear-gradient(270deg, var(--navy-900), var(--navy-800));
    color: var(--white);
    padding: 32px 24px;
    text-align: center;
}

.login-icon {
    width: 54px;
    height: 54px;
    margin: 0 auto 14px;
    background: rgba(255, 255, 255, 0.12);
    border: 1px solid rgba(255, 255, 255, 0.22);
    border-radius: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.login-header h1 { font-size: 1.2rem; margin-bottom: 4px; }
.login-header p { font-size: 0.85rem; color: #bfdbfe; }

.login-body {
    padding: 28px 24px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.alert-error {
    background: #fff1f2;
    color: var(--rose);
    border: 1px solid #fecdd3;
    padding: 10px 12px;
    border-radius: var(--radius-md);
    font-size: 0.82rem;
}

/* ---------------- انتخابگر تاریخ شمسی ---------------- */
.date-picker-wrapper {
    position: relative;
}

.date-input-trigger {
    cursor: pointer;
    background-color: var(--white) !important;
}

.jalali-popover {
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    right: 0;
    min-width: 245px;
    background: var(--white);
    border: 1px solid var(--slate-300);
    border-radius: var(--radius-md);
    box-shadow: 0 12px 28px rgba(15, 23, 42, 0.18);
    padding: 12px;
    z-index: 60;
    direction: rtl;
}

.jalali-popover-title {
    font-size: 0.78rem;
    font-weight: 700;
    color: var(--navy-900);
    margin-bottom: 10px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.jalali-selectors {
    display: grid;
    grid-template-columns: 0.9fr 1.3fr 1.1fr;
    gap: 6px;
    margin-bottom: 10px;
}

.jalali-selectors select {
    padding: 6px 4px;
    border: 1px solid var(--slate-300);
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 0.8rem;
    background: var(--slate-50);
    color: var(--slate-800);
    outline: none;
}

.jalali-selectors select:focus {
    border-color: var(--navy-800);
    background: var(--white);
}

.jalali-popover-actions {
    display: flex;
    justify-content: space-between;
    gap: 6px;
}

/* ---------------- مدیا کوئری‌های تبلت و دسکتاپ ---------------- */
@media (min-width: 768px) {
    .mobile-list { display: none; }
    .desktop-table-wrap { display: block; }

    .category-balances-grid {
        grid-template-columns: repeat(3, 1fr);
    }

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

    .filter-bar-2col {
        grid-template-columns: 2fr 1fr;
    }

    .tx-form { grid-template-columns: repeat(6, 1fr); }
    .note-col { grid-column: span 5; }
    .submit-col { grid-column: span 1; }

    .filter-bar {
        grid-template-columns: repeat(4, 1fr);
        padding: 16px 20px;
    }
    .filter-search {
        grid-column: span 2;
    }

    .modal-backdrop { align-items: center; padding: 16px; }
    .modal-box { border-radius: var(--radius-lg); }
}

@media (min-width: 1024px) {
    .app-header {
        position: sticky;
        top: 0;
        z-index: 40;
    }

    .header-inner {
        flex-direction: row;
        align-items: center;
        justify-content: space-between;
        padding: 14px 20px;
    }

    .header-top {
        flex: 1;
    }

    .mazane-bar {
        padding: 7px 12px;
        gap: 10px;
    }

    .gram18-pill { white-space: nowrap; }

    .summary-grid { grid-template-columns: 2fr 1fr 1fr; }
    .card-hero { grid-column: span 1; }

    .category-balances-grid {
        grid-template-columns: repeat(5, 1fr);
    }

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

    .stat-label { font-size: 0.85rem; }
    .stat-number { font-size: 1.45rem; }

    .filter-bar {
        grid-template-columns: 2fr 1fr 1.2fr 1fr 1fr 0.9fr 0.9fr;
    }
    .filter-search {
        grid-column: span 1;
    }
}