:root {
  --bg: #0b0f14;
  --bg2: #121821;
  --card: #161d28;
  --line: #243044;
  --gold: #d4a017;
  --gold2: #f0c14b;
  --accent: #2ee6a6;
  --red: #e85d5d;
  --silver: #b8c4d4;
  --text: #e8eef6;
  --muted: #8b9bb0;
  --blue: #4ea1ff;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { min-height: 100%; background: var(--bg); color: var(--text); font-family: Vazirmatn, sans-serif; }
a { color: var(--gold2); }
button, input, select, textarea { font-family: inherit; }
.login-wrap {
  min-height: 100vh;
  display: grid;
  place-items: center;
  background:
    radial-gradient(700px 380px at 78% 12%, rgba(180,120,20,.22), transparent 55%),
    radial-gradient(900px 500px at 100% 80%, rgba(40,30,10,.35), transparent),
    linear-gradient(180deg, #07090d 0%, #0b0f14 55%, #10141c 100%);
  padding: 12px;
  overflow: hidden;
}
.login-scene {
  --h: min(92vh, 680px);
  position: relative;
  height: var(--h);
  width: min(960px, 96vw);
  direction: ltr;
}
.login-mascot {
  position: absolute;
  left: 8px;
  bottom: 0;
  height: 100%;
  width: auto;
  z-index: 3;
  pointer-events: none;
  user-select: none;
  object-fit: contain;
  object-position: right bottom;
}
.login-card {
  position: absolute;
  left: calc(8px + var(--h) * 0.328);
  top: 4%;
  width: min(430px, calc(100% - var(--h) * 0.28));
  height: 92%;
  z-index: 2;
  background: linear-gradient(180deg, #1c2430, #141b24);
  border: 1px solid #2a3546;
  border-radius: 22px;
  padding: 28px 28px 20px;
  box-shadow: 0 28px 70px rgba(0,0,0,.5);
  overflow: auto;
  box-sizing: border-box;
}
@media (max-width: 760px) {
  .login-scene {
    --h: 240px;
    height: auto;
    min-height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
  }
  .login-mascot {
    position: relative;
    left: auto;
    height: 240px;
    margin-bottom: -36px;
  }
  .login-card {
    position: relative;
    left: auto;
    top: auto;
    width: min(430px, 94vw);
    height: auto;
  }
}
.brand {
  display: flex; align-items: center; gap: 12px; margin-bottom: 8px;
}
.lynx {
  width: 46px; height: 46px; border-radius: 12px;
  background: linear-gradient(135deg, #d4a017, #7a4d00);
  display: grid; place-items: center; font-weight: 800; color: #111;
}
.logo-lynx { width: 72px; height: 72px; object-fit: contain; background: #000; border-radius: 14px; }
.logo-lynx-sm { width: 52px; height: 52px; object-fit: contain; background: #000; border-radius: 12px; }
.logo-msp { height: 48px; object-fit: contain; background: #fff; border-radius: 10px; padding: 4px 8px; }
.logo-msp-sm { height: 36px; object-fit: contain; background: #fff; border-radius: 8px; padding: 3px 6px; }
.logo-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.invoice-logos { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.invoice-logos img { height: 56px; object-fit: contain; }
.login-card h1 { font-size: 22px; }
.login-card p.sub { color: var(--muted); margin: 6px 0 22px; font-size: 13px; }
label { display: block; font-size: 13px; color: var(--muted); margin: 12px 0 6px; }
input, select, textarea {
  width: 100%; background: #0e141c; border: 1px solid var(--line); color: var(--text);
  border-radius: 10px; padding: 11px 12px; outline: none;
}
textarea { min-height: 80px; resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: var(--gold); }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: 0; border-radius: 10px; padding: 11px 16px; cursor: pointer; font-weight: 600;
}
.btn-gold { background: linear-gradient(180deg, #f0c14b, #c48a0a); color: #1a1404; width: 100%; margin-top: 18px; }
.btn-green { background: #1f8a62; color: #fff; }
.btn-blue { background: #2b6cb0; color: #fff; }
.btn-red { background: #8a2d2d; color: #fff; }
.btn-ghost { background: transparent; border: 1px solid var(--line); color: var(--text); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.hint { margin-top: 16px; font-size: 12px; color: var(--muted); line-height: 1.7; background: #0e141c; padding: 10px; border-radius: 10px; }
.app { display: grid; grid-template-columns: 260px 1fr; min-height: 100vh; }
.side {
  background: #0e141c; border-left: 1px solid var(--line); padding: 20px 14px;
  display: flex; flex-direction: column; gap: 6px;
}
.side .brand { padding: 4px 8px 16px; }
.nav-btn {
  background: transparent; border: 0; color: var(--muted); text-align: right;
  padding: 10px 12px; border-radius: 10px; cursor: pointer; font-weight: 500;
}
.nav-btn.active, .nav-btn:hover { background: #1a2330; color: var(--text); }
.main { padding: 22px 26px 40px; }
.topbar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 22px; gap: 12px; flex-wrap: wrap; }
.user-chip { font-size: 13px; color: var(--muted); }
.grid { display: grid; gap: 14px; }
.kpis { grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); }
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 16px 18px;
}
.kpi .lbl { color: var(--muted); font-size: 12px; }
.kpi .val { font-size: 22px; font-weight: 800; margin-top: 6px; }
.badge {
  display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 700;
  padding: 4px 10px; border-radius: 999px;
}
.b-gold { background: rgba(240,193,75,.15); color: var(--gold2); }
.b-silver { background: rgba(184,196,212,.15); color: var(--silver); }
.b-red { background: rgba(232,93,93,.15); color: var(--red); }
.b-green { background: rgba(53,208,127,.15); color: #35d07f; }
.b-blue { background: rgba(78,161,255,.15); color: var(--blue); }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.dot.gold { background: var(--gold2); }
.dot.silver { background: var(--silver); }
.dot.red { background: var(--red); }
.dot.green { background: #35d07f; }
.dot.blue { background: var(--blue); }
tr.row-ok { background: rgba(53,208,127,.10); }
tr.row-err { background: rgba(232,93,93,.10); }
.chipbar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin: 0 0 12px; }
.chip {
  cursor: pointer; border: 1px solid var(--line); background: transparent; color: var(--muted);
  border-radius: 999px; padding: 5px 14px; font-size: 12px; font-weight: 600;
}
.chip:hover { color: var(--text); }
.chip.active { background: #1a2330; color: var(--gold2); border-color: var(--gold); }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { padding: 10px 8px; border-bottom: 1px solid var(--line); text-align: right; }
th { color: var(--muted); font-weight: 500; }
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.row3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 12px; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }
.status { font-size: 12px; padding: 3px 8px; border-radius: 8px; background: #243044; }
.timeline { border-right: 2px solid var(--line); padding-right: 14px; margin: 10px 8px; }
.tl-item { margin-bottom: 12px; }
.tl-item small { color: var(--muted); }
.invoice {
  background: #fff; color: #111; border-radius: 8px; padding: 22px; max-width: 720px;
}
.invoice h2 { color: #111; }
.muted { color: var(--muted); font-size: 13px; }
.warn { color: #f0c14b; font-size: 13px; }
.err { color: var(--red); font-size: 13px; }
.ok { color: var(--accent); }
.file-name { font-size: 12px; color: var(--accent); }
@media (max-width: 900px) {
  .app { grid-template-columns: 1fr; }
  .side { flex-direction: row; overflow: auto; }
  .row, .row3 { grid-template-columns: 1fr; }
}

/* جایگاه‌داران در داشبورد کارشناس فروش */
.table-scroll { overflow-x: auto; }
.station-row { cursor: pointer; transition: background .15s ease; }
.station-row:hover { background: rgba(240,193,75,.08); }
.station-thumb {
  width: 52px; height: 52px; border-radius: 10px; object-fit: cover;
  display: inline-grid; place-items: center; background: #1d2837; color: var(--gold2);
  border: 1px solid var(--line); vertical-align: middle;
}
.station-thumb-empty { font-size: 23px; opacity: .8; }
.station-thumb-loaded { border-color: rgba(240,193,75,.5); }
.station-modal {
  position: fixed; inset: 0; z-index: 50; overflow: auto; padding: 30px;
  background: rgba(0,0,0,.78);
}
.station-detail-card { max-width: 1000px; margin: auto; }
.station-detail-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 18px; }
.station-detail-image {
  width: 180px; height: 130px; border-radius: 12px; border: 1px solid var(--line);
  background: #0e141c; display: grid; place-items: center; overflow: hidden; flex: 0 0 auto;
}
.station-detail-image img { width: 100%; height: 100%; object-fit: cover; }
.station-detail-badges { display: flex; flex-wrap: wrap; gap: 8px; margin: 16px 0; }
.station-info-grid {
  display: grid; grid-template-columns: repeat(4, minmax(0,1fr)); gap: 10px; margin: 14px 0 22px;
}
.station-info-grid > div { background: #0e141c; border: 1px solid var(--line); border-radius: 10px; padding: 10px; }
.station-info-grid b, .station-info-grid span { display: block; }
.station-info-grid b { color: var(--muted); font-size: 11px; margin-bottom: 5px; font-weight: 500; }
.station-info-grid span { font-size: 13px; overflow-wrap: anywhere; }
.station-image-form { align-items: center; }
.station-image-preview {
  min-height: 112px; display: grid; place-items: center; border: 1px dashed var(--line);
  border-radius: 12px; background: #0e141c; overflow: hidden;
}
.station-image-preview img { width: 180px; height: 112px; object-fit: cover; border-radius: 10px; }
@media (max-width: 900px) {
  .station-info-grid { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .station-modal { padding: 12px; }
}
@media (max-width: 560px) {
  .station-detail-head { flex-direction: column; }
  .station-detail-image { width: 100%; height: 180px; }
  .station-info-grid { grid-template-columns: 1fr; }
}

/* گزارش‌های مدیریتی بازرگانی */
.report-toolbar { display:flex; justify-content:space-between; align-items:flex-end; gap:18px; flex-wrap:wrap; }
.report-filters { display:flex; align-items:flex-end; gap:8px; flex-wrap:wrap; }
.report-filters label { margin:0; min-width:145px; }
.report-filters input { padding:9px 10px; }
.report-filters .btn { padding:10px 13px; }
.report-kpis .val { font-size:19px; }
.report-grid { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:14px; margin-top:16px; }
.report-wide { min-width:0; }
.report-bars { min-height:220px; display:flex; align-items:flex-end; gap:8px; overflow-x:auto; padding:24px 8px 8px; direction:ltr; }
.report-bar-col { min-width:54px; flex:1 0 54px; display:flex; flex-direction:column; justify-content:flex-end; align-items:center; height:210px; direction:rtl; }
.report-bar-value { color:var(--muted); font-size:10px; max-width:90px; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; margin-bottom:4px; }
.report-bar { width:70%; min-height:2px; border-radius:7px 7px 2px 2px; background:linear-gradient(180deg,#f0c14b,#966000); box-shadow:0 4px 12px rgba(240,193,75,.12); }
.report-bar-label { color:var(--muted); font-size:10px; margin-top:8px; white-space:nowrap; transform:rotate(-38deg); transform-origin:top center; }
.report-change.up { color:#35d07f; }
.report-change.down { color:#e85d5d; }
.report-change.flat { color:var(--muted); }
.report-recommendations { grid-column:1 / -1; }
.recommendation-grid { display:grid; grid-template-columns:repeat(3,minmax(0,1fr)); gap:10px; margin-top:12px; }
.recommendation-grid > div { background:#0e141c; border:1px solid var(--line); border-radius:10px; padding:12px; }
.recommendation-grid strong { color:var(--gold2); }
.recommendation-grid p { margin-top:7px; line-height:1.8; }
#cmReportError { margin-top:12px; }
@media (max-width:900px) {
  .report-grid { grid-template-columns:1fr; }
  .recommendation-grid { grid-template-columns:repeat(2,minmax(0,1fr)); }
}
@media (max-width:560px) {
  .report-filters { width:100%; align-items:stretch; }
  .report-filters label { flex:1 1 140px; }
  .report-filters .btn { flex:1 1 120px; }
  .recommendation-grid { grid-template-columns:1fr; }
}
@media print {
  body.commerce-print-mode { background:#fff!important; color:#111!important; }
  body.commerce-print-mode .side,
  body.commerce-print-mode .topbar,
  body.commerce-print-mode .no-print,
  body.commerce-print-mode .report-recommendations { display:none!important; }
  body.commerce-print-mode .app { display:block!important; min-height:0!important; }
  body.commerce-print-mode .main { padding:0!important; }
  body.commerce-print-mode .card { color:#111!important; background:#fff!important; border:1px solid #bbb!important; box-shadow:none!important; break-inside:avoid; }
  body.commerce-print-mode .report-grid { display:block!important; }
  body.commerce-print-mode .report-grid > .card { margin-bottom:14px; }
  body.commerce-print-mode .report-bars { display:none!important; }
  body.commerce-print-mode th, body.commerce-print-mode td { color:#111!important; border-color:#bbb!important; }
  body.commerce-print-mode .muted { color:#555!important; }
  body.commerce-print-mode .kpi .val { color:#111!important; }
}

/* نمودارهای رنگی و مقایسه‌ای گزارش بازرگانی */
.report-bar-blue { background:linear-gradient(180deg,#58a6ff,#205eac); box-shadow:0 4px 12px rgba(88,166,255,.22); }
.report-bar-green { background:linear-gradient(180deg,#52e39a,#16865b); box-shadow:0 4px 12px rgba(82,227,154,.20); }
.report-bar-purple { background:linear-gradient(180deg,#c18cff,#6b3aa5); box-shadow:0 4px 12px rgba(193,140,255,.20); }
.report-bar-red { background:linear-gradient(180deg,#ff8585,#a73245); box-shadow:0 4px 12px rgba(255,133,133,.20); }
.report-compare-legend { display:flex; gap:15px; flex-wrap:wrap; align-items:center; margin:10px 0 2px; }
.report-compare-legend span { color:var(--muted); font-size:12px; display:inline-flex; align-items:center; gap:6px; }
.report-legend-dot { width:10px; height:10px; border-radius:3px; display:inline-block; }
.report-dot-blue { background:#58a6ff; }
.report-dot-green { background:#52e39a; }
.report-dot-purple { background:#c18cff; }
.report-compare-scroll { overflow-x:auto; padding:20px 8px 12px; direction:ltr; }
.report-compare-bars { min-height:205px; display:flex; align-items:flex-end; gap:12px; min-width:max-content; }
.report-compare-group { min-width:76px; height:200px; display:flex; flex-direction:column; justify-content:flex-end; align-items:center; direction:rtl; }
.report-compare-columns { height:165px; display:flex; align-items:flex-end; gap:4px; }
.report-compare-col { width:17px; min-height:2px; border-radius:5px 5px 1px 1px; box-shadow:0 3px 9px rgba(0,0,0,.18); }
.report-blue { background:linear-gradient(180deg,#58a6ff,#205eac); }
.report-green { background:linear-gradient(180deg,#52e39a,#16865b); }
.report-purple { background:linear-gradient(180deg,#c18cff,#6b3aa5); }
.report-compare-label { color:var(--muted); font-size:10px; margin-top:10px; white-space:nowrap; transform:rotate(-35deg); }
.report-compare-note { margin-top:4px; line-height:1.7; }
.recommendation-card { background:#0e141c; border:1px solid var(--line); border-right:4px solid var(--blue); border-radius:10px; padding:12px; }
.recommendation-card strong { color:var(--text); }
.recommendation-card p { margin-top:7px; line-height:1.9; }
.recommendation-good { border-right-color:#35d07f; }
.recommendation-warn { border-right-color:#f0c14b; }
.recommendation-bad { border-right-color:#e85d5d; }
.recommendation-info { border-right-color:#58a6ff; }

/* منوی موبایل و چیدمان ریسپانسیو */
.mobile-menu-btn { display:none; width:auto; margin:0; }
.mobile-backdrop { display:none; }
.topbar-title { min-width:0; }
@media (max-width:760px) {
  html, body { overflow-x:hidden; }
  .app { display:block; min-height:100vh; }
  .side {
    position:fixed; top:0; right:0; bottom:0; z-index:101;
    width:min(82vw,300px); height:100vh; padding:16px 12px;
    flex-direction:column; overflow-x:hidden; overflow-y:auto;
    transform:translateX(110%); transition:transform .22s ease;
    border-left:0; border-right:1px solid var(--line);
    box-shadow:-18px 0 50px rgba(0,0,0,.45);
  }
  .side.mobile-open { transform:translateX(0); }
  .side .nav-btn { flex:0 0 auto; width:100%; text-align:right; }
  .mobile-backdrop.active {
    display:block; position:fixed; inset:0; z-index:100;
    background:rgba(0,0,0,.58);
  }
  .main { width:100%; min-width:0; padding:12px 10px 28px; overflow:hidden; }
  .topbar { align-items:flex-start; gap:8px; margin-bottom:14px; }
  .mobile-menu-btn { display:inline-flex; flex:0 0 auto; padding:9px 10px; }
  .topbar-title { flex:1; order:2; }
  .topbar-title h2 { font-size:18px; line-height:1.45; }
  .topbar-title .muted { display:block; max-width:100%; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; font-size:10px; }
  .user-chip { width:100%; order:3; font-size:11px; text-align:right; padding-top:2px; }
  .user-chip #changePassword { padding:5px 8px!important; font-size:11px; }
  .card { padding:12px; border-radius:12px; }
  .kpis { grid-template-columns:repeat(2,minmax(0,1fr)); gap:8px; }
  .kpi .lbl { font-size:10px; line-height:1.5; }
  .kpi .val { font-size:16px; line-height:1.5; overflow-wrap:anywhere; }
  .report-toolbar { align-items:stretch; gap:10px; }
  .report-toolbar > div:first-child h3 { font-size:16px; }
  .report-filters { display:grid; grid-template-columns:1fr 1fr; width:100%; gap:7px; }
  .report-filters label { min-width:0; font-size:11px; margin:0; }
  .report-filters input { font-size:12px; padding:9px 7px; }
  .report-filters .btn { width:100%; min-width:0; margin-top:0; padding:9px 5px; font-size:11px; }
  .report-filters .btn:nth-last-child(2), .report-filters .btn:last-child { grid-column:span 1; }
  .report-grid { grid-template-columns:1fr; gap:10px; margin-top:10px; }
  .report-grid h3 { font-size:16px; }
  .report-bars { min-height:180px; gap:5px; padding-left:4px; padding-right:4px; }
  .report-bar-col { min-width:42px; flex-basis:42px; height:170px; }
  .report-bar-value { max-width:60px; font-size:8px; }
  .report-bar-label { font-size:8px; }
  .report-compare-group { min-width:66px; }
  .report-compare-columns { gap:3px; }
  .report-compare-col { width:14px; }
  .report-compare-label { font-size:8px; }
  .table-scroll { max-width:100%; overflow-x:auto; -webkit-overflow-scrolling:touch; }
  table { min-width:620px; font-size:11px; }
  th, td { padding:8px 6px; white-space:nowrap; }
  .row, .row3 { grid-template-columns:1fr; gap:5px; }
  .actions { gap:6px; }
  .actions .btn { flex:1 1 140px; }
  .station-detail-head { flex-direction:column; }
  .station-detail-image { width:100%; height:170px; }
  .station-info-grid { grid-template-columns:1fr 1fr; gap:7px; }
  .station-modal { padding:10px; }
  .report-recommendations { grid-column:auto; }
  .recommendation-grid { grid-template-columns:1fr; gap:8px; }
  .recommendation-card { padding:10px; }
}
@media (max-width:390px) {
  .kpis { grid-template-columns:1fr 1fr; }
  .kpi .val { font-size:14px; }
  .topbar-title h2 { font-size:16px; }
  .report-filters { grid-template-columns:1fr; }
  .report-filters .btn { grid-column:span 1!important; }
}

/* نصب PWA */
.pwa-install-btn { display:none!important; padding:6px 10px; margin-right:8px; }
.pwa-install-btn.pwa-install-ready { display:inline-flex!important; }
@media (max-width:760px) {
  .pwa-install-btn { padding:5px 7px; font-size:11px; margin-right:4px; }
}

/* تنظیم نهایی منوی گوشی و جلوگیری از بزرگ‌نمایی ناخواسته iOS */
@media (max-width:760px) {
  #app, .app, .main { width:100%; max-width:100vw; min-width:0; }
  .topbar { position:relative; display:block; padding-right:88px; min-height:48px; }
  .mobile-menu-btn {
    position:absolute; top:0; right:0; z-index:2;
    width:78px; height:46px; min-height:46px; padding:5px 8px;
    border-color:rgba(240,193,75,.65); color:var(--gold2);
    font-size:14px; line-height:1; gap:5px;
  }
  .mobile-menu-btn span:first-child { font-size:24px; line-height:1; }
  .topbar-title { display:block; width:100%; padding:0; }
  .topbar-title h2 { padding-top:2px; }
  .user-chip { padding-top:8px; }
  input, select, textarea { font-size:16px; }
  .report-filters input { font-size:16px; }
}
@media (max-width:390px) {
  .topbar { padding-right:84px; }
  .mobile-menu-btn { width:74px; }
  .topbar-title h2 { font-size:16px; }
  .user-chip { font-size:10px; }
}
