/* ═══════════════════════════════════════════════════════════════════════════
   Sales Ledger — app.css
   RTL, Persian, clean flat design
   ═══════════════════════════════════════════════════════════════════════════ */

/* ── Reset & Base ─────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
    --color-primary:     #3b82f6;
    --color-primary-dk:  #2563eb;
    --color-success:     #22c55e;
    --color-success-dk:  #16a34a;
    --color-warning:     #f59e0b;
    --color-danger:      #ef4444;
    --color-danger-dk:   #dc2626;
    --color-purple:      #8b5cf6;
    --color-orange:      #f97316;

    --bg-body:           #f1f5f9;
    --bg-card:           #ffffff;
    --bg-sidebar:        #1e293b;
    --bg-sidebar-hover:  #334155;
    --bg-topbar:         #ffffff;

    --text-primary:      #0f172a;
    --text-secondary:    #64748b;
    --text-muted:        #94a3b8;
    --text-sidebar:      #cbd5e1;
    --text-sidebar-mute: #64748b;

    --border:            #e2e8f0;
    --border-focus:      #3b82f6;

    --sidebar-width:     260px;
    --topbar-height:     60px;
    --radius:            10px;
    --radius-sm:         6px;
    --shadow:            0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.05);
    --shadow-md:         0 4px 6px rgba(0,0,0,.07), 0 2px 4px rgba(0,0,0,.05);
    --transition:        .18s ease;
}

html { direction: rtl; }

body {
    font-family: 'Vazirmatn', Tahoma, 'Arial', sans-serif;
    font-size: 14px;
    line-height: 1.6;
    color: var(--text-primary);
    background: var(--bg-body);
    min-height: 100vh;
}

a { color: var(--color-primary); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; }
ul, ol { list-style: none; }

/* ── App Layout ───────────────────────────────────────────────────────────── */
.app-wrapper {
    display: flex;
    min-height: 100vh;
}

/* ── Sidebar ──────────────────────────────────────────────────────────────── */
.sidebar {
    width: var(--sidebar-width);
    background: var(--bg-sidebar);
    color: var(--text-sidebar);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    z-index: 200;
    overflow-y: auto;
    transition: transform var(--transition);
}

.sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid rgba(255,255,255,.08);
    min-height: var(--topbar-height);
}

.sidebar-logo {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 700;
    font-size: 14px;
    color: #fff;
}
.logo-icon { font-size: 22px; }

.sidebar-close {
    display: none;
    background: none;
    border: none;
    color: var(--text-sidebar);
    cursor: pointer;
    font-size: 18px;
    padding: 4px;
}

.sidebar-user {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px 20px;
    border-bottom: 1px solid rgba(255,255,255,.06);
}
.user-avatar {
    width: 38px; height: 38px;
    border-radius: 50%;
    background: var(--color-primary);
    color: #fff;
    display: flex; align-items: center; justify-content: center;
    font-size: 16px; font-weight: 700;
    flex-shrink: 0;
}
.user-name  { font-size: 13px; font-weight: 600; color: #fff; }
.user-role  { font-size: 11px; margin-top: 2px; }

/* Nav */
.sidebar-nav { flex: 1; padding: 12px 0; overflow-y: auto; }
.nav-list    { }

.nav-group-label {
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 1px;
    text-transform: uppercase;
    color: var(--text-sidebar-mute);
    padding: 16px 20px 4px;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 20px;
    color: var(--text-sidebar);
    font-size: 13.5px;
    border-radius: 0;
    transition: background var(--transition), color var(--transition);
    border-right: 3px solid transparent;
    text-decoration: none;
}
.nav-link:hover,
.nav-link.active {
    background: var(--bg-sidebar-hover);
    color: #fff;
    text-decoration: none;
    border-right-color: var(--color-primary);
}
.nav-icon { font-size: 16px; flex-shrink: 0; }

.sidebar-footer {
    padding: 12px 0;
    border-top: 1px solid rgba(255,255,255,.06);
}
.nav-logout { color: #fca5a5 !important; }
.nav-logout:hover { background: rgba(239,68,68,.15) !important; color: #f87171 !important; border-right-color: var(--color-danger) !important; }

/* ── Overlay ──────────────────────────────────────────────────────────────── */
.sidebar-overlay {
    display: none;
    position: fixed; inset: 0;
    background: rgba(0,0,0,.45);
    z-index: 199;
}

/* ── Main Content ─────────────────────────────────────────────────────────── */
.main-content {
    flex: 1;
    margin-right: var(--sidebar-width);
    display: flex;
    flex-direction: column;
    min-width: 0;
}

/* ── Topbar ───────────────────────────────────────────────────────────────── */
.topbar {
    height: var(--topbar-height);
    background: var(--bg-topbar);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    padding: 0 24px;
    gap: 16px;
    position: sticky; top: 0; z-index: 100;
    box-shadow: var(--shadow);
}
.hamburger {
    display: none;
    flex-direction: column;
    gap: 4px;
    background: none; border: none;
    cursor: pointer; padding: 6px;
}
.hamburger span {
    display: block;
    width: 22px; height: 2px;
    background: var(--text-secondary);
    border-radius: 2px;
    transition: var(--transition);
}
.topbar-title { font-weight: 600; font-size: 15px; flex: 1; }
.topbar-date  { font-size: 12px; color: var(--text-muted); }

/* ── Page Content ─────────────────────────────────────────────────────────── */
.page-content { padding: 24px; flex: 1; }

/* ── Page Header ──────────────────────────────────────────────────────────── */
.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 24px;
}
.page-title    { font-size: 20px; font-weight: 700; color: var(--text-primary); }
.page-subtitle { font-size: 13px; color: var(--text-muted); }
.page-actions  { display: flex; gap: 8px; flex-wrap: wrap; }

/* ── Cards ────────────────────────────────────────────────────────────────── */
.card {
    background: var(--bg-card);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
    margin-bottom: 20px;
    overflow: hidden;
}
.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
}
.card-title { font-size: 15px; font-weight: 600; }
.card-body  { padding: 20px; }
.card-body.p-0 { padding: 0; }
.card-body.p-3 { padding: 12px; }
.mt-3 { margin-top: 16px; }
.mb-3 { margin-bottom: 16px; }

/* ── Stats Grid ───────────────────────────────────────────────────────────── */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
    margin-bottom: 24px;
}
.stats-grid-2 { grid-template-columns: repeat(2, 1fr); }
.stats-grid-1 { grid-template-columns: 1fr; }

