:root {
  --bg: #0a0e14;
  --surface: #111721;
  --surface2: #161e2b;
  --border: #223047;
  --green: #22c55e;
  --red: #ef4444;
  --gold: #eab308;
  --text: #e2e8f0;
  --muted: #64748b;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: 'Vazirmatn', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  overflow-x: hidden;
}
.mono { font-family: 'JetBrains Mono', monospace; }

.app { position: relative; min-height: 100vh; }

.grid-bg {
  position: fixed; inset: 0; z-index: 0; pointer-events: none;
  background-image:
    linear-gradient(rgba(34,197,94,0.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(239,68,68,0.03) 1px, transparent 1px);
  background-size: 40px 40px;
  mask-image: radial-gradient(ellipse at top, black, transparent 75%);
}
.app > *:not(.grid-bg) { position: relative; z-index: 1; }

/* HEADER */
.header {
  position: sticky; top: 0; z-index: 50;
  background: rgba(10,14,20,0.85);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border);
}
.header::after {
  content: ''; display: block; height: 2px;
  background: linear-gradient(90deg, var(--green), var(--gold), var(--red));
}
.header-inner {
  max-width: 1300px; margin: 0 auto; padding: 12px 20px;
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 14px;
}
.brand { display: flex; align-items: center; gap: 12px; }
.logo { font-size: 34px; filter: drop-shadow(0 0 10px rgba(239,68,68,0.4)); }
.title { font-size: 26px; font-weight: 900; letter-spacing: -0.5px; }
.title-accent { color: var(--green); }
.subtitle { font-size: 12px; color: var(--muted); font-weight: 300; margin-top: 2px; }

.status-bar { display: flex; align-items: center; flex-wrap: wrap; gap: 12px; font-size: 12px; }
.live-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--green); box-shadow: 0 0 0 rgba(34,197,94,0.6); animation: pulse 1.6s infinite; display: inline-block; }
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(34,197,94,0.6); }
  70% { box-shadow: 0 0 0 8px rgba(34,197,94,0); }
  100% { box-shadow: 0 0 0 0 rgba(34,197,94,0); }
}
.status-src { color: var(--green); font-weight: 600; }
.status-time { color: var(--muted); font-size: 11px; }
.auto-toggle { color: var(--muted); cursor: pointer; user-select: none; }
.refresh-btn {
  background: var(--surface2); color: var(--text); border: 1px solid var(--border);
  padding: 7px 14px; border-radius: 8px; cursor: pointer; font-family: inherit; font-size: 13px;
  transition: all 0.15s;
}
.refresh-btn:hover:not(:disabled) { border-color: var(--green); color: var(--green); }
.refresh-btn:disabled { opacity: 0.6; cursor: wait; }

/* TOP STRIP */
.topstrip {
  max-width: 1300px; margin: 16px auto 0; padding: 0 20px;
  display: flex; gap: 14px; flex-wrap: wrap;
}
.mood {
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px;
  padding: 12px 18px; display: flex; align-items: center; gap: 14px; min-width: 210px;
}
.mood-emoji { font-size: 40px; }
.mood-label { font-size: 11px; color: var(--muted); }
.mood-status { font-size: 17px; font-weight: 800; }
.tip {
  flex: 1; min-width: 240px;
  background: linear-gradient(135deg, rgba(234,179,8,0.08), var(--surface));
  border: 1px solid var(--border); border-radius: 12px; padding: 12px 18px;
  display: flex; align-items: center; gap: 12px;
}
.tip-title { font-weight: 800; color: var(--gold); white-space: nowrap; }
.tip-text { font-size: 13px; color: var(--text); font-weight: 300; }

