:root {
    color-scheme: light;
    --bg: #f3f7f7;
    --bg-elev: #eaf1f0;
    --card: #ffffff;
    --card-hi: #f7faf9;
    --border: #dce8e5;
    --border-strong: #c9dbd7;
    --text: #17302e;
    --text-dim: #617572;
    --text-faint: #8ca09c;
    --primary: #087f76;
    --primary-deep: #075d58;
    --primary-soft: #dff3ef;
    --debt: #df5d50;
    --debt-dim: #fff0ed;
    --credit: #138a67;
    --credit-dim: #e3f6ef;
    --gold: #087f76;
    --nav: #102c2d;
    --nav-dim: #a9c3bf;
    --radius-xl: 28px;
    --radius-lg: 20px;
    --radius-md: 15px;
    --radius-sm: 11px;
    --shadow-card: 0 14px 38px rgba(27, 67, 63, .08), 0 2px 8px rgba(27, 67, 63, .04);
    --shadow-float: 0 20px 55px rgba(12, 46, 44, .2);
    --font: 'Vazirmatn', system-ui, -apple-system, sans-serif;
}

html[data-theme="dark"] {
    color-scheme: dark;
    --bg: #101a1b;
    --bg-elev: #172425;
    --card: #1a292a;
    --card-hi: #203132;
    --border: #2b3e3e;
    --border-strong: #3a5150;
    --text: #eef7f5;
    --text-dim: #9eb1ae;
    --text-faint: #718784;
    --primary: #51c5b8;
    --primary-deep: #2ca99b;
    --primary-soft: #183c3a;
    --debt: #ff8276;
    --debt-dim: #3a2423;
    --credit: #51c99a;
    --credit-dim: #19382f;
    --gold: #51c5b8;
    --nav: #0b1516;
    --nav-dim: #91aaa6;
    --shadow-card: 0 16px 44px rgba(0, 0, 0, .2);
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

html, body {
    margin: 0;
    min-height: 100%;
    max-width: 100%;
    overflow-x: hidden;
    background: var(--bg);
    color: var(--text);
    font-family: var(--font);
    -webkit-tap-highlight-color: transparent;
}

body {
    min-height: 100vh;
    min-height: 100dvh;
    background-image:
        linear-gradient(rgba(8, 127, 118, .025) 1px, transparent 1px),
        linear-gradient(90deg, rgba(8, 127, 118, .025) 1px, transparent 1px);
    background-size: 32px 32px;
}

body.no-scroll { overflow: hidden; }

button, input, textarea { font: inherit; }
button { border: 0; cursor: pointer; }
button, a { -webkit-tap-highlight-color: transparent; }
a { color: inherit; }
svg { display: block; }
::selection { background: rgba(8, 127, 118, .2); }

:focus-visible {
    outline: 3px solid rgba(8, 127, 118, .22);
    outline-offset: 3px;
}

/* پوسته اصلی */
.app {
    min-height: 100vh;
    min-height: 100dvh;
    display: grid;
    grid-template-columns: 250px minmax(0, 1fr);
    grid-template-rows: 76px minmax(0, 1fr);
}

.topbar {
    grid-column: 2;
    grid-row: 1;
    position: sticky;
    top: 0;
    z-index: 35;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    padding: 14px clamp(24px, 4vw, 56px);
    background: color-mix(in srgb, var(--bg) 88%, transparent);
    border-bottom: 1px solid color-mix(in srgb, var(--border) 75%, transparent);
    backdrop-filter: blur(18px);
}

.topbar-title { display: flex; align-items: center; gap: 11px; }
.topbar-copy { display: flex; flex-direction: column; }
.topbar-mark { font-weight: 850; font-size: 17px; letter-spacing: -.3px; }
.topbar-sub { color: var(--text-faint); font-size: 10.5px; margin-top: 1px; }

.brand-symbol {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    flex: 0 0 auto;
    color: white;
    background: var(--primary);
    border-radius: 12px 12px 4px 12px;
    box-shadow: 0 9px 20px rgba(8, 127, 118, .2);
}
.brand-symbol svg { width: 21px; height: 21px; }

.topbar-context { display: flex; align-items: center; gap: 8px; }
.today-box { text-align: left; padding-left: 10px; line-height: 1.35; }
.today-label { display: block; color: var(--text-faint); font-size: 9.5px; }
.today-date { display: block; font-size: 11.5px; font-weight: 650; }

.icon-btn {
    width: 40px;
    height: 40px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: var(--text-dim);
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 13px;
    transition: .18s ease;
}
.icon-btn:hover { color: var(--primary); border-color: var(--border-strong); transform: translateY(-1px); }
.icon-btn svg { width: 19px; height: 19px; }
.theme-icon--moon { display: none; }
html[data-theme="dark"] .theme-icon--sun { display: none; }
html[data-theme="dark"] .theme-icon--moon { display: block; }

/* ناوبری */
.tabbar {
    grid-column: 1;
    grid-row: 1 / 3;
    position: fixed;
    inset: 0 0 0 auto;
    z-index: 40;
    width: 250px;
    display: flex;
    flex-direction: column;
    gap: 7px;
    padding: 24px 18px;
    background:
        radial-gradient(circle at 15% 8%, rgba(81, 197, 184, .15), transparent 27%),
        var(--nav);
    color: white;
}

.nav-brand { display: flex; align-items: center; gap: 12px; padding: 1px 6px 34px; }
.nav-brand .brand-symbol { background: #d8fff8; color: #0c5c57; box-shadow: none; }
.nav-brand span:last-child { display: flex; flex-direction: column; }
.nav-brand b { font-size: 18px; }
.nav-brand small { font-size: 10px; color: var(--nav-dim); margin-top: -1px; }
.nav-label { color: #76918d; font-size: 9.5px; font-weight: 700; padding: 0 12px 5px; }

.tab-btn {
    position: relative;
    min-height: 48px;
    width: 100%;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 0 13px;
    color: var(--nav-dim);
    background: transparent;
    border-radius: 13px;
    font-size: 13px;
    font-weight: 580;
    text-align: right;
    transition: .18s ease;
}
.tab-btn svg { width: 20px; height: 20px; flex: 0 0 auto; }
.tab-btn:hover { color: white; background: rgba(255, 255, 255, .055); }
.tab-btn.active { color: #102c2d; background: #d8fff8; font-weight: 750; }
.tab-btn.active::after {
    content: '';
    position: absolute;
    right: -18px;
    width: 4px;
    height: 23px;
    border-radius: 4px 0 0 4px;
    background: #67dacd;
}

.nav-foot {
    margin-top: auto;
    display: flex;
    align-items: center;
    gap: 8px;
    color: #7d9793;
    font-size: 9.5px;
    border-top: 1px solid rgba(255, 255, 255, .08);
    padding: 18px 8px 0;
}
.nav-status-dot { width: 7px; height: 7px; background: #62d9ab; border-radius: 50%; box-shadow: 0 0 0 4px rgba(98, 217, 171, .1); }

.content {
    grid-column: 2;
    grid-row: 2;
    width: min(1180px, 100%);
    margin: 0 auto;
    padding: 34px clamp(24px, 4vw, 56px) 72px;
}

.tab-panel { display: none; animation: panelIn .32s ease both; }
.tab-panel.active { display: block; }
@keyframes panelIn { from { opacity: 0; transform: translateY(7px); } to { opacity: 1; transform: none; } }

/* تیترها و اکشن‌ها */
.page-intro {
    min-height: 108px;
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 30px;
    padding-bottom: 26px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 28px;
}
.page-intro h1 { margin: 5px 0 5px; font-size: clamp(25px, 3vw, 34px); line-height: 1.25; letter-spacing: -.8px; }
.page-intro p { margin: 0; color: var(--text-dim); font-size: 12.5px; }
.eyebrow { display: inline-flex; color: var(--primary); font-size: 9.5px; font-weight: 800; letter-spacing: .2px; }
.eyebrow--light { color: #9df5ea; }

.section-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin: 0 0 13px; }
.section-head--tight { margin-top: 28px; }
.section-head h2 { margin: 0; font-size: 14px; font-weight: 800; letter-spacing: -.2px; }
.count-pill, .debt-total-pill {
    display: inline-flex;
    align-items: center;
    min-height: 25px;
    padding: 3px 9px;
    color: var(--text-dim);
    background: var(--bg-elev);
    border: 1px solid var(--border);
    border-radius: 999px;
    font-size: 9.5px;
    white-space: nowrap;
}
.debt-total-pill { color: var(--debt); background: var(--debt-dim); border-color: color-mix(in srgb, var(--debt) 22%, transparent); }

.secondary-action, .icon-text-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 41px;
    padding: 0 15px;
    border-radius: 12px;
    font-size: 11.5px;
    font-weight: 700;
    transition: .18s ease;
}
.secondary-action { color: white; background: var(--primary); box-shadow: 0 10px 22px rgba(8, 127, 118, .16); }
.secondary-action:hover { background: var(--primary-deep); transform: translateY(-1px); }
.secondary-action svg, .icon-text-btn svg { width: 17px; height: 17px; }
.icon-text-btn { color: var(--text-dim); background: var(--card); border: 1px solid var(--border); }
.icon-text-btn:hover { color: var(--primary); border-color: var(--border-strong); }
.report-actions { display: flex; gap: 8px; }

/* هروی داشبورد */
.dashboard-hero {
    position: relative;
    min-height: 225px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    overflow: hidden;
    margin-bottom: 22px;
    padding: 38px clamp(26px, 5vw, 58px);
    color: #eefdfa;
    background:
        linear-gradient(115deg, rgba(255,255,255,.045) 1px, transparent 1px) 0 0 / 24px 24px,
        linear-gradient(125deg, #0c6660 0%, #0d4d4c 48%, #17373b 100%);
    border-radius: var(--radius-xl);
    box-shadow: 0 25px 60px rgba(10, 67, 63, .18);
}
.dashboard-hero::after {
    content: '';
    position: absolute;
    width: 240px;
    height: 240px;
    left: -80px;
    bottom: -140px;
    border-radius: 50%;
    background: #ef705f;
    filter: blur(2px);
    opacity: .8;
}
.hero-copy { position: relative; z-index: 2; max-width: 500px; }
.hero-copy h1 { margin: 8px 0 10px; font-size: clamp(29px, 4vw, 48px); line-height: 1.2; letter-spacing: -1.5px; }
.hero-copy p { max-width: 440px; margin: 0; color: #c4dedb; font-size: 12.5px; line-height: 1.9; }
.hero-main-label { margin-top: 13px; color: #c4dedb; font-size: 10px; }
.hero-main-value { direction: ltr; width: fit-content; margin-top: 3px; color: white; font-size: clamp(28px, 4vw, 43px); font-weight: 900; letter-spacing: -1.6px; }
.hero-main-value.is-credit { color: #8ee6c3; }
.hero-kpis { display: flex; gap: 10px; margin-top: 19px; }
.hero-kpis > div { min-width: 112px; padding: 9px 11px; background: rgba(255,255,255,.075); border: 1px solid rgba(255,255,255,.1); border-radius: 11px; }
.hero-kpis span { display: block; color: #9fc4c0; font-size: 8.5px; }
.hero-kpis b { direction: ltr; display: block; width: fit-content; margin-top: 4px; color: #f4fffd; font-size: 11px; }
.ledger-visual { position: relative; width: 185px; height: 170px; flex: 0 0 auto; }
.ledger-core {
    position: absolute;
    inset: 43px 51px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    background: #d9fff8;
    color: #0a5f59;
    border-radius: 26px 26px 8px 26px;
    box-shadow: 0 18px 40px rgba(0,0,0,.22);
    transform: rotate(-6deg);
}
.ledger-core i, .ledger-core b { font-style: normal; font-size: 26px; line-height: 1; }
.ledger-core b { color: #ee6e60; margin-top: 8px; }
.ledger-orbit { position: absolute; border: 1px solid rgba(211, 255, 248, .28); border-radius: 50%; }
.ledger-orbit--one { inset: 17px; }
.ledger-orbit--two { inset: -4px 25px 8px 0; transform: rotate(18deg); border-color: rgba(239, 112, 95, .5); }

/* کارت ثبت */
.txn-card {
    position: relative;
    z-index: 3;
    padding: 22px;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-card);
}
.txn-card-head { display: flex; align-items: center; gap: 12px; margin-bottom: 18px; }
.txn-card-head h2 { margin: 0 0 2px; font-size: 15px; }
.txn-card-head p { margin: 0; color: var(--text-faint); font-size: 10.5px; }
.txn-card-icon { width: 39px; height: 39px; display: inline-flex; align-items: center; justify-content: center; color: var(--primary); background: var(--primary-soft); border-radius: 12px; }
.txn-card-icon svg { width: 20px; height: 20px; }
.field-label { display: block; margin: 0 0 7px; color: var(--text-dim); font-size: 10.5px; font-weight: 650; }
.search-field { position: relative; }
.txn-search, .sheet-input, .amount-input, .note-input, .hist-filter-input, .hist-filter-date-field input {
    width: 100%;
    color: var(--text);
    background: var(--card-hi);
    border: 1px solid var(--border);
    border-radius: 12px;
    outline: none;
    transition: border-color .18s, box-shadow .18s, background .18s;
}
.txn-search { height: 50px; padding: 0 15px 0 45px; font-size: 13px; }
.txn-search:focus, .sheet-input:focus, .amount-input:focus, .note-input:focus, .hist-filter-input:focus, .hist-filter-date-field input:focus {
    border-color: color-mix(in srgb, var(--primary) 65%, var(--border));
    background: var(--card);
    box-shadow: 0 0 0 4px rgba(8, 127, 118, .09);
}
.search-shortcut { position: absolute; left: 13px; top: 13px; min-width: 25px; height: 24px; display: grid; place-items: center; color: var(--text-faint); background: var(--bg-elev); border: 1px solid var(--border); border-radius: 7px; font: 11px ui-monospace, monospace; direction: ltr; }
.txn-card-foot { display: flex; align-items: center; gap: 5px; margin-top: 12px; color: var(--text-faint); font-size: 10px; }
.txn-card-foot button { padding: 0; color: var(--primary); background: none; font-weight: 750; }
.suggestions { display: grid; gap: 7px; margin-top: 8px; }
.suggestion-chip { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 11px 13px; background: var(--primary-soft); border: 1px solid color-mix(in srgb, var(--primary) 17%, transparent); border-radius: 10px; cursor: pointer; }
.sg-name { font-size: 12px; font-weight: 750; }
.sg-balance { direction: ltr; font-size: 11px; color: var(--text-dim); }

/* مشتری‌ها */
.customer-tools { margin-bottom: 22px; padding: 15px; background: var(--card); border: 1px solid var(--border); border-radius: var(--radius-md); box-shadow: var(--shadow-card); }
.customer-search-wrap { position: relative; }
.customer-search-wrap svg { position: absolute; right: 13px; top: 12px; width: 19px; height: 19px; color: var(--text-faint); }
.customer-search-wrap input { width: 100%; height: 44px; padding: 0 42px 0 13px; color: var(--text); background: var(--card-hi); border: 1px solid var(--border); border-radius: 12px; outline: 0; font-size: 11px; }
.customer-search-wrap input:focus { border-color: color-mix(in srgb, var(--primary) 65%, var(--border)); box-shadow: 0 0 0 4px rgba(8,127,118,.09); }
.customer-sort { display: flex; gap: 6px; overflow-x: auto; margin-top: 11px; scrollbar-width: none; }
.customer-sort::-webkit-scrollbar { display: none; }
.customer-sort-btn { flex: 0 0 auto; min-height: 34px; padding: 0 11px; color: var(--text-dim); background: var(--bg-elev); border: 1px solid var(--border); border-radius: 10px; font-size: 9.5px; font-weight: 650; }
.customer-sort-btn.active { color: white; background: var(--primary); border-color: var(--primary); }
.customer-sort-hint { margin: 9px 2px 0; color: var(--text-faint); font-size: 8.5px; }
.customer-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.customer-card {
    min-width: 0;
    display: flex;
    align-items: center;
    gap: 11px;
    min-height: 76px;
    padding: 13px;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    transition: .18s ease;
}
.customer-card:hover { transform: translateY(-2px); border-color: var(--border-strong); box-shadow: var(--shadow-card); }
.cc-clickable { cursor: pointer; }
.cc-avatar, .as-avatar {
    display: grid;
    place-items: center;
    flex: 0 0 auto;
    width: 43px;
    height: 43px;
    color: var(--primary-deep);
    background: var(--primary-soft);
    border: 1px solid color-mix(in srgb, var(--primary) 15%, transparent);
    border-radius: 14px 14px 5px 14px;
    font-weight: 850;
}
.cc-body { min-width: 0; flex: 1; }
.cc-name { overflow: hidden; color: var(--text); font-size: 12px; font-weight: 750; text-overflow: ellipsis; white-space: nowrap; }
.cc-phone { direction: ltr; text-align: right; color: var(--text-faint); font-size: 9.5px; margin-top: 3px; }
.cc-insight { direction: rtl; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cc-insight--payments { font-size: 8.5px; line-height: 1.65; white-space: normal; }
.cc-balance { direction: ltr; font-size: 12px; font-weight: 800; white-space: nowrap; }
.negative { color: var(--debt) !important; }
.positive { color: var(--credit) !important; }

.threshold-banner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin: 12px 0;
    padding: 12px 16px;
    background: var(--debt-dim);
    border: 1px solid var(--debt);
    border-radius: 14px;
    color: var(--debt);
    font-size: 12px;
    font-weight: 700;
    cursor: pointer;
    transition: transform .15s ease, box-shadow .15s ease;
}
.threshold-banner:hover { transform: translateY(-1px); box-shadow: 0 8px 18px rgba(223, 93, 80, .18); }
.threshold-banner-arrow { width: 18px; height: 18px; flex: 0 0 auto; }
.zero { color: var(--text-faint) !important; }
.cc-edit, .hist-edit-btn { display: inline-flex; align-items: center; justify-content: center; flex: 0 0 auto; color: var(--text-faint); background: transparent; border-radius: 9px; }
.cc-edit { width: 30px; height: 30px; }
.cc-edit:hover, .hist-edit-btn:hover { color: var(--primary); background: var(--primary-soft); }
.cc-edit svg, .hist-edit-btn svg { width: 15px; height: 15px; }

/* مشتری‌هایی که از حد نصاب بدهی رد کرده‌اند - در همه‌ی لیست‌ها هایلایت قرمز کمرنگ */
.customer-card--over,
.mini-row--over {
    background: var(--debt-dim);
    border-color: color-mix(in srgb, var(--debt) 35%, var(--border));
}
.customer-card--over:hover,
.mini-row--over:hover {
    border-color: var(--debt);
}
.customer-card--over .cc-name,
.mini-row--over .mr-name { color: var(--debt); }

/* لیست‌های داشبورد */
.most-active-row { display: flex; align-items: center; gap: 8px; overflow-x: auto; scrollbar-width: none; margin: 16px 0 2px; }
.most-active-row::-webkit-scrollbar { display: none; }
.active-chip { display: flex; align-items: center; gap: 8px; flex: 0 0 auto; min-height: 37px; padding: 7px 11px; background: var(--card); border: 1px solid var(--border); border-radius: 999px; cursor: pointer; }
.active-chip::before { content: ''; width: 7px; height: 7px; background: var(--primary); border-radius: 50%; }
.ac-name { font-size: 10.5px; font-weight: 700; }
.ac-count { color: var(--text-faint); font-size: 9px; }
.dashboard-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
.dashboard-column { min-width: 0; }
.mini-list { display: grid; gap: 7px; }
.mini-list--grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.mini-row {
    min-width: 0;
    min-height: 58px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 10px 13px;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 13px;
    transition: .16s ease;
}
.mini-row-clickable { cursor: pointer; }
.mini-row-clickable:hover { border-color: var(--border-strong); transform: translateY(-1px); }
.mini-row-left { display: flex; align-items: center; gap: 9px; min-width: 0; }
.mini-row-text { min-width: 0; }
.mr-rank { width: 28px; height: 28px; display: grid; place-items: center; flex: 0 0 auto; color: var(--debt); background: var(--debt-dim); border-radius: 9px; font-size: 10px; font-weight: 850; }
.mr-name { overflow: hidden; font-size: 11px; font-weight: 730; text-overflow: ellipsis; white-space: nowrap; }
.mr-sub { margin-top: 2px; color: var(--text-faint); font-size: 9px; }
.mr-val { direction: ltr; flex: 0 0 auto; font-size: 10.5px; font-weight: 800; white-space: nowrap; }

/* تاریخچه */
.hist-filters { display: grid; grid-template-columns: minmax(180px, 1fr) auto auto; gap: 10px; align-items: end; margin-bottom: 16px; padding: 14px; background: var(--card); border: 1px solid var(--border); border-radius: var(--radius-md); }
.hist-filter-input { height: 42px; padding: 0 13px; font-size: 11px; }
.hist-filter-dates { display: flex; gap: 8px; }
.hist-filter-date-field label { display: block; margin-bottom: 5px; color: var(--text-faint); font-size: 8.5px; }
.hist-filter-date-field input { height: 42px; padding: 0 9px; font-size: 9.5px; direction: ltr; }
.hist-filter-clear { height: 42px; padding: 0 12px; color: var(--text-dim); background: var(--bg-elev); border: 1px solid var(--border); border-radius: 11px; font-size: 9.5px; }
.history-list { display: grid; gap: 8px; }
.hist-row {
    display: grid;
    grid-template-columns: 37px minmax(0, 1fr) auto 28px;
    align-items: center;
    gap: 11px;
    min-height: 72px;
    padding: 11px 13px;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    transition: .16s ease;
}
.hist-row-clickable { cursor: pointer; }
.hist-row-clickable:hover { border-color: var(--border-strong); }
.hist-badge { width: 34px; height: 34px; display: grid; place-items: center; border-radius: 11px; font-size: 15px; font-weight: 800; }
.hist-badge.add { color: var(--debt); background: var(--debt-dim); }
.hist-badge.sub { color: var(--credit); background: var(--credit-dim); }
.hist-info { min-width: 0; }
.hist-name { overflow: hidden; font-size: 11px; font-weight: 760; text-overflow: ellipsis; white-space: nowrap; }
.hist-note { overflow: hidden; margin-top: 2px; color: var(--text-dim); font-size: 9.5px; text-overflow: ellipsis; white-space: nowrap; }
.hist-time, .hist-edited-tag { display: flex; align-items: center; gap: 4px; color: var(--text-faint); font-size: 8.5px; margin-top: 4px; direction: ltr; justify-content: flex-end; }
.hist-time::before, .hist-edited-tag::before {
    content: '';
    flex: 0 0 auto;
    width: 10px;
    height: 10px;
    background-color: currentColor;
    opacity: .75;
    -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none'%3E%3Ccircle cx='12' cy='12' r='8.5' stroke='black' stroke-width='2'/%3E%3Cpath d='M12 7.5V12l3 2' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center / contain no-repeat;
    mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none'%3E%3Ccircle cx='12' cy='12' r='8.5' stroke='black' stroke-width='2'/%3E%3Cpath d='M12 7.5V12l3 2' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center / contain no-repeat;
}
.hist-edited-tag { color: var(--primary); }
.hist-amounts { direction: ltr; text-align: left; }
.hist-amount { font-size: 11.5px; font-weight: 850; }
.hist-after { color: var(--text-faint); font-size: 8.5px; margin-top: 3px; white-space: nowrap; }
.hist-edit-btn { width: 28px; height: 28px; }

.empty-state { grid-column: 1 / -1; min-height: 108px; display: flex; align-items: center; justify-content: center; padding: 24px; color: var(--text-faint); background: var(--card); border: 1px dashed var(--border-strong); border-radius: var(--radius-md); font-size: 11px; text-align: center; }

/* گزارش */
.rp-stat-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; }
.rp-stat { position: relative; overflow: hidden; min-height: 125px; padding: 18px; background: var(--card); border: 1px solid var(--border); border-radius: var(--radius-md); }
.rp-stat::after { content: ''; position: absolute; left: -18px; bottom: -22px; width: 62px; height: 62px; background: var(--bg-elev); border-radius: 50%; }
.rp-stat--debt { border-top: 3px solid var(--debt); }
.rp-stat--credit { border-top: 3px solid var(--credit); }
.rp-stat-label { color: var(--text-dim); font-size: 9.5px; }
.rp-stat-value { direction: ltr; text-align: right; margin-top: 12px; font-size: clamp(16px, 2vw, 21px); font-weight: 850; letter-spacing: -.4px; }
.rp-stat--debt .rp-stat-value { color: var(--debt); }
.rp-stat--credit .rp-stat-value { color: var(--credit); }
.rp-stat-sub { margin-top: 6px; color: var(--text-faint); font-size: 8.8px; }
.rp-insight-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.rp-insight { padding: 16px; background: var(--primary-soft); border: 1px solid color-mix(in srgb, var(--primary) 16%, transparent); border-radius: var(--radius-md); }
.rp-insight-label { color: var(--text-dim); font-size: 9px; }
.rp-insight-value { margin-top: 6px; font-size: 16px; font-weight: 850; }
.rp-insight-note { margin-top: 4px; color: var(--text-faint); font-size: 8.5px; }
.rp-callout { display: flex; align-items: center; justify-content: space-between; gap: 22px; margin-top: 10px; padding: 15px 17px; border: 1px solid var(--border); border-radius: var(--radius-md); }
.rp-callout--warn { background: var(--debt-dim); border-color: color-mix(in srgb, var(--debt) 18%, transparent); }
.rp-callout--good { background: var(--credit-dim); border-color: color-mix(in srgb, var(--credit) 18%, transparent); }
.rp-callout > div { flex: 0 0 auto; }
.rp-callout span { display: block; color: var(--text-dim); font-size: 8.5px; }
.rp-callout b { direction: ltr; display: block; width: fit-content; margin-top: 3px; font-size: 15px; }
.rp-callout p { margin: 0; color: var(--text-dim); font-size: 9px; line-height: 1.8; }
.rp-health-grid { display: grid; grid-template-columns: repeat(4, minmax(0,1fr)); gap: 9px; }
.rp-health { min-height: 92px; padding: 14px; background: var(--card); border: 1px solid var(--border); border-radius: 13px; }
.rp-health span { display: block; min-height: 27px; color: var(--text-dim); font-size: 8.5px; line-height: 1.6; }
.rp-health b { direction: ltr; display: block; width: fit-content; margin-top: 6px; font-size: 13px; }
.rp-health small { display: block; margin-top: 3px; color: var(--text-faint); font-size: 7.5px; }
.rp-period-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.rp-period-card { padding: 16px; background: var(--card); border: 1px solid var(--border); border-radius: var(--radius-md); }
.rp-period-title { margin-bottom: 12px; font-size: 11.5px; font-weight: 800; }
.rp-period-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.rp-period-item { min-width: 0; padding: 11px; border-radius: 11px; }
.rp-period-item--debt { background: var(--debt-dim); }
.rp-period-item--credit { background: var(--credit-dim); }
.rp-period-item-label { display: block; color: var(--text-dim); font-size: 8.5px; }
.rp-period-item-val { direction: ltr; display: block; overflow: hidden; margin-top: 5px; font-size: 10.5px; font-weight: 800; text-align: right; text-overflow: ellipsis; white-space: nowrap; }
.rp-period-item--debt .rp-period-item-val { color: var(--debt); }
.rp-period-item--credit .rp-period-item-val { color: var(--credit); }
.rp-trend { display: inline-flex; margin-top: 5px; padding: 2px 5px; border-radius: 999px; font-size: 7.5px; }
.rp-trend--up { color: var(--debt); background: color-mix(in srgb, var(--debt) 10%, transparent); }
.rp-trend--down { color: var(--credit); background: color-mix(in srgb, var(--credit) 10%, transparent); }
.rp-period-count { margin-top: 9px; color: var(--text-faint); font-size: 8.5px; }
.rp-chart-card { position: relative; min-height: 240px; padding: 18px; background: var(--card); border: 1px solid var(--border); border-radius: var(--radius-md); }
.rp-chart-card h3 { margin: 0 0 15px; font-size: 10px; font-weight: 750; }
.rp-chart-grid { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 10px; }
.rp-person-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.rp-person-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 58px; padding: 11px 13px; background: var(--card); border: 1px solid var(--border); border-radius: 13px; cursor: pointer; transition: .16s ease; }
.rp-person-row:hover { border-color: var(--border-strong); transform: translateY(-1px); }
.rp-person-name { min-width: 0; overflow: hidden; font-size: 10.5px; font-weight: 740; text-overflow: ellipsis; white-space: nowrap; }
.rp-person-phone { display: block; direction: ltr; color: var(--text-faint); font-size: 8px; text-align: right; }
.rp-person-right { flex: 0 0 auto; text-align: left; }
.rp-person-amount { display: block; direction: ltr; font-size: 10px; font-weight: 800; }
.rp-person-amount--debt { color: var(--debt); }
.rp-person-count { display: block; color: var(--text-faint); font-size: 8px; margin-top: 2px; }

/* دستیار هوشمند */
.page-intro--ai { margin-bottom: 18px; }
.ai-chat-card {
    width: min(900px, 100%);
    margin: 0 auto;
    overflow: hidden;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-card);
}
.ai-chat-head {
    min-height: 72px;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 18px;
    background: linear-gradient(135deg, color-mix(in srgb, var(--primary-soft) 78%, var(--card)), var(--card));
    border-bottom: 1px solid var(--border);
}
.ai-chat-head > div { min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.ai-chat-head b { font-size: 14px; }
.ai-chat-head span:not(.ai-orb):not(.ai-online) { color: var(--text-dim); font-size: 12px; }
.ai-orb {
    width: 42px;
    height: 42px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 3px;
    flex: 0 0 auto;
    color: #082f2d;
    background: linear-gradient(145deg, #9df5ea, var(--primary));
    border-radius: 15px 15px 5px 15px;
    box-shadow: 0 9px 22px rgba(81, 197, 184, .2);
}
.ai-orb i { width: 4px; height: 4px; background: currentColor; border-radius: 50%; }
.ai-online { margin-right: auto; display: inline-flex; align-items: center; gap: 6px; color: var(--credit); font-size: 12px; white-space: nowrap; }
.ai-online i { width: 7px; height: 7px; background: currentColor; border-radius: 50%; box-shadow: 0 0 0 4px color-mix(in srgb, var(--credit) 12%, transparent); }
.ai-quick-prompts {
    display: flex;
    gap: 7px;
    overflow-x: auto;
    padding: 12px 14px;
    border-bottom: 1px solid var(--border);
    scrollbar-width: none;
}
.ai-quick-prompts::-webkit-scrollbar { display: none; }
.ai-quick-prompts button {
    min-height: 34px;
    flex: 0 0 auto;
    padding: 0 12px;
    color: var(--text-dim);
    background: var(--bg-elev);
    border: 1px solid var(--border);
    border-radius: 999px;
    font-size: 12px;
    transition: .16s ease;
}
.ai-quick-prompts button:hover { color: var(--primary); border-color: var(--border-strong); transform: translateY(-1px); }
.ai-messages {
    height: min(52vh, 500px);
    min-height: 350px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 15px;
    padding: 22px 18px;
    scroll-behavior: smooth;
}
.ai-empty { margin: auto; color: var(--text-faint); font-size: 13px; }
.ai-message { direction: ltr; display: flex; align-items: flex-end; gap: 8px; justify-content: flex-start; }
.ai-message--user { flex-direction: row-reverse; }
.ai-message-avatar {
    width: 31px;
    height: 31px;
    display: grid;
    place-items: center;
    flex: 0 0 auto;
    color: var(--primary);
    background: var(--primary-soft);
    border: 1px solid color-mix(in srgb, var(--primary) 20%, transparent);
    border-radius: 10px;
    font-size: 10px;
    font-weight: 850;
}
.ai-message--user .ai-message-avatar { color: var(--text-dim); background: var(--bg-elev); border-color: var(--border); }
.ai-message-bubble {
    direction: rtl;
    max-width: min(76%, 650px);
    padding: 11px 14px;
    color: var(--text);
    background: var(--bg-elev);
    border: 1px solid var(--border);
    border-radius: 16px 16px 16px 5px;
    font-size: 13px;
    line-height: 1.95;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}
.ai-message--user .ai-message-bubble { color: #eafffc; background: var(--primary-deep); border-color: transparent; border-radius: 16px 16px 5px 16px; }
.ai-message--pending .ai-message-bubble { color: var(--text-faint); animation: aiPulse 1.2s ease-in-out infinite; }
.ai-message--error .ai-message-bubble { color: var(--debt); background: var(--debt-dim); border-color: color-mix(in srgb, var(--debt) 22%, transparent); }
@keyframes aiPulse { 50% { opacity: .55; } }
.ai-composer {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 46px;
    align-items: end;
    gap: 9px;
    padding: 13px 14px;
    background: var(--card-hi);
    border-top: 1px solid var(--border);
}
.ai-composer textarea {
    width: 100%;
    min-height: 46px;
    max-height: 130px;
    resize: none;
    padding: 11px 13px;
    color: var(--text);
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 13px;
    outline: 0;
    font-size: 13px;
    line-height: 1.75;
}
.ai-composer textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 12%, transparent); }
.ai-composer button { width: 46px; height: 46px; display: grid; place-items: center; color: white; background: var(--primary); border-radius: 13px; transition: .16s ease; }
.ai-composer button:hover { background: var(--primary-deep); transform: translateY(-1px); }
.ai-composer button:disabled { opacity: .55; cursor: wait; transform: none; }
.ai-composer button svg { width: 20px; height: 20px; }
.ai-composer button.is-loading svg { animation: aiSend 1s linear infinite; }
@keyframes aiSend { to { transform: rotate(360deg); } }
.ai-disclaimer { padding: 0 14px 12px; color: var(--text-faint); background: var(--card-hi); font-size: 11px; text-align: center; }

/* صفحات تمام صفحه */
.amount-screen {
    position: fixed;
    inset: 0;
    z-index: 80;
    display: flex;
    justify-content: center;
    overflow-y: auto;
    padding: 20px;
    background: color-mix(in srgb, var(--nav) 76%, transparent);
    backdrop-filter: blur(12px);
    opacity: 0;
    visibility: hidden;
    transition: opacity .22s, visibility .22s;
}
.amount-screen.open { opacity: 1; visibility: visible; }
.amount-screen-inner { width: min(620px, 100%); min-height: min-content; margin: auto; padding: 22px; background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius-xl); box-shadow: var(--shadow-float); transform: translateY(14px) scale(.985); transition: transform .24s ease; }
.amount-screen.open .amount-screen-inner { transform: none; }
.as-topbar, .cs-topbar { display: flex; justify-content: space-between; margin-bottom: 5px; }
.cs-topbar { justify-content: space-between; }
.cs-topbar-left { display: flex; gap: 8px; }
.as-back-btn { width: 39px; height: 39px; display: grid; place-items: center; color: var(--text-dim); background: var(--card); border: 1px solid var(--border); border-radius: 12px; }
.as-back-btn svg { width: 18px; height: 18px; }

/* ماشین حساب */
.calc-overlay { position: fixed; inset: 0; z-index: 200; display: flex; align-items: center; justify-content: center; padding: 18px; background: rgba(7, 29, 29, .58); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); opacity: 0; visibility: hidden; transition: opacity .2s ease, visibility .2s ease; }
.calc-overlay.open { opacity: 1; visibility: visible; }
.calc-box { position: relative; width: min(320px, 100%); padding: 22px; background: var(--card); border: 1px solid var(--border); border-radius: var(--radius-xl); box-shadow: var(--shadow-float); transform: translateY(14px) scale(.985); transition: transform .22s ease; }
.calc-overlay.open .calc-box { transform: none; }
.calc-close { position: absolute; top: 14px; left: 14px; width: 30px; height: 30px; display: grid; place-items: center; color: var(--text-dim); background: var(--bg-elev); border: 1px solid var(--border); border-radius: 50%; }
.calc-close svg { width: 15px; height: 15px; }
.calc-display-row { display: flex; align-items: stretch; gap: 8px; margin: 6px 0 16px; }
.calc-display { flex: 1; min-width: 0; direction: ltr; min-height: 52px; margin: 0; padding: 10px 14px; display: flex; align-items: center; justify-content: flex-end; background: var(--nav); color: white; border-radius: var(--radius-lg); font-size: 26px; font-weight: 850; overflow-x: auto; white-space: nowrap; }
.calc-copy-btn {
    flex: 0 0 auto;
    width: 44px;
    display: grid;
    place-items: center;
    color: var(--text-dim);
    background: var(--bg-elev);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    transition: .15s ease;
}
.calc-copy-btn:hover { color: var(--primary); border-color: var(--primary); background: var(--primary-soft); }
.calc-copy-btn:active { transform: scale(.94); }
.calc-copy-btn svg { width: 17px; height: 17px; }
.calc-grid { display: grid; grid-template-columns: repeat(4, 1fr); grid-auto-rows: 54px; gap: 8px; }
.calc-key { color: var(--text); background: var(--bg-elev); border: 1px solid var(--border); border-radius: 13px; font-size: 16px; font-weight: 750; }
.calc-key:active { transform: scale(.96); }
.calc-key--fn { color: var(--credit); background: var(--credit-dim); }
.calc-key--op { color: var(--primary); background: var(--primary-soft); font-size: 18px; }
.calc-key--eq { grid-column: span 3; color: white; background: var(--primary); font-size: 20px; }
.calc-key--eq:hover { background: var(--primary-deep); }
.as-customer { display: flex; flex-direction: column; align-items: center; padding: 12px 0 20px; text-align: center; }
.as-avatar { width: 58px; height: 58px; margin-bottom: 10px; font-size: 20px; }
.as-name { font-size: 17px; font-weight: 850; }
.cs-phone { direction: ltr; margin-top: 3px; color: var(--text-faint); font-size: 10px; }
.as-balance { direction: ltr; margin-top: 5px; color: var(--text-dim); font-size: 11px; }

/* خلاصه‌ی جمع پرداخت/دریافت در صفحه‌ی مشتری */
.cs-turnover-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 4px 0 16px; }
.cs-turnover-card {
    position: relative;
    min-width: 0;
    padding: 13px 14px;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
}
.cs-turnover-label { display: block; color: var(--text-faint); font-size: 9px; }
.cs-turnover-value { direction: ltr; display: block; width: fit-content; margin-top: 6px; font-size: 13.5px; font-weight: 850; }
.cs-turnover-percent { display: block; margin-top: 5px; font-size: 8.5px; font-weight: 700; }
.cs-turnover-card--in { background: var(--debt-dim); border-color: color-mix(in srgb, var(--debt) 22%, transparent); }
.cs-turnover-card--in .cs-turnover-value { color: var(--debt); }
.cs-turnover-card--out { background: var(--credit-dim); border-color: color-mix(in srgb, var(--credit) 22%, transparent); }
.cs-turnover-card--out .cs-turnover-value,
.cs-turnover-card--out .cs-turnover-percent { color: var(--credit); }

/* یادداشت مشتری */
.cs-note-date { color: var(--text-faint); font-size: 8.5px; }
.cs-note-box {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 10px;
    margin: 10px 0 18px;
    padding: 13px 14px;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
}
.cs-note-text { flex: 1; min-width: 0; margin: 0; color: var(--text-dim); font-size: 11px; line-height: 1.9; white-space: pre-wrap; word-break: break-word; }
.cs-note-text--empty { color: var(--text-faint); font-style: normal; }
.cs-note-edit-btn {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    flex: 0 0 auto;
    padding: 6px 9px;
    color: var(--primary);
    background: var(--primary-soft);
    border-radius: 9px;
    font-size: 9px;
    font-weight: 700;
}
.cs-note-edit-btn svg { width: 13px; height: 13px; }

.as-running { margin-bottom: 18px; padding: 18px; background: var(--nav); color: white; border-radius: var(--radius-lg); text-align: center; }
.as-running-label { display: block; color: var(--nav-dim); font-size: 9px; }
.as-running-value { direction: ltr; min-height: 40px; margin-top: 6px; font-size: 28px; font-weight: 850; }
.quick-grid { display: grid; gap: 8px; margin-bottom: 18px; }
.quick-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 7px; direction: ltr; }
.quick-btn { min-height: 40px; color: var(--text); background: var(--card); border: 1px solid var(--border); border-radius: 11px; font-size: 10.5px; font-weight: 750; }
.quick-row--add .quick-btn { color: var(--debt); background: var(--debt-dim); }
.quick-row--sub .quick-btn { color: var(--credit); background: var(--credit-dim); }
.manual-row { display: grid; grid-template-columns: minmax(0, 1fr) 180px; gap: 9px; margin-bottom: 16px; }
.amount-input { height: 48px; padding: 0 14px; direction: ltr; font-size: 15px; font-weight: 800; }
.sign-toggle { display: grid; grid-template-columns: 1fr 1fr; padding: 3px; background: var(--bg-elev); border: 1px solid var(--border); border-radius: 12px; }
.sign-btn { color: var(--text-faint); background: transparent; border-radius: 9px; font-size: 9.5px; }
.sign-btn--plus.active { color: var(--debt); background: var(--debt-dim); font-weight: 750; }
.sign-btn--minus.active { color: var(--credit); background: var(--credit-dim); font-weight: 750; }
.note-input { min-height: 74px; resize: vertical; padding: 12px 13px; font-size: 11px; line-height: 1.8; }
.reset-btn { width: 100%; margin: 9px 0; padding: 8px; color: var(--text-faint); background: transparent; font-size: 9.5px; }
.confirm-btn { width: 100%; min-height: 48px; display: inline-flex; align-items: center; justify-content: center; color: white; background: var(--primary); border-radius: 13px; font-size: 12px; font-weight: 800; text-decoration: none; box-shadow: 0 10px 25px rgba(8, 127, 118, .17); }
.confirm-btn:hover { background: var(--primary-deep); }
.confirm-btn--sticky { position: sticky; bottom: 0; }

.cs-rating-box {
    width: 100%;
    min-height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 10px 0;
    padding: 10px 16px;
    border-radius: 13px;
    border: 1px solid var(--border);
    background: var(--card);
    text-align: center;
}
.cs-rating-text { color: var(--text-dim); font-size: 11px; font-weight: 700; line-height: 1.7; }
.cs-rating-box--good { background: var(--credit-dim); border-color: color-mix(in srgb, var(--credit) 25%, transparent); }
.cs-rating-box--good .cs-rating-text { color: var(--credit); }
.cs-rating-box--bad { background: var(--debt-dim); border-color: color-mix(in srgb, var(--debt) 25%, transparent); }
.cs-rating-box--bad .cs-rating-text { color: var(--debt); }
.cs-rating-box--neutral { background: var(--warn-dim, rgba(214, 165, 11, .12)); border-color: color-mix(in srgb, var(--warn, #d6a50b) 25%, transparent); }
.cs-rating-box--neutral .cs-rating-text { color: var(--warn, #d6a50b); }
.customer-screen { z-index: 75; }
.customer-screen .amount-screen-inner { width: min(720px, 100%); }

/* شیت‌ها */
.sheet-overlay { position: fixed; inset: 0; z-index: 100; display: flex; align-items: flex-end; justify-content: center; padding: 18px; background: rgba(7, 29, 29, .58); backdrop-filter: blur(8px); opacity: 0; visibility: hidden; transition: .2s ease; }
.sheet-overlay.open { opacity: 1; visibility: visible; }
.sheet { width: min(460px, 100%); padding: 10px 22px 22px; background: var(--card); border: 1px solid var(--border); border-radius: 25px; box-shadow: var(--shadow-float); transform: translateY(24px); transition: transform .22s ease; }
.sheet-overlay.open .sheet { transform: none; }
.sheet-handle { width: 42px; height: 4px; margin: 0 auto 17px; background: var(--border-strong); border-radius: 5px; }
.sheet h3 { margin: 0 0 18px; font-size: 17px; }
.sheet-input { min-height: 45px; padding: 10px 12px; margin-bottom: 13px; font-size: 11.5px; }
.sheet-actions { display: flex; gap: 8px; margin-top: 4px; }
.sheet-cancel, .sheet-confirm, .sheet-delete { min-height: 44px; flex: 1; border-radius: 11px; font-size: 10.5px; font-weight: 750; }
.sheet-cancel { color: var(--text-dim); background: var(--bg-elev); }
.sheet-confirm { color: white; background: var(--primary); }
.sheet-delete { color: var(--debt); background: var(--debt-dim); }
.sheet-cancel--full { width: 100%; margin-top: 8px; }
.edit-log-meta { margin: -3px 0 12px; color: var(--text-faint); font-size: 8.5px; }

/* توست و دکمه شناور */
.toast { position: fixed; z-index: 150; right: 50%; bottom: 24px; min-width: 220px; max-width: calc(100vw - 32px); padding: 12px 16px; color: white; background: #123a37; border: 1px solid rgba(255,255,255,.12); border-radius: 13px; box-shadow: var(--shadow-float); font-size: 11px; text-align: center; opacity: 0; pointer-events: none; transform: translate(50%, 12px); transition: .22s ease; }
.toast.error { background: #8b3731; }
.toast.show { opacity: 1; transform: translate(50%, 0); }
.fab { position: fixed; z-index: 55; left: 28px; bottom: 28px; width: 54px; height: 54px; display: none; align-items: center; justify-content: center; color: white; background: var(--primary); border-radius: 18px 18px 6px 18px; box-shadow: 0 16px 35px rgba(8, 127, 118, .28); }
.fab.visible { display: flex; }
.fab svg { width: 22px; height: 22px; }

/* ورود و نصب */
.login-page, .login-body { display: grid; place-items: center; padding: 24px; background: var(--bg); background-image: radial-gradient(circle at 70% 15%, rgba(81,197,184,.12), transparent 28%), linear-gradient(rgba(81,197,184,.025) 1px, transparent 1px), linear-gradient(90deg,rgba(81,197,184,.025) 1px, transparent 1px); background-size: auto, 30px 30px, 30px 30px; }
.login-wrap, .login-card { width: min(390px, 100%); padding: 32px; background: var(--card); border: 1px solid var(--border); border-radius: 30px; box-shadow: 0 30px 80px rgba(26,75,70,.16); }
.login-wrap { display: flex; flex-direction: column; align-items: center; gap: 22px; }
.login-identity { text-align: center; }
.login-symbol { width: 54px; height: 54px; display: grid; place-items: center; margin: 0 auto 12px; color: white; background: var(--primary); border-radius: 18px 18px 6px 18px; box-shadow: 0 12px 28px rgba(8,127,118,.22); }
.login-symbol svg { width: 27px; height: 27px; }
.login-mark { color: var(--primary); font-size: 10px; font-weight: 850; }
.login-identity h1, .login-card h1 { margin: 5px 0; font-size: 23px; }
.login-sub { color: var(--text-dim); font-size: 10.5px; }
.login-default-pin-hint {
    display: inline-block;
    margin-top: 10px;
    padding: 6px 14px;
    color: var(--primary);
    background: var(--primary-soft);
    border: 1px solid color-mix(in srgb, var(--primary) 25%, transparent);
    border-radius: 10px;
    font-size: 10.5px;
}
.login-default-pin-hint b { direction: ltr; display: inline-block; letter-spacing: 1px; }
.login-pin-status { min-height: 47px; display: flex; flex-direction: column; align-items: center; }
.login-dots { display: flex; gap: 12px; direction: ltr; }
.login-dot { width: 12px; height: 12px; background: var(--bg-elev); border: 1px solid var(--border-strong); border-radius: 50%; transition: .14s ease; }
.login-dot.filled { background: var(--primary); border-color: var(--primary); transform: scale(1.12); }
.login-dots.shake { animation: loginShake .4s; }
@keyframes loginShake { 20%, 60% { transform: translateX(-6px); } 40%, 80% { transform: translateX(6px); } }
.login-error { min-height: 17px; margin-top: 8px; color: var(--debt); font-size: 9.5px; }
.login-pin-input { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.login-keypad { display: grid; grid-template-columns: repeat(3, 64px); gap: 10px; direction: ltr; }
.login-key { width: 64px; height: 54px; display: grid; place-items: center; color: var(--text); background: var(--card-hi); border: 1px solid var(--border); border-radius: 15px; font-size: 17px; font-weight: 750; transition: .12s ease; }
.login-key:hover { color: var(--primary); border-color: var(--border-strong); transform: translateY(-1px); }
.login-key:active { transform: scale(.96); }
.login-key--ghost { visibility: hidden; }
.login-key--del svg { width: 20px; height: 20px; }
.login-secure { display: flex; align-items: center; gap: 6px; color: var(--text-faint); font-size: 9px; }
.login-secure svg { width: 14px; height: 14px; }
.install-card { text-align: right; }
.install-card > .login-mark { width: fit-content; margin: 0 auto; }
.install-card h1 { text-align: center; }
.install-status { padding: 14px; margin: 20px 0 15px; border: 1px solid var(--border); border-radius: var(--radius-md); }
.install-status--ok { background: var(--credit-dim); border-color: color-mix(in srgb, var(--credit) 20%, transparent); }
.install-status--error { background: var(--debt-dim); border-color: color-mix(in srgb, var(--debt) 20%, transparent); }
.install-status-title { font-size: 11.5px; font-weight: 800; }
.install-status-desc { color: var(--text-dim); font-size: 10px; line-height: 1.9; }
.install-status-desc code { direction: ltr; display: inline-block; padding: 1px 5px; background: var(--card); border-radius: 5px; }
.install-error-box { direction: ltr; overflow-wrap: anywhere; margin-top: 9px; padding: 9px; color: var(--text-faint); background: var(--card); border-radius: 8px; font: 9px monospace; text-align: left; }
.install-footnote { margin: 16px 0 0; color: var(--text-faint); font-size: 9px; text-align: center; }

/* تبلت و موبایل */
@media (max-width: 920px) {
    .app { display: block; padding-bottom: 82px; }
    .topbar { grid-column: auto; height: 67px; padding: 10px 16px; }
    .topbar-sub { display: none; }
    .today-box { display: none; }
    .tabbar {
        inset: auto 10px 10px;
        width: auto;
        height: 65px;
        flex-direction: row;
        align-items: center;
        gap: 3px;
        padding: 7px;
        background: color-mix(in srgb, var(--card) 93%, transparent);
        border: 1px solid var(--border);
        border-radius: 20px;
        box-shadow: 0 18px 45px rgba(18, 51, 49, .2);
        backdrop-filter: blur(18px);
    }
    .nav-brand, .nav-label, .nav-foot { display: none; }
    .tab-btn { min-width: 0; min-height: 50px; flex: 1; flex-direction: column; justify-content: center; gap: 2px; padding: 3px; color: var(--text-faint); border-radius: 14px; font-size: 8px; }
    .tab-btn svg { width: 19px; height: 19px; }
    .tab-btn.active { color: var(--primary-deep); background: var(--primary-soft); }
    .tab-btn.active::after { right: auto; bottom: -2px; width: 18px; height: 3px; border-radius: 4px 4px 0 0; background: var(--primary); }
    .content { width: 100%; padding: 20px 16px 36px; }
    .dashboard-hero { min-height: 210px; }
    .fab { left: 20px; bottom: 88px; }
}

@media (max-width: 680px) {
    .brand-symbol { width: 35px; height: 35px; }
    .topbar-mark { font-size: 15px; }
    .icon-btn { width: 37px; height: 37px; border-radius: 12px; }
    .content { padding-top: 16px; }
    .page-intro { min-height: 0; align-items: flex-start; margin-bottom: 22px; padding: 10px 2px 20px; }
    .page-intro h1 { font-size: 25px; }
    .page-intro p { font-size: 10.5px; line-height: 1.8; }
    .secondary-action { min-width: 42px; min-height: 42px; padding: 0; }
    .secondary-action svg { width: 19px; height: 19px; }
    .secondary-action { font-size: 0; }
    .dashboard-hero { min-height: 218px; padding: 27px 23px; border-radius: 24px; }
    .hero-copy { max-width: 78%; }
    .hero-copy h1 { font-size: 31px; }
    .hero-copy p { font-size: 10.5px; line-height: 1.75; }
    .hero-main-label { margin-top: 10px; }
    .hero-main-value { font-size: 27px; letter-spacing: -1px; }
    .hero-kpis { gap: 6px; margin-top: 15px; }
    .hero-kpis > div { min-width: 0; padding: 7px 8px; }
    .hero-kpis span { font-size: 7.5px; }
    .hero-kpis b { font-size: 9px; }
    .ledger-visual { position: absolute; left: -38px; bottom: -9px; width: 150px; height: 140px; opacity: .92; }
    .ledger-core { inset: 38px 41px; }
    .txn-card { padding: 17px; border-radius: 17px; }
    .txn-card-head { margin-bottom: 15px; }
    .dashboard-grid, .customer-list, .mini-list--grid, .rp-period-list, .rp-person-list { grid-template-columns: 1fr; gap: 7px; }
    .dashboard-grid { gap: 0; }
    .hist-filters { grid-template-columns: 1fr; }
    .hist-filter-dates { display: grid; grid-template-columns: 1fr 1fr; }
    .hist-filter-clear { width: 100%; }
    .hist-row { grid-template-columns: 35px minmax(0,1fr) auto 28px; gap: 9px; padding: 10px; }
    .hist-edit-btn { grid-column: 4; grid-row: 1; justify-self: end; margin-top: 0; }
    .rp-stat-grid { grid-template-columns: repeat(2, minmax(0,1fr)); }
    .rp-stat { min-height: 112px; padding: 14px; }
    .rp-insight-grid { grid-template-columns: 1fr; }
    .rp-health-grid { grid-template-columns: repeat(2, minmax(0,1fr)); }
    .rp-chart-grid { grid-template-columns: 1fr; }
    .rp-callout { display: block; }
    .rp-callout p { margin-top: 9px; }
    .report-actions { flex-direction: column; }
    .icon-text-btn { min-height: 34px; padding: 0 10px; font-size: 9px; }
    .page-intro--ai { align-items: center; }
    .ai-chat-card { border-radius: 17px; }
    .ai-chat-head { padding: 12px; }
    .ai-chat-head span:not(.ai-orb):not(.ai-online) { display: none; }
    .ai-messages { height: calc(100dvh - 390px); min-height: 300px; padding: 17px 12px; }
    .ai-message-bubble { max-width: 84%; }
    .ai-message-avatar { width: 29px; height: 29px; }
    .amount-screen { padding: 0; background: var(--bg); }
    .amount-screen-inner, .customer-screen .amount-screen-inner { min-height: 100dvh; width: 100%; margin: 0; padding: 16px; border: 0; border-radius: 0; box-shadow: none; }
    .manual-row { grid-template-columns: 1fr; }
    .sign-toggle { min-height: 44px; }
    .sheet-overlay { padding: 0; }
    .sheet { width: 100%; padding: 10px 18px calc(18px + env(safe-area-inset-bottom)); border-radius: 25px 25px 0 0; }
    .toast { bottom: 92px; }
}

@media (max-width: 370px) {
    .hero-copy h1 { font-size: 27px; }
    .rp-stat-grid { grid-template-columns: 1fr; }
    .login-wrap, .login-card { padding: 25px 20px; }
    .login-keypad { grid-template-columns: repeat(3, 58px); }
    .login-key { width: 58px; }
}

/* خوانایی بهتر متن‌های ریز، بدون تغییر ساختار صفحه */
@media screen {
    body { font-size: 14px; }

    .today-label, .nav-brand small, .nav-label, .nav-foot, .eyebrow,
    .count-pill, .customer-sort-btn, .customer-sort-hint, .cc-phone,
    .cc-insight--payments, .ac-count, .mr-rank, .mr-sub,
    .hist-filter-date-field label, .hist-filter-date-field input,
    .hist-filter-clear, .hist-note, .hist-time, .hist-edited-tag,
    .hist-after, .rp-stat-label, .rp-stat-sub, .rp-insight-label,
    .rp-insight-note, .rp-callout span, .rp-callout p, .rp-health span,
    .rp-health small, .rp-period-item-label, .rp-trend, .rp-period-count,
    .rp-person-phone, .rp-person-count, .as-running-label, .sign-btn,
    .reset-btn, .edit-log-meta, .login-mark, .login-error,
    .login-secure, .install-footnote {
        font-size: 12px;
    }

    .topbar-sub, .today-date, .page-intro p, .hero-copy p,
    .hero-main-label, .hero-kpis span, .txn-card-head p, .field-label,
    .txn-card-foot, .customer-search-wrap input, .ac-name, .mr-name,
    .mr-val, .hist-filter-input, .empty-state, .rp-chart-card h3,
    .rp-person-name, .rp-person-amount, .as-balance, .cs-phone,
    .quick-btn, .note-input, .sheet-input, .sheet-cancel,
    .sheet-confirm, .sheet-delete, .toast, .login-sub,
    .install-status-title, .install-status-desc {
        font-size: 13px;
    }

    .section-head h2, .hero-kpis b, .sg-name, .sg-balance,
    .cc-name, .cc-balance, .hist-name, .hist-amount,
    .rp-period-title, .rp-period-item-val, .confirm-btn {
        font-size: 14px;
    }

    .login-key { font-size: 19px; }
}

@media screen and (max-width: 920px) {
    .tab-btn { font-size: 11px; }
}

@media screen and (max-width: 680px) {
    .page-intro p, .hero-copy p { font-size: 13px; }
    .hero-kpis span { font-size: 11px; }
    .hero-kpis b { font-size: 13px; }
    .icon-text-btn { font-size: 11px; }
    .ai-disclaimer { font-size: 11px; }
}

@media print {
    body { background: white; }
    .tabbar, .topbar, .fab, .page-intro, #tab-add, #tab-view, #tab-history, #tab-ai { display: none !important; }
    .app, .content { display: block; padding: 0; }
    #tab-report { display: block !important; }
    .rp-stat, .rp-period-card, .rp-chart-card, .rp-person-row { break-inside: avoid; box-shadow: none; }
}

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

/* ===================== منوی حساب کاربری (آواتار بالای صفحه) ===================== */

.account-menu-wrap { position: relative; }
.account-trigger {
    display: inline-flex;
    align-items: center;
    gap: 9px;
    height: 40px;
    padding: 4px 5px 4px 12px;
    background: linear-gradient(135deg, rgba(255,255,255,.10), rgba(255,255,255,.02));
    border: 1px solid rgba(255,255,255,.14);
    border-radius: 13px;
    color: var(--text);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    transition: .18s ease;
}
.account-trigger:hover { border-color: var(--border-strong); transform: translateY(-1px); }
.account-avatar {
    display: grid;
    place-items: center;
    flex: 0 0 auto;
    width: 30px;
    height: 30px;
    color: var(--primary-deep);
    background: var(--primary-soft);
    border-radius: 10px 10px 10px 4px;
    font-weight: 850;
    font-size: 12px;
    overflow: hidden;
}
.account-name { font-size: 11.5px; font-weight: 700; white-space: nowrap; color: var(--text); }

.account-menu {
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    z-index: 60;
    width: 210px;
    max-width: calc(100vw - 24px);
    padding: 8px;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 16px;
    box-shadow: var(--shadow-float);
    opacity: 0;
    visibility: hidden;
    transform: translateY(-6px);
    transition: .16s ease;
}
.account-menu.open { opacity: 1; visibility: visible; transform: none; }

.account-menu-item {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    min-height: 44px;
    padding: 0 10px;
    color: var(--text-dim);
    background: transparent;
    border-radius: 11px;
    font-size: 11.5px;
    font-weight: 650;
    text-align: right;
    transition: .15s ease;
}
.account-menu-item:hover, .account-menu-item:active { color: var(--text); background: color-mix(in srgb, var(--primary) 10%, transparent); }
.account-menu-item-icon {
    display: grid;
    place-items: center;
    flex: 0 0 auto;
    width: 30px;
    height: 30px;
    color: var(--text-dim);
    background: var(--bg-elev);
    border: 1px solid var(--border);
    border-radius: 9px;
    transition: .15s ease;
}
.account-menu-item:hover .account-menu-item-icon, .account-menu-item:active .account-menu-item-icon { color: var(--primary); background: var(--card); border-color: var(--primary); }
.account-menu-item svg { width: 15px; height: 15px; flex: 0 0 auto; }
.account-menu-item--danger { color: var(--debt); }
.account-menu-item--danger:hover, .account-menu-item--danger:active { color: var(--debt); background: var(--debt-dim); }
.account-menu-item--danger:hover .account-menu-item-icon, .account-menu-item--danger:active .account-menu-item-icon { color: var(--debt); border-color: var(--debt); }
.account-menu-sep { height: 1px; margin: 6px 4px; background: var(--border); }

@media (max-width: 680px) {
    .account-name { display: inline-block; max-width: 84px; overflow: hidden; text-overflow: ellipsis; }
    .account-trigger { padding: 5px 10px 5px 6px; }
}

/* ===================== صفحه پروفایل صاحب حساب ===================== */

.op-avatar-wrap { position: relative; width: 84px; margin: 6px auto 22px; }
.op-avatar {
    display: grid;
    place-items: center;
    width: 84px;
    height: 84px;
    margin: 0 auto;
    color: var(--primary-deep);
    background: var(--primary-soft);
    border: 1px solid color-mix(in srgb, var(--primary) 15%, transparent);
    border-radius: 26px 26px 8px 26px;
    font-size: 28px;
    font-weight: 850;
    overflow: hidden;
}
.op-avatar-edit {
    position: absolute;
    left: -4px;
    bottom: -4px;
    display: grid;
    place-items: center;
    width: 32px;
    height: 32px;
    color: white;
    background: var(--primary);
    border: 2px solid var(--card);
    border-radius: 50%;
    box-shadow: 0 6px 14px rgba(8, 127, 118, .3);
}
.op-avatar-edit svg { width: 16px; height: 16px; }

.op-headline { text-align: center; font-size: 17px; font-weight: 850; }
.op-subline { margin-top: 3px; text-align: center; color: var(--text-faint); font-size: 10.5px; }

.op-stats-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin: 18px 0 22px; }
.op-stat {
    min-width: 0;
    padding: 12px 10px;
    text-align: center;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
}
.op-stat-label { display: block; color: var(--text-faint); font-size: 8px; line-height: 1.6; }
.op-stat-value { direction: ltr; display: block; margin-top: 6px; font-size: 11.5px; font-weight: 850; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ===================== عکس پروفایل مشتری (در شیت افزودن/ویرایش) ===================== */

.cust-photo-wrap { position: relative; width: 72px; margin: 4px auto 18px; display: flex; flex-direction: column; align-items: center; gap: 8px; }
.cust-photo-preview {
    display: grid;
    place-items: center;
    width: 72px;
    height: 72px;
    color: var(--primary-deep);
    background: var(--primary-soft);
    border: 1px solid color-mix(in srgb, var(--primary) 15%, transparent);
    border-radius: 22px 22px 7px 22px;
    font-size: 22px;
    font-weight: 850;
    overflow: hidden;
}
.cust-photo-edit {
    position: absolute;
    left: -2px;
    bottom: 26px;
    display: grid;
    place-items: center;
    width: 28px;
    height: 28px;
    color: white;
    background: var(--primary);
    border: 2px solid var(--card);
    border-radius: 50%;
    box-shadow: 0 6px 14px rgba(8, 127, 118, .3);
}
.cust-photo-edit svg { width: 14px; height: 14px; }
.cust-photo-remove { padding: 4px 10px; color: var(--debt); background: var(--debt-dim); border-radius: 8px; font-size: 8.5px; font-weight: 700; }

/* ===================== پاپ‌آپ تایید حذف (تایپ DELETE) ===================== */

.confirm-delete-sheet { text-align: center; }
.confirm-delete-icon {
    display: grid;
    place-items: center;
    width: 54px;
    height: 54px;
    margin: 4px auto 14px;
    color: var(--debt);
    background: var(--debt-dim);
    border-radius: 18px;
}
.confirm-delete-icon svg { width: 24px; height: 24px; }
.confirm-delete-sheet h3 { text-align: center; }
.confirm-delete-desc { margin: 0 0 16px; color: var(--text-dim); font-size: 10.5px; line-height: 1.9; text-align: center; }
.confirm-delete-keyword {
    direction: ltr;
    width: fit-content;
    margin: 0 auto 14px;
    padding: 7px 18px;
    color: var(--debt);
    background: var(--debt-dim);
    border: 1px dashed color-mix(in srgb, var(--debt) 45%, transparent);
    border-radius: 10px;
    font-size: 15px;
    font-weight: 850;
    letter-spacing: 2px;
}
.confirm-delete-input { direction: ltr; text-align: center; font-weight: 800; letter-spacing: 1px; }
.sheet-delete--solid { flex: 1; color: white; background: var(--debt); }
.sheet-delete--solid:hover { background: color-mix(in srgb, var(--debt) 85%, black); }
.sheet-delete--solid:disabled { opacity: .45; pointer-events: none; }

/* ===================== صفحه تنظیمات ===================== */

.settings-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    padding: 14px 16px;
    margin-bottom: 10px;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
}
.settings-row-copy { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.settings-row-copy b { font-size: 12px; }
.settings-row-copy span { color: var(--text-faint); font-size: 10px; line-height: 1.6; }
.settings-help {
    padding: 12px 14px;
    margin: -2px 0 14px;
    background: var(--bg-elev);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    color: var(--text-dim);
    font-size: 10.5px;
    line-height: 1.9;
}
.settings-help p { margin: 0 0 6px; }
.settings-help p:last-child { margin-bottom: 0; }

.settings-stepper {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 0 0 auto;
    padding: 6px 10px;
    background: var(--bg-elev);
    border: 1px solid var(--border);
    border-radius: 12px;
}
.settings-stepper-input {
    width: 44px;
    padding: 0;
    background: transparent;
    border: none;
    color: var(--text);
    font-size: 15px;
    font-weight: 800;
    text-align: center;
    direction: ltr;
}
.settings-stepper-input:focus { outline: none; }
.settings-stepper-unit { color: var(--text-faint); font-size: 10.5px; font-weight: 650; white-space: nowrap; }
.settings-inline-save {
    width: 100%;
    justify-content: center;
    margin: -2px 0 14px;
}

.settings-version-badge {
    flex: 0 0 auto;
    padding: 6px 13px;
    color: var(--text-dim);
    background: var(--bg-elev);
    border: 1px solid var(--border);
    border-radius: 999px;
    font-size: 10.5px;
    font-weight: 750;
    direction: ltr;
    white-space: nowrap;
}

.danger-zone-title { color: var(--debt); }
.settings-row--danger {
    border-color: var(--debt-dim);
    background: var(--debt-dim);
}
.icon-text-btn--danger { color: var(--debt); border-color: var(--debt-dim); }
.icon-text-btn--danger:hover { color: white; background: var(--debt); border-color: var(--debt); }
