/* ============ زرپ بینش — نسخهٔ موبایل (روی سیستم طراحی مشترک app.css) ============ */
body.mobile { padding-bottom: env(safe-area-inset-bottom); overscroll-behavior-y: contain; -webkit-tap-highlight-color: transparent; }

.m-top {
    position: sticky; top: 0; z-index: 30; display: flex; align-items: center; gap: 10px;
    padding: calc(10px + env(safe-area-inset-top)) 14px 10px; background: var(--bg); background: color-mix(in srgb, var(--bg) 82%, transparent);
    backdrop-filter: blur(16px); border-bottom: 1px solid var(--line);
}
.m-logo { width: 36px; height: 36px; border-radius: 11px; box-shadow: 0 6px 18px rgba(99,102,241,.45); }
.m-title { flex: 1; min-width: 0; }
.m-title b { display: block; font-size: 15.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.m-title small { color: var(--muted); font-size: 11.5px; }
.m-icon { position: relative; width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; font-size: 19px; background: var(--card); border: 1px solid var(--line); color: var(--text); }
.m-badge { position: absolute; top: -5px; left: -5px; min-width: 19px; height: 19px; padding: 0 4px; border-radius: 10px; background: var(--bad); color: #fff; font-size: 11px; font-style: normal; font-weight: 700; display: grid; place-items: center; }

.m-content { padding: 12px 12px calc(92px + env(safe-area-inset-bottom)); max-width: 1100px; margin: 0 auto; }
.m-scroll { overflow-x: auto; margin: 0 -12px 10px; padding: 0 12px; scrollbar-width: none; }
.m-scroll::-webkit-scrollbar { display: none; }
.m-scroll .seg { white-space: nowrap; }

.m-nav {
    position: fixed; bottom: 0; left: 0; right: 0; z-index: 40; display: flex; justify-content: space-around;
    padding: 8px 6px calc(8px + env(safe-area-inset-bottom)); background: var(--card-solid); background: color-mix(in srgb, var(--card-solid) 88%, transparent);
    backdrop-filter: blur(18px); border-top: 1px solid var(--line);
}
.m-nav a { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: 11px; color: var(--muted); padding: 4px 0; border-radius: 12px; }
.m-nav a span { font-size: 21px; line-height: 1.15; transition: transform .15s; }
.m-nav a.active { color: var(--accent); font-weight: 700; }
.m-nav a.active span { transform: translateY(-2px) scale(1.12); }

/* هیچ ستونی به‌خاطر متن بلند از صفحه بیرون نزند */
body.mobile .grid > *, body.mobile .hero > * { min-width: 0; }
body.mobile { overflow-x: hidden; }
body.mobile .seg { max-width: 100%; overflow-x: auto; scrollbar-width: none; flex-wrap: nowrap; }
body.mobile .seg::-webkit-scrollbar { display: none; }
body.mobile .seg button { flex: none; }
body.mobile .bar { max-width: 100%; }
body.mobile .dt { max-width: 100%; min-height: 0; }
body.mobile .card, body.mobile .content { max-width: 100%; }

/* WebView قدیمی بدون flex gap (راست‌به‌چپ: فاصله سمت راستِ عنصر بعدی) */
html.nogap .m-top > * + *, html.nogap .brand-big > * + *, html.nogap .bar > * + *, html.nogap .seg > * + *,
html.nogap .tools > * + *, html.nogap .card-h > * + *, html.nogap .say > * + * { margin-right: 8px; }
html.nogap .m-nav a > * + *, html.nogap .tile > * + * { margin-top: 2px; }

/* قهرمان صفحهٔ «امروز» */
.hero { display: grid; grid-template-columns: 240px 1fr; gap: 12px 20px; align-items: center; margin-bottom: 16px; padding: 18px; }
.ring-wrap { position: relative; width: 220px; height: 220px; margin: 0 auto; grid-row: span 2; }
.ring { width: 100%; height: 100%; transform: rotate(-90deg); }
.ring-track { fill: none; stroke: var(--card2); stroke-width: 16; }
.ring-fill { fill: none; stroke-width: 16; stroke-linecap: round; transition: stroke-dasharray 1.2s cubic-bezier(.2,.8,.2,1); filter: drop-shadow(0 0 8px rgba(99,102,241,.55)); }
.ring-fill2 { fill: none; stroke: #FBBF24; stroke-width: 9; stroke-linecap: round; opacity: .9; }
.ring-center { position: absolute; top: 0; right: 0; bottom: 0; left: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; }
.ring-center small { color: var(--muted); font-size: 12.5px; }
.ring-center b { font-size: 34px; letter-spacing: -.5px; }
.hero-msg .say { margin: 0; }
.hero-chips { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.hchip { background: var(--card2); border-radius: 14px; padding: 10px 8px; text-align: center; border: 1px solid var(--line); }
.hchip span { font-size: 20px; display: block; }
.hchip b { font-size: 18px; display: block; }
.hchip small { color: var(--muted); font-size: 11px; line-height: 1.4; display: block; }
.hchip.hot { background: linear-gradient(135deg, rgba(251,146,60,.25), rgba(239,68,68,.18)); border-color: rgba(251,146,60,.5); }
.hchip.hot span { animation: flame 1.2s ease-in-out infinite alternate; }
@keyframes flame { from { transform: scale(1) rotate(-4deg); } to { transform: scale(1.18) rotate(4deg); } }

.badges { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; margin-bottom: 8px; }
.badge-card { border-radius: 16px; padding: 12px; text-align: center; background: var(--card); border: 1px solid var(--line); filter: grayscale(1); opacity: .5; }
.badge-card.on { filter: none; opacity: 1; background: linear-gradient(160deg, var(--accent-soft), var(--card)); border-color: var(--line2); border-color: color-mix(in srgb, var(--accent) 40%, transparent); box-shadow: 0 8px 22px rgba(99,102,241,.18); }
.badge-card span { font-size: 30px; display: block; }
.badge-card b { display: block; font-size: 13.5px; margin-top: 2px; }
.badge-card small { color: var(--muted); font-size: 11px; }

.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 10px; margin-bottom: 16px; }
.tile { display: flex; flex-direction: column; gap: 2px; padding: 14px; border-radius: 18px; background: var(--card); border: 1px solid var(--line); color: var(--text); box-shadow: var(--shadow); transition: transform .12s; }
.tile:active { transform: scale(.97); }
.tile span { font-size: 26px; }
.tile b { font-size: 14.5px; }
.tile small { color: var(--muted); font-size: 11.5px; }

/* ورود */
.login { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.login-card { width: min(420px, 100%); background: var(--card); border: 1px solid var(--line); border-radius: 24px; padding: 26px 22px; box-shadow: var(--shadow); backdrop-filter: blur(14px); }
.login-card label { display: block; margin: 12px 0 4px; color: var(--muted); font-size: 13px; }
.login-card input { width: 100%; padding: 11px 12px; font-size: 15px; }
.brand-big { display: flex; align-items: center; gap: 12px; margin-bottom: 10px; }
.brand-big img { width: 56px; height: 56px; border-radius: 16px; box-shadow: 0 10px 28px rgba(99,102,241,.45); }
.brand-big b { display: block; font-size: 22px; }
.brand-big small { color: var(--muted); }

/* کوچک‌کردن سیستم طراحی برای گوشی */
@media (max-width: 760px) {
    .grid { gap: 10px; margin-bottom: 10px; }
    .c3 { grid-column: span 6; }
    .c4, .c5, .c6, .c7, .c8, .c9 { grid-column: span 12; }
    .card { padding: 12px 12px 14px; border-radius: 16px; }
    .kpi { padding: 12px 12px 8px; }
    .kpi .val { font-size: 19px; }
    .kpi .ico { width: 32px; height: 32px; font-size: 16px; border-radius: 10px; }
    .kpi .note { font-size: 11px; }
    .section { margin: 18px 2px 8px; } .section h2 { font-size: 17px; }
    .say { font-size: 13px; padding: 10px 12px; }
    .story { padding: 10px 12px; } .story p { font-size: 12.5px; }
    .hero { grid-template-columns: 1fr; padding: 14px; }
    .ring-wrap { width: 200px; height: 200px; grid-row: auto; }
    .hero-chips { grid-template-columns: repeat(2, 1fr); }
    .drawer { width: 100vw; padding: calc(12px + env(safe-area-inset-top)) 12px 90px; }
    .card-h .ct .btn.ghost.sm:nth-child(n+2) { display: none; } /* فقط اکسل یا تمام‌صفحه */
    .tbl-wrap { max-height: 420px !important; }
    .search { width: 140px; }
    .dt-col { width: 190px; }
    .card.fs { top: 0; right: 0; bottom: 0; left: 0; border-radius: 0; }
    .big-num { font-size: 20px; }
}

/* جشن (کاغذ رنگی) */
.zc-confetti { position: fixed; top: -12px; width: 9px; height: 14px; z-index: 300; pointer-events: none; border-radius: 2px; animation: zc-fall linear forwards; }
@keyframes zc-fall { to { transform: translateY(105vh) rotate(720deg); opacity: .2; } }

/* چاپ / PDF: فقط خود گزارش */
@media print {
    .m-nav, .m-top .m-icon, .drawer, .toast { display: none !important; }
    .m-top { position: static; backdrop-filter: none; }
    .m-content { padding-bottom: 12px; }
}

/* ---------------------------------------------------------------- «زنده» (گزارش لحظه‌ای) */
.live-head { display: flex; align-items: center; margin: 2px 2px 10px; }
.live-head > * + * { margin-right: 8px; }
.live-head b { font-size: 16px; }
.live-head small { color: var(--muted); font-size: 12px; margin-right: auto !important; }
.live-dot { width: 11px; height: 11px; border-radius: 50%; background: #EF4444; box-shadow: 0 0 0 0 rgba(239,68,68,.6); animation: live-pulse 1.6s infinite; flex: none; }
.live-dot.off { background: var(--faint); animation: none; box-shadow: none; }
@keyframes live-pulse { 0% { box-shadow: 0 0 0 0 rgba(239,68,68,.55); } 70% { box-shadow: 0 0 0 10px rgba(239,68,68,0); } 100% { box-shadow: 0 0 0 0 rgba(239,68,68,0); } }
.live-hero { text-align: center; padding: 18px 16px 16px; margin: 12px 0 14px; }
.live-hero > small { color: var(--muted); font-size: 13px; }
.live-big { margin: 2px 0 6px; line-height: 1.15; }
.live-big b { font-size: 46px; font-weight: 800; background: linear-gradient(135deg, #22D3EE, #818CF8); -webkit-background-clip: text; background-clip: text; color: transparent; }
.live-big span { color: var(--muted); font-size: 14px; margin-right: 6px; }
.live-delta { display: inline-block; font-size: 13.5px; font-weight: 700; padding: 5px 12px; border-radius: 999px; background: var(--card2); color: var(--muted); margin-bottom: 14px; }
.live-delta.up { background: var(--good-soft); color: var(--good); }
.live-delta.down { background: var(--bad-soft); color: var(--bad); }
.live-delta small { font-weight: 400; opacity: .85; margin-right: 4px; }
.live-pace { padding: 14px 16px; margin-bottom: 14px; }
.live-pace-t { display: flex; align-items: center; }
.live-pace-t > span { font-size: 30px; margin-left: 12px; }
.live-pace-t b { display: block; font-size: 15.5px; }
.live-pace.ahead .live-pace-t b { color: var(--good); }
.live-pace.behind .live-pace-t b { color: var(--warn); }
.live-pace-t small { color: var(--muted); font-size: 12px; }
.live-bar { position: relative; height: 12px; border-radius: 999px; background: var(--card2); margin: 12px 0 8px; overflow: visible; }
.live-bar i { display: block; height: 100%; border-radius: 999px; background: linear-gradient(90deg, #818CF8, #22D3EE); transition: width .8s ease; }
.live-pace.ahead .live-bar i { background: linear-gradient(90deg, #FBBF24, #34D399); }
.live-bar em { position: absolute; top: -4px; bottom: -4px; width: 3px; margin-right: -1.5px; border-radius: 2px; background: var(--text); opacity: .55; }
.live-proj { font-size: 12.5px; color: var(--muted); }
.live-tags { margin-top: 8px; }
.live-tags .chip { display: inline-block; margin: 0 0 6px 6px; }
.live-row { position: relative; display: flex; align-items: center; justify-content: space-between; padding: 8px 2px 10px; border-bottom: 1px solid var(--line); }
.live-row:last-child { border-bottom: 0; }
.live-row b { display: block; font-size: 13.5px; font-weight: 600; }
.live-row small { color: var(--muted); font-size: 11.5px; }
.live-row span { font-weight: 700; font-size: 14px; white-space: nowrap; margin-right: 10px; }
.live-row i { position: absolute; right: 0; bottom: 3px; height: 3px; border-radius: 3px; background: var(--accent); opacity: .55; }
.live-feed { display: grid; grid-gap: 8px; margin-bottom: 18px; }
.live-item { display: grid; grid-template-columns: 58px 1fr auto; align-items: center; background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 10px 12px; }
.live-item > * + * { margin-right: 10px; }
.live-item.big { border-color: rgba(52,211,153,.55); background: linear-gradient(135deg, var(--good-soft), var(--card)); }
.live-item.ret .live-amt { color: var(--bad); }
.live-item.new { animation: live-new 2.4s ease-out; }
@keyframes live-new { 0% { box-shadow: 0 0 0 3px rgba(34,211,238,.8); transform: scale(1.02); } 100% { box-shadow: 0 0 0 0 rgba(34,211,238,0); transform: none; } }
.live-time { font-weight: 700; font-size: 15px; text-align: center; line-height: 1.2; }
.live-time small { display: block; font-weight: 400; font-size: 10.5px; color: var(--muted); }
.live-body { min-width: 0; }
.live-body b { display: block; font-size: 13.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.live-body b .badge { margin-right: 6px; font-size: 10.5px; }
.live-body small { display: block; color: var(--muted); font-size: 11.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.live-amt { font-weight: 800; font-size: 15px; white-space: nowrap; }
@media (max-width: 760px) {
    .live-big b { font-size: 40px; }
    .live-chips { grid-template-columns: repeat(2, 1fr); }
}

/* ---------------------------------------------------------------- CRM */
.crm-stats { display: grid; grid-template-columns: repeat(4, 1fr); grid-gap: 8px; margin-bottom: 12px; }
.crm-stats .hchip b { font-size: 16px; }
.crm-card { display: block; background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 12px 14px; margin-bottom: 10px; color: var(--text); text-decoration: none; cursor: pointer; }
.crm-card.late { border-color: rgba(239,68,68,.5); }
.crm-card-h { display: flex; align-items: center; justify-content: space-between; }
.crm-card-h b { font-size: 14.5px; }
.crm-card-h .badge { margin-right: 8px; white-space: nowrap; }
.crm-card > small { display: block; color: var(--muted); font-size: 12.5px; margin-top: 4px; line-height: 1.7; }
.crm-actions { margin-top: 10px; }
.crm-actions .btn { margin: 0 0 6px 6px; }
.crm-search, .crm-form input, .crm-form textarea, .crm-log textarea, .crm-log input { width: 100%; box-sizing: border-box; padding: 11px 12px; border-radius: 12px; border: 1px solid var(--line2); background: var(--card2); color: var(--text); font: inherit; font-size: 14px; margin-bottom: 10px; }
.crm-person { display: flex; align-items: center; padding: 10px 4px; border-bottom: 1px solid var(--line); color: var(--text); text-decoration: none; }
.crm-person > * + * { margin-right: 10px; }
.av { width: 40px; height: 40px; flex: none; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-weight: 800; color: #fff; background: linear-gradient(135deg, #6366F1, #22D3EE); }
.av.big { width: 56px; height: 56px; font-size: 22px; }
.pp { flex: 1; min-width: 0; }
.pp b { display: block; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pp small, .pr small { color: var(--muted); font-size: 11.5px; }
.pr { text-align: left; }
.pr .bal { display: block; color: var(--warn); margin-top: 3px; }
.kanban { display: flex; overflow-x: auto; padding-bottom: 8px; margin: 0 -4px 12px; -webkit-overflow-scrolling: touch; scroll-snap-type: x mandatory; }
.kan-col { flex: 0 0 78%; max-width: 300px; margin: 0 4px; background: var(--card2); border-radius: 14px; padding: 10px; scroll-snap-align: start; }
.kan-h { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 8px; }
.kan-h small { color: var(--muted); font-size: 11.5px; }
.kan-card { display: block; background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 10px; margin-bottom: 8px; color: var(--text); text-decoration: none; }
.kan-card b { display: block; font-size: 13.5px; }
.kan-card small { display: block; color: var(--muted); font-size: 11.5px; margin: 2px 0 6px; }
.kan-card .chip { display: inline-block; margin: 0 0 0 6px; font-size: 11px; }
.chip.late { color: var(--bad); }
.fab { position: fixed; left: 18px; bottom: calc(84px + env(safe-area-inset-bottom)); width: 58px; height: 58px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 30px; color: #fff; text-decoration: none; background: linear-gradient(135deg, #6366F1, #22D3EE); box-shadow: 0 10px 26px rgba(99,102,241,.5); z-index: 30; }
.crm-top { margin-bottom: 10px; }
.crm-top .btn { margin-left: 6px; }
.crm-head { padding: 14px; margin-bottom: 12px; }
.crm-head > b { display: block; font-size: 18px; }
.crm-head > small { color: var(--muted); }
.crm-who { display: flex; align-items: center; }
.crm-who > * + * { margin-right: 12px; }
.crm-who b { display: block; font-size: 18px; }
.crm-who small { color: var(--muted); display: block; margin-bottom: 4px; }
.crm-who .badge { margin-left: 4px; }
.stage-steps { display: flex; flex-wrap: wrap; margin-top: 10px; }
.stage-steps button { border: 1px solid var(--line2); background: var(--card2); color: var(--text); border-radius: 999px; padding: 6px 10px; font: inherit; font-size: 12px; margin: 0 0 6px 6px; cursor: pointer; }
.stage-steps button.on { background: linear-gradient(135deg, #6366F1, #818CF8); color: #fff; border-color: transparent; font-weight: 700; }
.stage-steps button.won.on { background: linear-gradient(135deg, #10B981, #34D399); }
.stage-steps button.lost.on { background: linear-gradient(135deg, #EF4444, #F87171); }
.crm-log, .crm-form { padding: 14px; margin-bottom: 12px; }
.crm-log > b, .crm-form > b { display: block; margin-bottom: 10px; font-size: 15px; }
.crm-form label { display: block; font-size: 12.5px; color: var(--muted); margin: 2px 0 4px; }
.crm-log > small { display: block; color: var(--muted); margin-bottom: 4px; }
.chips { margin-bottom: 8px; }
.chips .chip { border: 1px solid var(--line2); background: var(--card2); color: var(--text); font: inherit; font-size: 12.5px; padding: 6px 11px; border-radius: 999px; margin: 0 0 6px 6px; cursor: pointer; }
.chips .chip.on { background: var(--accent); color: #fff; border-color: transparent; }
.pick { border: 1px solid var(--line2); border-radius: 12px; margin: -6px 0 10px; overflow: hidden; }
.pick button { display: flex; justify-content: space-between; width: 100%; padding: 10px 12px; border: 0; border-bottom: 1px solid var(--line); background: var(--card); color: var(--text); font: inherit; text-align: right; cursor: pointer; }
.pick small { color: var(--muted); }
.timeline { margin-bottom: 18px; }
.tl { display: flex; padding: 8px 0; border-bottom: 1px dashed var(--line); }
.tl > i { font-style: normal; font-size: 18px; width: 34px; flex: none; text-align: center; }
.tl small { color: var(--muted); font-size: 11.5px; }
.tl p { margin: 4px 0 0; font-size: 13px; line-height: 1.8; }
.neg { color: var(--bad); }
@media (max-width: 760px) {
    .crm-stats { grid-template-columns: repeat(2, 1fr); }
}