/* CONTROLS */
.controls { max-width: 1300px; margin: 16px auto; padding: 0 20px; display: flex; flex-direction: column; gap: 12px; }
.segment {
  display: inline-flex; background: var(--surface); border: 1px solid var(--border);
  border-radius: 10px; padding: 4px; gap: 2px; align-self: flex-start; flex-wrap: wrap;
}
.seg-btn {
  background: transparent; border: none; color: var(--muted); cursor: pointer;
  padding: 8px 16px; border-radius: 7px; font-family: inherit; font-size: 13px; font-weight: 600;
  transition: all 0.15s;
}
.seg-btn.active { background: var(--green); color: #04140a; }
.seg-btn:hover:not(.active) { color: var(--text); }

.ctrl-row { display: flex; gap: 12px; flex-wrap: wrap; }
.search {
  flex: 1; min-width: 200px; background: var(--surface); border: 1px solid var(--border);
  color: var(--text); padding: 10px 14px; border-radius: 9px; font-family: inherit; font-size: 14px;
}
.search:focus { outline: none; border-color: var(--green); }
.search::placeholder { color: var(--muted); }
.sort-select {
  background: var(--surface); border: 1px solid var(--border); color: var(--text);
  padding: 10px 14px; border-radius: 9px; font-family: inherit; font-size: 13px; cursor: pointer;
}
.sort-select:focus { outline: none; border-color: var(--green); }

.pills { display: flex; gap: 8px; flex-wrap: wrap; }
.pill {
  background: var(--surface); border: 1px solid var(--border); color: var(--muted);
  padding: 7px 15px; border-radius: 20px; cursor: pointer; font-family: inherit; font-size: 13px;
  transition: all 0.15s;
}
.pill.active { background: var(--surface2); border-color: var(--green); color: var(--green); }
.pill:hover:not(.active) { color: var(--text); border-color: var(--muted); }

/* GRID */
.grid {
  max-width: 1300px; margin: 0 auto 40px; padding: 0 20px;
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px;
}
@media (max-width: 900px) { .grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 600px) { .grid { grid-template-columns: 1fr; } }

/* CARD */
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: 14px;
  padding: 16px; cursor: pointer; transition: transform 0.15s, box-shadow 0.2s, border-color 0.2s;
  animation: fadeUp 0.4s ease both;
}
@keyframes fadeUp { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
.card:hover { transform: translateY(-3px); border-color: var(--muted); }
.card.glow-buy:hover { box-shadow: 0 8px 30px rgba(34,197,94,0.15); border-color: rgba(34,197,94,0.4); }
.card.glow-sell:hover { box-shadow: 0 8px 30px rgba(239,68,68,0.15); border-color: rgba(239,68,68,0.4); }
.card.strong { border-color: rgba(34,197,94,0.5); box-shadow: 0 0 22px rgba(34,197,94,0.12); animation: fadeUp 0.4s both, strongGlow 2.4s infinite; }
.card.strong.glow-sell { border-color: rgba(239,68,68,0.5); animation: fadeUp 0.4s both, strongGlowRed 2.4s infinite; }
@keyframes strongGlow { 0%,100% { box-shadow: 0 0 14px rgba(34,197,94,0.1); } 50% { box-shadow: 0 0 26px rgba(34,197,94,0.28); } }
@keyframes strongGlowRed { 0%,100% { box-shadow: 0 0 14px rgba(239,68,68,0.1); } 50% { box-shadow: 0 0 26px rgba(239,68,68,0.28); } }

.card.skeleton { height: 200px; background: linear-gradient(100deg, var(--surface) 30%, var(--surface2) 50%, var(--surface) 70%); background-size: 200% 100%; animation: shimmer 1.4s infinite; cursor: default; }
@keyframes shimmer { to { background-position: -200% 0; } }

.card-head { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.coin-img { width: 34px; height: 34px; border-radius: 50%; }
.coin-meta { flex: 1; min-width: 0; }
.coin-name-row { display: flex; align-items: baseline; gap: 8px; }
.coin-sym { font-weight: 700; font-size: 15px; }
.coin-rank { font-size: 10px; color: var(--muted); }
.coin-name { font-size: 12px; color: var(--muted); font-weight: 300; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.sig-badge { font-size: 12px; font-weight: 800; padding: 4px 12px; border-radius: 7px; white-space: nowrap; }
.badge-buy { background: rgba(34,197,94,0.15); color: var(--green); border: 1px solid rgba(34,197,94,0.3); }
.badge-sell { background: rgba(239,68,68,0.15); color: var(--red); border: 1px solid rgba(239,68,68,0.3); }
.badge-neutral { background: rgba(100,116,139,0.15); color: var(--muted); border: 1px solid rgba(100,116,139,0.3); }

.card-price-row { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 10px; }
.price { font-size: 20px; font-weight: 700; transition: color 0.3s; }
.flash-up { animation: flashUp 0.9s; }
.flash-down { animation: flashDown 0.9s; }
@keyframes flashUp { 0% { color: var(--green); text-shadow: 0 0 10px rgba(34,197,94,0.5); } 100% { color: var(--text); } }
@keyframes flashDown { 0% { color: var(--red); text-shadow: 0 0 10px rgba(239,68,68,0.5); } 100% { color: var(--text); } }
.change { font-size: 13px; font-weight: 700; }
.change.pos { color: var(--green); }
.change.neg { color: var(--red); }

.card-spark-row { margin-bottom: 12px; }
.spark { width: 100%; height: 34px; }
.spark-empty { font-size: 11px; color: var(--muted); text-align: center; padding: 10px; }

.confbar-wrap { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.confbar-bg { flex: 1; height: 7px; background: var(--surface2); border-radius: 5px; overflow: hidden; }
.confbar-fill { height: 100%; border-radius: 5px; transition: width 0.4s; }
.confbar-label { font-size: 12px; font-weight: 700; min-width: 34px; text-align: left; }

.chips { display: flex; gap: 7px; flex-wrap: wrap; }
.chip { font-size: 11px; background: var(--surface2); border: 1px solid var(--border); padding: 3px 9px; border-radius: 6px; color: var(--muted); }
.chip b { color: var(--text); }
.chip-hot { color: var(--gold); border-color: rgba(234,179,8,0.3); }

/* MODAL */
.modal-overlay {
  position: fixed; inset: 0; z-index: 100; background: rgba(0,0,0,0.7);
  backdrop-filter: blur(4px); display: flex; align-items: center; justify-content: center; padding: 20px;
  animation: fadeIn 0.2s;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.modal {
  background: var(--surface); border: 1px solid var(--border); border-radius: 16px;
  max-width: 620px; width: 100%; max-height: 90vh; overflow-y: auto; padding: 24px; position: relative;
  animation: modalUp 0.25s ease;
}
@keyframes modalUp { from { transform: translateY(20px) scale(0.98); opacity: 0; } to { transform: none; opacity: 1; } }
.modal-close {
  position: absolute; top: 14px; left: 14px; background: var(--surface2); border: 1px solid var(--border);
  color: var(--muted); width: 32px; height: 32px; border-radius: 8px; cursor: pointer; font-size: 15px;
}
.modal-close:hover { color: var(--red); }
.modal-head { display: flex; align-items: center; gap: 14px; margin-bottom: 18px; }
.coin-img-lg { width: 48px; height: 48px; border-radius: 50%; }
.modal-title { font-size: 22px; font-weight: 800; }
.modal-price { font-size: 18px; margin-top: 4px; color: var(--muted); }
.modal-spark { margin-bottom: 18px; background: var(--bg); border-radius: 10px; padding: 6px; }
.spark-big { width: 100%; height: 140px; display: block; }
.conf-big { margin-bottom: 18px; font-size: 14px; }
.conf-big b { color: var(--green); font-size: 18px; }

.levels { background: var(--bg); border-radius: 10px; padding: 6px 16px; margin-bottom: 16px; }
.lvl-row { display: flex; justify-content: space-between; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--border); }
.lvl-row:last-child { border-bottom: none; }
.lvl-label { font-size: 13px; color: var(--muted); }
.lvl-val { font-size: 15px; font-weight: 700; }
.lvl-val.entry { color: var(--text); }
.lvl-val.sl { color: var(--red); }
.lvl-val.tp { color: var(--green); }

.reasons { margin-bottom: 16px; }
.reasons-title { font-size: 13px; color: var(--muted); margin-bottom: 8px; }
.reasons-list { display: flex; flex-wrap: wrap; gap: 7px; }
.reason-tag { font-size: 12px; background: var(--surface2); border: 1px solid var(--border); padding: 4px 11px; border-radius: 7px; }

.validate { font-size: 12px; color: var(--muted); display: flex; align-items: center; gap: 8px; margin-bottom: 14px; }
.dot-green { width: 8px; height: 8px; border-radius: 50%; background: var(--green); display: inline-block; }
.nodata-msg { color: var(--muted); text-align: center; padding: 30px; }
.disclaimer-mini { font-size: 12px; color: var(--gold); background: rgba(234,179,8,0.08); padding: 10px 14px; border-radius: 8px; text-align: center; }

/* STATES */
.error-state { max-width: 500px; margin: 60px auto; text-align: center; color: var(--muted); }
.error-state p { margin-bottom: 16px; }
.empty { max-width: 500px; margin: 60px auto; text-align: center; color: var(--muted); font-size: 16px; }

/* FOOTER */
.footer {
  max-width: 1300px; margin: 0 auto; padding: 30px 20px 40px; text-align: center;
  color: var(--muted); font-size: 13px; border-top: 1px solid var(--border);
}
.footer b { color: var(--text); }
.footer-links { margin-top: 8px; }
.footer-links a { color: var(--green); text-decoration: none; }
.footer-links a:hover { text-decoration: underline; }

@media (max-width: 600px) {
  .title { font-size: 21px; }
  .status-time { display: none; }
  .modal { padding: 18px; }
}