.stat-card {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 16px;
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
    border-right: 4px solid transparent;
}
.stat-blue   { border-right-color: var(--color-primary); }
.stat-green, .stat-success { border-right-color: var(--color-success); }
.stat-purple { border-right-color: var(--color-purple); }
.stat-orange { border-right-color: var(--color-orange); }
.stat-red    { border-right-color: var(--color-danger); }

.stat-icon  { font-size: 28px; flex-shrink: 0; }
.stat-value { font-size: 22px; font-weight: 700; line-height: 1.2; }
.stat-label { font-size: 12px; color: var(--text-muted); margin-top: 2px; }

/* ── Dashboard Grid ───────────────────────────────────────────────────────── */
.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(360px, 1fr));
    gap: 20px;
}

/* ── Tables ───────────────────────────────────────────────────────────────── */
.table-responsive { overflow-x: auto; }

.table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13.5px;
}
.table th,
.table td {
    padding: 10px 16px;
    text-align: right;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}
.table th {
    background: #f8fafc;
    font-weight: 600;
    font-size: 12.5px;
    color: var(--text-secondary);
    text-transform: none;
}
.table tbody tr:last-child td { border-bottom: none; }
.table tbody tr:hover { background: #f8fafc; }
.table-footer td { background: #f8fafc; font-weight: 600; }

/* ── Stackable tables (mobile card layout) ───────────────────────────────────
   Same mechanism as .ui .table.is-stackable in admin-theme.css, but scoped to
   the plain .table used across most views (no .ui wrapper required).
   Usage: add class="table is-stackable" to the <table>, and data-label="..."
   to each <td> (matching its column header). Below 768px each row becomes a
   card instead of relying on horizontal scroll. */
@media (max-width: 768px) {
    .table.is-stackable thead {
        position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
        overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
    }
    .table.is-stackable,
    .table.is-stackable tbody,
    .table.is-stackable tr,
    .table.is-stackable td { display: block; width: 100%; }

    .table.is-stackable tbody tr {
        padding: 10px 14px;
        margin-bottom: 12px;
        border: 1px solid var(--border);
        border-radius: 10px;
        background: #fff;
    }
    .table.is-stackable tbody tr:hover { background: #fff; }

    .table.is-stackable td {
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 10px;
        padding: 7px 0;
        border: none;
        border-bottom: 1px dashed var(--border);
        white-space: normal;
        text-align: left;
    }
    .table.is-stackable td:last-child { border-bottom: none; }
    .table.is-stackable td.sticky-col { position: static; background: transparent; box-shadow: none; }

    /* ستون عملیات: چند دکمه باید بشکنند به خط بعد، نه اینکه توسط flex
       تک‌خطی فشرده/سرریز شوند (رفتار پیش‌فرض flex یعنی nowrap). */
    .table.is-stackable td.actions {
        flex-wrap: wrap; justify-content: flex-start; gap: 8px;
    }

    .table.is-stackable td[data-label]::before {
        content: attr(data-label);
        font-size: 11.5px; font-weight: 700; color: var(--text-muted);
        flex-shrink: 0; text-align: right;
    }

    /* First cell of a row (usually the row's title/name) rendered as a card heading, not a key-value line */
    .table.is-stackable td.is-card-title {
        display: block; text-align: right;
        padding-bottom: 8px; margin-bottom: 8px;
        border-bottom: 1px solid var(--border);
        font-weight: 600;
    }
    .table.is-stackable td.is-card-title::before { content: none; }

    .table.is-stackable tfoot { display: block; }
    .table.is-stackable tfoot tr { background: #f8fafc; }
}

.row-inactive { opacity: 0.55; }
.row-gold   { background: #fffbeb !important; }
.row-silver { background: #f8fafc !important; }
.row-bronze { background: #fef3c7 !important; }

/* Sticky column in commission table */
.sticky-col {
    position: sticky;
    right: 0;
    background: #fff;
    z-index: 10;
    border-left: 1px solid var(--border);
}
.commission-table th.sticky-col { background: #f8fafc; }
.commission-table input { width: 90px; text-align: center; }

/* ── Buttons ──────────────────────────────────────────────────────────────── */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 8px 18px;
    border-radius: var(--radius-sm);
    font-size: 13.5px;
    font-weight: 500;
    font-family: inherit;
    cursor: pointer;
    border: 1px solid transparent;
    transition: background var(--transition), border-color var(--transition), box-shadow var(--transition);
    text-decoration: none !important;
    white-space: nowrap;
}
.btn-block { width: 100%; }

.btn-primary {
    background: var(--color-primary);
    color: #fff;
    border-color: var(--color-primary);
}
.btn-primary:hover { background: var(--color-primary-dk); border-color: var(--color-primary-dk); }

.btn-success {
    background: var(--color-success);
    color: #fff;
    border-color: var(--color-success);
}
.btn-success:hover { background: var(--color-success-dk); border-color: var(--color-success-dk); }

.btn-warning {
    background: var(--color-warning);
    color: #fff;
    border-color: var(--color-warning);
}
.btn-warning:hover { filter: brightness(.9); }

.btn-danger {
    background: var(--color-danger);
    color: #fff;
    border-color: var(--color-danger);
}
.btn-danger:hover { background: var(--color-danger-dk); }

.btn-outline {
    background: transparent;
    color: var(--text-secondary);
    border-color: var(--border);
}
.btn-outline:hover { background: #f1f5f9; border-color: #cbd5e1; color: var(--text-primary); }

.btn-sm   { padding: 6px 14px; font-size: 12.5px; }
.btn-xs   { padding: 4px 10px; font-size: 12px; }
.w-100    { width: 100%; }

/* ── Forms ────────────────────────────────────────────────────────────────── */
.form-card { max-width: 900px; }

.form-row {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    margin-bottom: 4px;
    align-items: flex-start;
}
.form-group { display: flex; flex-direction: column; margin-bottom: 14px; }
.form-group.col-2  { flex: 0 0 calc(16.66% - 10px); min-width: 100px; }
.form-group.col-3  { flex: 0 0 calc(25% - 12px); min-width: 120px; }
.form-group.col-4  { flex: 0 0 calc(33.33% - 11px); min-width: 140px; }
.form-group.col-6  { flex: 0 0 calc(50% - 8px); min-width: 160px; }
.form-group.col-8  { flex: 0 0 calc(66.66% - 6px); min-width: 200px; }
.form-group.col-12 { flex: 0 0 100%; }

.form-label {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 5px;
}
.required { color: var(--color-danger); }

.form-control {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 13.5px;
    font-family: inherit;
    color: var(--text-primary);
    background: #fff;
    transition: border-color var(--transition), box-shadow var(--transition);
    direction: rtl;
}
.form-control:focus {
    outline: none;
    border-color: var(--border-focus);
    box-shadow: 0 0 0 3px rgba(59,130,246,.12);
}
.form-control-sm { padding: 5px 9px; font-size: 12.5px; }
.form-control::placeholder { color: var(--text-muted); }

select.form-control { cursor: pointer; }

.form-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    margin-top: 20px;
    padding-top: 20px;
    border-top: 1px solid var(--border);
}

/* Radio Group */
.radio-group { display: flex; gap: 20px; align-items: center; padding-top: 6px; }
.radio-label { display: flex; align-items: center; gap: 6px; cursor: pointer; font-size: 13.5px; }

/* Input with icon */
.input-with-toggle { position: relative; }
.input-with-toggle .form-control { padding-left: 40px; }
.toggle-password {
    position: absolute;
    left: 10px; top: 50%;
    transform: translateY(-50%);
    background: none; border: none;
    cursor: pointer; font-size: 16px; opacity: .6;
}

/* ── Filter Card ──────────────────────────────────────────────────────────── */
.filter-card .card-body { padding: 16px 20px; }
.filter-form .form-actions { border-top: none; padding-top: 0; margin-top: 8px; }
.align-items-end { align-items: flex-end; }
.d-flex { display: flex; }

/* ── Alerts ───────────────────────────────────────────────────────────────── */
.alert {
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    margin-bottom: 16px;
    font-size: 13.5px;
    border-right: 4px solid transparent;
}
.alert-success { background: #f0fdf4; color: #166534; border-right-color: var(--color-success); }
.alert-error   { background: #fef2f2; color: #991b1b; border-right-color: var(--color-danger);  }
.alert-warning { background: #fffbeb; color: #92400e; border-right-color: var(--color-warning);  }
.alert-info    { background: #eff6ff; color: #1e40af; border-right-color: var(--color-primary);  }

/* ── Badges ───────────────────────────────────────────────────────────────── */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 2px 8px;
    border-radius: 20px;
    font-size: 11.5px;
    font-weight: 600;
    white-space: nowrap;
}
.badge-admin       { background: #ede9fe; color: #5b21b6; }
.badge-seller      { background: #dbeafe; color: #1d4ed8; }
.badge-supervisor  { background: #fdf3e3; color: #b45309; }
.badge-active      { background: #dcfce7; color: #166534; }
.badge-inactive    { background: #f1f5f9; color: #64748b; }
.badge-danger      { background: #fee2e2; color: #991b1b; }
.badge-warning     { background: #fef3c7; color: #92400e; }
.badge-installment { background: #fef3c7; color: #92400e; }
.badge-cash        { background: #dcfce7; color: #166534; }
.badge-today       { background: #dbeafe; color: #1d4ed8; }
.badge-shift       { background: #f1f5f9; color: #475569; }

/* ── Rank Badges ──────────────────────────────────────────────────────────── */
.rank-badge { font-size: 18px; }
.rank-badge:not(.rank-1):not(.rank-2):not(.rank-3) {
    font-size: 13px;
    color: var(--text-muted);
    font-weight: 700;
}

/* ── Report View Grid ─────────────────────────────────────────────────────── */
.report-view-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-bottom: 20px;
}

.info-list { display: grid; grid-template-columns: 120px 1fr; gap: 8px 16px; align-items: start; }
.info-list dt { font-weight: 600; color: var(--text-secondary); font-size: 13px; }
.info-list dd { color: var(--text-primary); }

.total-display { display: flex; flex-direction: column; gap: 16px; }
.total-item { display: flex; justify-content: space-between; align-items: center; padding: 12px 0; border-bottom: 1px solid var(--border); }
.total-item:last-child { border-bottom: none; }
.total-label { font-weight: 600; color: var(--text-secondary); }
.total-value { font-size: 18px; font-weight: 700; }

/* ── Items Section (Report Form) ──────────────────────────────────────────── */
.items-section {
    margin-top: 20px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    margin-bottom: 20px;
}
.items-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    background: #f8fafc;
    border-bottom: 1px solid var(--border);
}
.items-title { font-size: 14px; font-weight: 600; margin: 0; }

/* کلاس واقعی HTML این است (نه .items-header بالا) — قبلاً هیچ استایلی نمی‌گرفت */
.items-section-header {
    display: flex; align-items: center; justify-content: space-between; gap: 10px;
    flex-wrap: wrap;
    padding: 12px 16px;
    background: #f8fafc;
    border-bottom: 1px solid var(--border);
}
.items-section-header #addCustomerBtn { min-height: 40px; }

#groupsContainer { padding: 14px; }

.items-totals-bar {
    display: flex; align-items: center; justify-content: space-between; gap: 12px;
    flex-wrap: wrap;
    padding: 14px 16px;
    background: #f3f6f8;
    border-top: 1px solid var(--border);
    font-size: 14px;
}

.items-table th, .items-table td { white-space: nowrap; vertical-align: middle; }
.items-table .form-control { margin: 0; }
.items-table .select2-container { min-width: 220px; }

/* Report Totals */
.report-totals {
    display: flex;
    gap: 24px;
    flex-wrap: wrap;
    padding: 16px 0;
    border-top: 2px solid var(--border);
    margin-top: 4px;
    margin-bottom: 4px;
}
.total-box {
    font-size: 15px;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 8px;
}
.total-box strong { font-size: 18px; color: var(--text-primary); }
.total-box-green strong { color: var(--color-success); }

/* ── Pagination ───────────────────────────────────────────────────────────── */
.pagination-wrapper {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    padding: 12px 16px;
    border-top: 1px solid var(--border);
}
.page-btn {
    display: inline-flex; align-items: center; justify-content: center;
    width: 34px; height: 34px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 13px;
    color: var(--text-secondary);
    text-decoration: none;
    transition: var(--transition);
}
.page-btn:hover, .page-btn.active {
    background: var(--color-primary);
    color: #fff;
    border-color: var(--color-primary);
    text-decoration: none;
}

/* ── Misc Helpers ─────────────────────────────────────────────────────────── */
.text-success { color: var(--color-success) !important; }
.text-danger  { color: var(--color-danger)  !important; }
.text-muted   { color: var(--text-muted)    !important; }
.text-center  { text-align: center; }
.text-left    { text-align: left; }
.fw-bold      { font-weight: 700; }
.mr-2         { margin-left: 8px; } /* RTL: "right" is actually left visually */
.empty-state  { padding: 32px; text-align: center; color: var(--text-muted); font-size: 14px; }
.actions      { white-space: nowrap; }
.actions .btn + .btn { margin-right: 4px; }

/* ── Auth ─────────────────────────────────────────────────────────────────── */
.auth-body {
    background: linear-gradient(135deg, #1e293b 0%, #334155 100%);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 24px;
}
.auth-container { width: 100%; max-width: 420px; }
.auth-card {
    background: #fff;
    border-radius: 16px;
    padding: 40px 36px;
    box-shadow: 0 20px 60px rgba(0,0,0,.25);
}
.auth-logo { text-align: center; margin-bottom: 28px; }
.auth-logo-icon { font-size: 48px; display: block; margin-bottom: 10px; }
.auth-title { font-size: 18px; font-weight: 700; margin-bottom: 4px; }
.auth-subtitle { font-size: 13px; color: var(--text-muted); }
.auth-form .form-group { margin-bottom: 16px; }
.auth-form .btn-primary { margin-top: 8px; font-size: 15px; padding: 11px; }
.auth-footer { text-align: center; margin-top: 20px; color: var(--text-muted); font-size: 12px; }
.auth-alert { max-width: 420px; margin: 0 auto 16px; }

/* ── Select2 RTL Tweaks ───────────────────────────────────────────────────── */
.select2-container--default .select2-selection--single {
    height: 36px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    direction: rtl;
}
.select2-container--default .select2-selection--single .select2-selection__rendered {
    line-height: 34px;
    padding-right: 12px;
    padding-left: 28px;
    font-family: 'Vazirmatn', Tahoma, sans-serif;
    font-size: 13.5px;
    color: var(--text-primary);
}
.select2-container--default .select2-selection--single .select2-selection__arrow {
    left: 6px; right: auto;
}
.select2-dropdown { direction: rtl; font-family: 'Vazirmatn', Tahoma, sans-serif; font-size: 13.5px; }
.select2-results__option { padding: 8px 12px; }
.select2-container--default .select2-results__option--highlighted { background-color: var(--color-primary) !important; }
.select2-search__field { direction: rtl; font-family: 'Vazirmatn', Tahoma, sans-serif; }

/* ── Persian Datepicker Tweaks ────────────────────────────────────────────── */
.datepicker-plot-area { direction: rtl; font-family: 'Vazirmatn', Tahoma, sans-serif; }

/* ── Seller Name in commission table ──────────────────────────────────────── */
.seller-name { min-width: 140px; }



.customer-card {
    border: 1px solid var(--border, #e2e8f0);
    border-radius: 12px;
    margin-bottom: 16px;
    overflow: hidden;
    background: #fff;
    box-shadow: 0 1px 4px rgba(0,0,0,.06);
}

.customer-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    background: #f1f5f9;
    font-weight: 700;
    font-size: 15px;
    border-bottom: 1px solid var(--border, #e2e8f0);
}

.item-count {
    font-weight: 400;
    font-size: 12px;
    color: #64748b;
}

.items-list {
    padding: 8px 0;
}

.item-row {
    padding: 10px 16px;
    border-bottom: 1px dashed #e2e8f0;
}
.item-row:last-child { border-bottom: none; }

.item-name {
    font-weight: 600;
    font-size: 14px;
    margin-bottom: 6px;
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.item-details {
    display: flex;
    flex-wrap: wrap;
    gap: 8px 20px;
    font-size: 13px;
    color: #475569;
}

.item-details label {
    color: #94a3b8;
    font-size: 12px;
}

.customer-card-footer {
    display: flex;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 8px;
    padding: 12px 16px;
    background: #f8fafc;
    border-top: 2px solid var(--border, #e2e8f0);
    font-size: 13px;
    font-weight: 600;
}

.grand-total {
    display: flex;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 8px;
    padding: 14px 20px;
    background: #0f172a;
    color: #fff;
    border-radius: 12px;
    font-weight: 700;
    font-size: 14px;
    margin-top: 8px;
}

.grand-total .text-success { color: #4ade80 !important; }

@media (max-width: 480px) {
    .customer-card-footer,
    .grand-total { flex-direction: column; gap: 4px; }
    .item-details { gap: 6px 16px; }
}



/* ── Print Styles ─────────────────────────────────────────────────────────── */
@media print {
    .sidebar, .topbar, .page-header .btn, .page-header .page-actions,
    .filter-card, .form-actions, .pagination-wrapper, .actions { display: none !important; }
    .main-content { margin-right: 0 !important; }
    .page-content { padding: 0 !important; }
    .card { box-shadow: none !important; border: 1px solid #ddd !important; }
    body { background: #fff !important; font-size: 12px; }
    .table th, .table td { padding: 6px 10px !important; }
}

/* ── Responsive ───────────────────────────────────────────────────────────── */
@media (max-width: 1024px) {
    .stats-grid { grid-template-columns: repeat(2, 1fr); }
    .report-view-grid { grid-template-columns: 1fr; }
    .dashboard-grid { grid-template-columns: 1fr; }
}

@media (max-width: 768px) {
    .sidebar {
        transform: translateX(100%);
    }
    .sidebar.open {
        transform: translateX(0);
    }
    .sidebar-close { display: block; }
    .sidebar-overlay.open { display: block; }

    .main-content { margin-right: 0; }
    .hamburger { display: flex; }

    .stats-grid { grid-template-columns: 1fr 1fr; }
    .page-content { padding: 16px; }

    .form-group.col-2,
    .form-group.col-3,
    .form-group.col-4,
    .form-group.col-6,
    .form-group.col-8 { flex: 0 0 100%; }

    .commission-table { font-size: 12px; }
    .commission-table .form-control { width: 70px; }

    /* Touch targets: bump interactive controls to the ~44px minimum comfortable tap size on mobile,
       without touching desktop density where a mouse pointer makes the smaller size fine. */
    .btn { min-height: 44px; padding: 10px 18px; }
    .btn-sm { min-height: 40px; padding: 9px 16px; }
    .btn-xs { min-height: 36px; padding: 7px 12px; }

    .form-control,
    select.form-control { min-height: 44px; padding: 10px 12px; font-size: 15px; }
    .form-control-sm { min-height: 40px; }

    .page-btn { width: 44px; height: 44px; }

    .select2-container--default .select2-selection--single { height: 44px; }
    .select2-container--default .select2-selection--single .select2-selection__rendered { line-height: 42px; }
    .select2-container--default .select2-selection--single .select2-selection__arrow { height: 42px; }

    input[type="checkbox"],
    input[type="radio"] { width: 20px; height: 20px; }

    .actions .btn + .btn { margin-right: 6px; margin-bottom: 6px; }
}

@media (max-width: 480px) {
    .stats-grid { grid-template-columns: 1fr; }
    .auth-card { padding: 28px 20px; }
    .table th, .table td { padding: 8px 10px; font-size: 12.5px; }
}
@media (max-width: 768px) {
    #items-table thead { display: none; }

    #items-table tr.item-row {
        display: block;
        border: 1px solid #ddd;
        border-radius: 8px;
        margin-bottom: 12px;
        padding: 8px;
        background: #fff;
    }

    #items-table tr.item-row td {
        display: flex;
        align-items: center;
        justify-content: space-between;
        padding: 4px 0;
        border: none;
    }

    #items-table tr.item-row td::before {
        content: attr(data-label);
        font-weight: bold;
        font-size: 12px;
        color: #555;
        min-width: 90px;
    }

    #items-table tr.item-row td .form-control {
        width: 100% !important;
    }
}

/* ── گروه مشتری ─────────────────────────────────────────────────────────── */
.customer-group {
    border: 1px solid var(--border);
    border-radius: 12px;
    background: #fafbfc;
    margin-bottom: 14px;
    overflow: hidden;
}
.customer-group:last-child { margin-bottom: 0; }

.group-header {
    display: flex; align-items: center; justify-content: space-between; gap: 10px;
    flex-wrap: wrap;
    padding: 12px 14px;
    background: #fff;
    border-bottom: 1px solid var(--border);
}
.group-label { font-size: 14px; font-weight: 700; color: var(--text-primary); }
.group-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.group-actions .btn-xs { min-height: 36px; padding: 8px 12px; }

/* ── ردیف تخفیف گروه ────────────────────────────────────────────────────── */
.group-discount-row {
    display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
    padding: 10px 14px;
    background: #f3f6f8;
    border-bottom: 1px solid var(--border);
}
.discount-field { display: flex; align-items: center; gap: 6px; }
.discount-field label { font-size: 12.5px; font-weight: 600; color: #3d4b5c; white-space: nowrap; }
.discount-percent-input { width: 70px !important; text-align: center; padding: 8px 6px !important; }
.discount-percent-input:disabled { background: #eef2f6; color: #94a3b8; cursor: not-allowed; }
.discount-qty-hint, .discount-lock-hint {
    font-size: 11.5px; color: #b45309; font-weight: 600;
    background: #fdf3e3; padding: 3px 10px; border-radius: 999px;
}
.discount-lock-hint { color: #be123c; background: #fdeaee; }

/* ── سوییچ قابل‌استفاده‌ی مجدد (اسنپ‌پی، تخفیف تعدادی) ───────────────────── */
.switch-field { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; user-select: none; }
.switch { position: relative; display: inline-block; inline-size: 42px; block-size: 24px; flex-shrink: 0; }
.switch input[type="checkbox"] {
    position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer; z-index: 1; inline-size: 100%; block-size: 100%;
}
.switch-slider {
    position: absolute; inset: 0; background: #cbd5e1; border-radius: 999px;
    transition: background .15s ease; pointer-events: none;
}
.switch-slider::before {
    content: ""; position: absolute; inline-size: 18px; block-size: 18px;
    inset-block-start: 3px; inset-inline-start: 3px;
    background: #fff; border-radius: 50%; transition: inset-inline-start .15s ease;
    box-shadow: 0 1px 2px rgba(0,0,0,.25);
}
.switch input:checked + .switch-slider { background: var(--color-primary, #0f6e6a); }
.switch input:checked + .switch-slider::before { inset-inline-start: 21px; }
.switch input:disabled + .switch-slider { opacity: .5; cursor: not-allowed; }
.switch-text { font-size: 12.5px; font-weight: 600; color: #3d4b5c; }

/* ── کارت هر محصول ──────────────────────────────────────────────────────── */
.group-items-body { display: flex; flex-direction: column; gap: 10px; padding: 12px; }

.item-card {
    border: 1px solid #dee2e6;
    border-radius: 10px;
    padding: 12px;
    background: #fff;
    position: relative;
}

.item-card-grid {
    display: grid;
    grid-template-columns: 2fr 1fr 1fr auto 1.2fr;
    gap: 10px;
    align-items: end;
}

.item-field { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.item-field label { font-size: 11px; color: #6c757d; margin: 0; display: flex; align-items: center; gap: 4px; }
.item-field--switch { align-items: flex-start; justify-content: center; }
.item-field--readonly .line-total {
    background: #eef2f6 !important; color: #3d4b5c; font-weight: 700;
    border-color: #dfe6ed !important; cursor: default;
}

.item-card .remove-row { margin-top: 10px; min-height: 36px; padding: 8px 12px; }

@media (max-width: 768px) {
    .items-section-header { flex-direction: column; align-items: stretch; }
    .items-section-header #addCustomerBtn { width: 100%; }
    .items-totals-bar { flex-direction: column; align-items: stretch; gap: 8px; }

    /* دو کنترل تخفیفِ گروه در موبایل هرکدام یک ردیف کامل، برای تارگت لمسی راحت */
    .group-discount-row { flex-direction: column; align-items: stretch; gap: 10px; }
    .discount-field { justify-content: space-between; }
    .discount-percent-input { flex: 1; max-width: none !important; width: auto !important; }

    .item-card-grid {
        grid-template-columns: 1fr 1fr;
    }
    .item-field--product,
    .item-field--switch,
    .item-field--readonly {
        grid-column: 1 / -1;
    }
    .item-field--switch { flex-direction: row; align-items: center; justify-content: flex-start; gap: 8px; padding-block: 4px; }
}

/* ══ نوار اکشن چسبان ورودی + خلاصهٔ زنده + اسنک‌بار بازگردانی ═══════════════ */

/* هایلایت مشتری فعال — بدون محو کردن بقیه، فقط حلقهٔ ملایم */
.customer-group { transition: box-shadow .15s ease, border-color .15s ease; }
.customer-group.is-active-group {
    border-color: var(--color-primary, #0f6e6a);
    box-shadow: 0 0 0 1px var(--color-primary, #0f6e6a), 0 3px 12px rgba(15,110,106,.13);
}

/* موبایل: نوار شناور در قوس شست */
.entry-actionbar {
    position: fixed; inset-inline: 0; bottom: 0; z-index: 40;
    display: flex; flex-direction: column; gap: 8px;
    background: #fff; border-top: 1px solid var(--border);
    box-shadow: 0 -4px 18px rgba(16,23,32,.10);
    padding: 8px 12px calc(8px + env(safe-area-inset-bottom, 0px));
}
.entry-actionbar-summary {
    display: flex; align-items: center; justify-content: center; gap: 18px;
    font-size: 13px; color: #3d4b5c;
}
.entry-actionbar-summary .ea-metric strong { font-weight: 800; font-size: 15px; color: #101720; margin-inline-start: 4px; }
.entry-actionbar-summary .ea-metric--comm strong { color: var(--color-success, #15803d); }

.entry-actionbar-actions { display: flex; gap: 8px; }
.entry-actionbar-actions .ea-add-product { flex: 1 1 auto; min-height: 52px; font-size: 15px; font-weight: 700; }
.entry-actionbar-actions .ea-add-customer { flex: 0 0 auto; min-height: 52px; padding: 0 16px; font-weight: 700; }

/* فضای پایین صفحه تا نوار شناور، دکمهٔ ثبت را نپوشاند (فقط صفحات دارای فرم) */
@media (max-width: 767px) {
    body.has-entry-actionbar .form-actions { margin-bottom: 140px; }
}

/* اسنک‌بار بازگردانی */
.entry-snackbar {
    position: fixed; inset-inline: 12px; bottom: 136px; z-index: 50;
    display: flex; align-items: center; justify-content: space-between; gap: 12px;
    background: #101720; color: #fff; border-radius: 10px; padding: 12px 14px;
    box-shadow: 0 8px 24px rgba(0,0,0,.28);
    opacity: 0; transform: translateY(8px);
    transition: opacity .18s ease, transform .18s ease;
    pointer-events: none;
}
.entry-snackbar.show { opacity: 1; transform: none; pointer-events: auto; }
.entry-snackbar-text { font-size: 13.5px; font-weight: 600; }
.entry-snackbar-undo {
    background: none; border: none; color: #7dd3c0; font: inherit; font-weight: 800;
    font-size: 14px; cursor: pointer; padding: 6px 8px; white-space: nowrap; flex-shrink: 0;
}

/* دسکتاپ/تبلت: نوار از حالت شناور به جریان عادیِ زیر لیست برمی‌گردد */
@media (min-width: 768px) {
    .entry-actionbar {
        position: static; box-shadow: none;
        flex-direction: row; align-items: center; justify-content: space-between;
        border: 1px solid var(--border); border-radius: var(--radius);
        margin-top: 14px; padding: 12px 16px;
    }
    .entry-actionbar-summary { justify-content: flex-start; }
    .entry-actionbar-actions { flex: 0 0 auto; }
    .entry-actionbar-actions .ea-add-product,
    .entry-actionbar-actions .ea-add-customer { min-height: 42px; }
    .entry-snackbar { inset-inline: auto; inset-inline-end: 24px; bottom: 24px; max-width: 360px; }
}

.ranking-grid{
display:grid;
grid-template-columns:repeat(auto-fill,minmax(260px,1fr));
gap:18px;
}

.ranking-card{
background:#fff;
border-radius:12px;
padding:16px;
box-shadow:0 4px 14px rgba(0,0,0,.05);
border:1px solid #eee;
transition:.2s;
}

.ranking-card:hover{
transform:translateY(-3px);
box-shadow:0 6px 18px rgba(0,0,0,.08);
}

.ranking-header{
display:flex;
align-items:center;
gap:10px;
margin-bottom:10px;
}

.rank-number{
background:#eee;
padding:3px 8px;
border-radius:6px;
font-size:12px;
}

.ranking-name{
font-weight:700;
}

.ranking-stats{
display:flex;
justify-content:space-between;
margin:10px 0;
font-size:13px;
}

.ranking-products{
font-size:12px;
color:#666;
margin:10px 0;
}

.ranking-balance{
margin-top:10px;
padding-top:10px;
border-top:1px solid #eee;
text-align:center;
}

.balance-value{
font-weight:700;
font-size:16px;
}

.rank-gold{
border-top:4px solid #FFD700;
}

.rank-silver{
border-top:4px solid #C0C0C0;
}

.rank-bronze{
border-top:4px solid #CD7F32;
}


