:root { --tk-h: 46px; }
@media (max-width: 640px) { :root { --tk-h: 42px; } }
body.tk-on { padding-top: var(--tk-h) !important; }
body.tk-on .h-screen, body.tk-on .min-h-screen { min-height: calc(100vh - var(--tk-h)); }
body.tk-on .sticky.top-0 { top: var(--tk-h) !important; }

/* ---------- ticker */
#tk-bar { position: fixed; top: 0; left: 0; right: 0; height: var(--tk-h); z-index: 9998; overflow: hidden; direction: ltr;
  background: linear-gradient(90deg, #0b0f14, #121826 50%, #0b0f14); border-bottom: 1px solid rgba(250, 204, 21, .25);
  box-shadow: 0 2px 14px rgba(0, 0, 0, .35); font-family: Vazirmatn, Tahoma, sans-serif; user-select: none; }
#tk-bar::before, #tk-bar::after { content: ""; position: absolute; top: 0; bottom: 0; width: 26px; z-index: 2; pointer-events: none; }
#tk-bar::before { left: 0; background: linear-gradient(90deg, #0b0f14, transparent); }
#tk-bar::after { right: 0; background: linear-gradient(-90deg, #0b0f14, transparent); }
#tk-track { position: absolute; top: 0; height: 100%; display: flex; align-items: center; gap: 10px; padding: 0 14px; white-space: nowrap; will-change: transform; }
#tk-track.run { animation: tk-pingpong var(--tk-dur, 40s) cubic-bezier(.45, .05, .55, .95) infinite alternate; }
#tk-bar.paused #tk-track { animation-play-state: paused; }
@keyframes tk-pingpong {
  0% { transform: translateX(var(--tk-from)) scaleX(1); }
  2% { transform: translateX(var(--tk-from)) scaleX(.985); }
  4% { transform: translateX(var(--tk-from)) scaleX(1); }
  96% { transform: translateX(var(--tk-to)) scaleX(1); }
  98% { transform: translateX(var(--tk-to)) scaleX(.985); }
  100% { transform: translateX(var(--tk-to)) scaleX(1); }
}
.tk-item { display: inline-flex; align-items: center; gap: 8px; direction: rtl; padding: 5px 12px; border-radius: 12px; cursor: pointer;
  background: rgba(255, 255, 255, .045); border: 1px solid rgba(255, 255, 255, .07); color: #e5e7eb; font-size: 13px; transition: background .2s; }
.tk-item:hover { background: rgba(255, 255, 255, .09); }
.tk-name { color: #cbd5e1; font-weight: 600; }
.tk-price { color: #fff; font-weight: 800; font-size: 14px; font-variant-numeric: tabular-nums; }
.tk-unit { color: #94a3b8; font-size: 11px; }
.tk-chg { font-size: 12px; font-weight: 700; display: inline-flex; align-items: center; gap: 2px; direction: ltr; }
.tk-up { color: #34d399; } .tk-down { color: #f87171; } .tk-flat { color: #94a3b8; }
.tk-flag { width: 26px; height: 18px; border-radius: 3px; overflow: hidden; flex: none; box-shadow: 0 1px 3px rgba(0, 0, 0, .5); transform-origin: left center;
  animation: tk-wave 2.6s ease-in-out infinite; }
.tk-flag svg { width: 100%; height: 100%; display: block; }
@keyframes tk-wave {
  0%, 100% { transform: perspective(60px) rotateY(0deg) skewY(0deg); filter: brightness(1); }
  25% { transform: perspective(60px) rotateY(-14deg) skewY(2deg); filter: brightness(1.12); }
  50% { transform: perspective(60px) rotateY(0deg) skewY(-1.5deg); filter: brightness(.92); }
  75% { transform: perspective(60px) rotateY(10deg) skewY(1.5deg); filter: brightness(1.08); }
}
.tk-flag::after { content: ""; position: absolute; }
.tk-sep { width: 1px; height: 20px; background: rgba(255, 255, 255, .08); }
@media (max-width: 640px) { .tk-item { font-size: 12px; padding: 4px 9px; gap: 6px; } .tk-price { font-size: 13px; } .tk-flag { width: 22px; height: 15px; } }

/* ---------- shared modal / panel */
.nx-overlay { position: fixed; inset: 0; background: rgba(2, 6, 12, .55); z-index: 9999; display: flex; align-items: flex-start; justify-content: center; padding: calc(var(--tk-h) + 14px) 12px 12px; }
.nx-card { width: 100%; max-width: 460px; max-height: calc(100vh - var(--tk-h) - 40px); overflow: auto; background: #10151c; color: #e5e7eb; border: 1px solid rgba(255, 255, 255, .08);
  border-radius: 18px; box-shadow: 0 20px 60px rgba(0, 0, 0, .5); direction: rtl; font-family: Vazirmatn, Tahoma, sans-serif; }
.nx-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 16px; border-bottom: 1px solid rgba(255, 255, 255, .06); position: sticky; top: 0; background: #10151c; z-index: 1; }
.nx-head b { font-size: 15px; }
.nx-x { background: none; border: 0; color: #94a3b8; font-size: 20px; cursor: pointer; }
.nx-tabs { display: flex; gap: 6px; padding: 10px 16px; flex-wrap: wrap; }
.nx-tab { border: 1px solid rgba(255, 255, 255, .1); background: transparent; color: #cbd5e1; padding: 5px 12px; border-radius: 999px; font: inherit; font-size: 12px; cursor: pointer; }
.nx-tab.on { background: linear-gradient(90deg, #6366f1, #7c3aed); border-color: transparent; color: #fff; }
.nx-tab i { font-style: normal; background: #ef4444; color: #fff; border-radius: 999px; padding: 0 6px; margin-right: 4px; font-size: 11px; }
.nx-actions { display: flex; gap: 8px; padding: 0 16px 8px; }
.nx-btn { border: 1px solid rgba(255, 255, 255, .12); background: rgba(255, 255, 255, .04); color: #e5e7eb; padding: 7px 12px; border-radius: 10px; font: inherit; font-size: 12px; cursor: pointer; }
.nx-btn.pri { background: linear-gradient(90deg, #6366f1, #7c3aed); border: 0; color: #fff; font-weight: 700; }
.nx-btn.warn { color: #fca5a5; }
.nx-list { padding: 4px 10px 14px; }
.nx-n { display: flex; gap: 10px; padding: 11px 10px; border-radius: 12px; cursor: pointer; position: relative; }
.nx-n:hover { background: rgba(255, 255, 255, .04); }
.nx-n.unread { background: rgba(99, 102, 241, .08); }
.nx-n.unread::before { content: ""; position: absolute; right: 2px; top: 18px; width: 7px; height: 7px; border-radius: 50%; background: #818cf8; }
.nx-ic { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; flex: none; font-size: 16px; }
.nx-ic.warehouse { background: rgba(245, 158, 11, .15); } .nx-ic.chat { background: rgba(16, 185, 129, .15); } .nx-ic.system { background: rgba(99, 102, 241, .15); }
.nx-t { font-size: 13px; font-weight: 700; color: #f1f5f9; }
.nx-b { font-size: 12px; color: #94a3b8; margin-top: 3px; line-height: 1.7; }
.nx-time { font-size: 11px; color: #64748b; margin-top: 3px; }
.nx-del { position: absolute; left: 8px; top: 8px; background: none; border: 0; color: #64748b; cursor: pointer; font-size: 14px; display: none; }
.nx-n:hover .nx-del { display: block; }
.nx-empty { text-align: center; color: #64748b; font-size: 13px; padding: 30px 0; }
.nx-sec { padding: 12px 16px; border-top: 1px solid rgba(255, 255, 255, .06); }
.nx-sec h4 { margin: 0 0 10px; font-size: 13px; color: #fbbf24; }
.nx-grid { display: grid; grid-template-columns: 1fr repeat(3, 64px); gap: 8px; align-items: center; font-size: 12px; }
.nx-grid .h { color: #94a3b8; text-align: center; }
.nx-grid input { justify-self: center; width: 18px; height: 18px; accent-color: #7c3aed; }
.nx-field { display: block; font-size: 12px; color: #94a3b8; margin-bottom: 10px; }
.nx-field input, .nx-field select, .nx-field textarea { display: block; width: 100%; margin-top: 5px; box-sizing: border-box; background: #0b0f14; border: 1px solid rgba(255, 255, 255, .1);
  color: #f1f5f9; border-radius: 10px; padding: 8px 10px; font: inherit; font-size: 13px; }
.nx-note { font-size: 11px; color: #64748b; line-height: 1.8; margin: 6px 0 0; }
.nx-msg { font-size: 12px; margin-top: 8px; }
.nx-msg.ok { color: #34d399; } .nx-msg.bad { color: #f87171; }

/* ---------- bell */
#nx-bell { position: fixed; left: 16px; bottom: 18px; z-index: 9997; width: 52px; height: 52px; border-radius: 50%; border: 0; cursor: pointer;
  background: linear-gradient(135deg, #6366f1, #7c3aed); color: #fff; box-shadow: 0 8px 24px rgba(99, 102, 241, .45); display: grid; place-items: center; }
#nx-bell svg { width: 24px; height: 24px; }
#nx-bell .badge { position: absolute; top: -2px; right: -2px; min-width: 20px; height: 20px; border-radius: 999px; background: #ef4444; color: #fff; font: 700 11px Tahoma, sans-serif;
  display: grid; place-items: center; padding: 0 5px; border: 2px solid #0d1014; }
#nx-bell.ring svg { animation: nx-ring .9s ease-in-out 2; }
@keyframes nx-ring { 0%, 100% { transform: rotate(0); } 20% { transform: rotate(16deg); } 40% { transform: rotate(-14deg); } 60% { transform: rotate(9deg); } 80% { transform: rotate(-6deg); } }
#nx-toast { position: fixed; left: 16px; bottom: 80px; z-index: 9999; max-width: 320px; background: #10151c; border: 1px solid rgba(99, 102, 241, .4); color: #e5e7eb;
  border-radius: 14px; padding: 12px 14px; direction: rtl; font: 13px Vazirmatn, Tahoma, sans-serif; box-shadow: 0 12px 30px rgba(0, 0, 0, .45); cursor: pointer;
  transform: translateY(20px); opacity: 0; transition: .3s; }
#nx-toast.show { transform: none; opacity: 1; }
#nx-toast b { display: block; margin-bottom: 3px; }

/* ---------- phone / tablet layout fixes for the original app */
html, body { overflow-x: clip; max-width: 100vw; } /* clip (not hidden) so body never becomes a scroll box */
#root { overflow-x: clip; max-width: 100vw; } /* clip, not hidden: keeps the sticky header working */
main .grid > *, main .flex-1 { min-width: 0; } /* grid cards may shrink; flex rows keep their size */
main .overflow-x-auto > * { flex-shrink: 0; }
main { max-width: 100vw; }
main .overflow-x-auto { max-width: 100%; -webkit-overflow-scrolling: touch; }
main img, main video, main canvas, main iframe { max-width: 100%; }
@media (max-width: 480px) {
  header .mr-auto > .inline-flex.rounded-xl:first-child { display: none; } /* "online users" pill */
  header .mr-auto { gap: 2px; }
  #nx-bell { width: 46px; height: 46px; left: 10px; bottom: 12px; }
  #nx-cases { bottom: 66px !important; left: 10px !important; font-size: 11px; padding: 8px 10px !important; }
}

/* lighter ticker on phones/tablets: no per-flag 3D wave, GPU-only transform */
@media (max-width: 1024px), (prefers-reduced-motion: reduce) {
  .tk-flag { animation: none; }
  #tk-track.run { animation-timing-function: linear; }
}
#tk-track { backface-visibility: hidden; transform: translateZ(0); }

/* admin tools button (the app has its own bell now) */
#nx-admin { position: fixed; left: 16px; bottom: 18px; z-index: 9997; width: 46px; height: 46px; border-radius: 50%; border: 0; cursor: pointer;
  background: #1f2937; color: #fff; font-size: 20px; box-shadow: 0 8px 24px rgba(0,0,0,.35); }
@media (max-width: 640px) { #nx-admin { width: 40px; height: 40px; left: 10px; bottom: 12px; font-size: 17px; } }

/* support desk shortcut (above the admin button) */
#nx-support { position: fixed; left: 16px; bottom: 74px; z-index: 9997; width: 46px; height: 46px; border-radius: 50%; display: grid; place-items: center; text-decoration: none;
  background: #f59e0b; color: #111; font-size: 20px; box-shadow: 0 8px 24px rgba(0,0,0,.35); }
#nx-support b { position: absolute; top: -4px; right: -4px; background: #f43f5e; color: #fff; font-size: 10px; min-width: 18px; height: 18px; border-radius: 9px; display: grid; place-items: center; padding: 0 4px; font-family: inherit; }
#nx-support b[hidden] { display: none; }
@media (max-width: 640px) { #nx-support { width: 40px; height: 40px; left: 10px; bottom: 60px; font-size: 17px; } }
