:root {
  --bg: #080d1a;
  --panel: #101729;
  --panel2: #17213a;
  --text: #eef3ff;
  --muted: #93a3c2;
  --line: #24314f;
  --green: #22d399;
  --red: #ff5c72;
  --yellow: #f5c451;
  --blue: #60a5fa;
  --purple: #a78bfa;
  --cyan: #22d3ee;
  --shadow: 0 14px 40px rgba(0, 0, 0, 0.32);
}

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  direction: rtl;
  overflow-x: hidden;
  max-width: 100%;
  background: radial-gradient(circle at 80% 0%, #152348 0%, transparent 38%),
              radial-gradient(circle at 10% 20%, #0f293c 0%, transparent 32%),
              var(--bg);
  color: var(--text);
  font-family: Vazirmatn, "IRANSans", Tahoma, "Segoe UI", system-ui, -apple-system, sans-serif;
  font-size: 14px;
  line-height: 1.6;
}

a {
  color: inherit;
  text-decoration: none;
}

.ltr-num {
  direction: ltr;
  unicode-bidi: isolate;
  display: inline-block;
  font-variant-numeric: tabular-nums;
}

.app {
  display: flex;
  min-height: 100vh;
}

/* Sidebar pinned right for RTL */
.side {
  width: 245px;
  background: rgba(9, 14, 28, 0.96);
  border-left: 1px solid var(--line);
  padding: 10px 10px;
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  z-index: 20;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  backdrop-filter: blur(12px);
  overflow-y: auto;
  scrollbar-width: thin;
}

.brand {
  font-weight: 800;
  font-size: 16px;
  padding: 4px 6px 10px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.brand span {
  color: var(--blue);
}

.brand small {
  font-size: 10.5px;
  background: rgba(96, 165, 250, 0.14);
  color: var(--blue);
  padding: 1px 6px;
  border-radius: 999px;
}

.nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.nav a {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 6px 10px;
  border-radius: 8px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
  transition: all 0.15s ease;
}

.nav a:hover {
  background: rgba(255, 255, 255, 0.04);
  color: #fff;
}

.nav a.active {
  background: linear-gradient(135deg, rgba(96, 165, 250, 0.2), rgba(167, 139, 250, 0.14));
  color: #fff;
  border: 1px solid rgba(96, 165, 250, 0.35);
}

.side-footer {
  padding: 8px 6px 2px;
  border-top: 1px solid var(--line);
  font-size: 11px;
  color: var(--muted);
}

/* Main container */
.main {
  margin-right: 245px;
  width: calc(100% - 245px);
  min-width: 0;
  max-width: 100%;
  overflow-x: hidden;
  padding: 24px 28px 40px;
  transition: margin-right 0.22s ease, width 0.22s ease;
}

.side {
  transition: transform 0.22s ease, opacity 0.22s ease, width 0.22s ease;
}

.sidebar-toggle-float {
  display: none;
  position: fixed;
  top: 14px;
  right: 12px;
  z-index: 9999;
  background: linear-gradient(135deg, #2563eb, #3b82f6);
  color: #ffffff;
  border: 1px solid rgba(147, 197, 253, 0.7);
  border-radius: 10px;
  padding: 8px 13px;
  font-size: 13px;
  font-weight: 800;
  cursor: pointer;
  box-shadow: 0 6px 22px rgba(37, 99, 235, 0.48);
}

.top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 14px;
  margin-bottom: 20px;
  padding-bottom: 16px;
  border-bottom: 1px solid rgba(36, 49, 79, 0.65);
}

.title h1 {
  margin: 0 0 4px;
  font-size: 23px;
  font-weight: 800;
}

.muted {
  color: var(--muted);
  font-size: 13px;
}

.top-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
}

/* Global Sliding Currency Toggle (IRT <-> USDT) */
.currency-switch {
  display: inline-flex;
  align-items: center;
  background: #0b1224;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 4px;
  gap: 4px;
  box-shadow: inset 0 2px 6px rgba(0, 0, 0, 0.35);
}

.currency-switch button.curr-opt {
  background: transparent;
  color: var(--muted);
  border: 0;
  border-radius: 999px;
  padding: 7px 14px;
  font-size: 12.5px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s ease;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.currency-switch button.curr-opt.active-irt {
  background: linear-gradient(135deg, #2563eb, #3b82f6);
  color: #fff;
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.38);
}

.currency-switch button.curr-opt.active-usdt {
  background: linear-gradient(135deg, #059669, #10b981);
  color: #fff;
  box-shadow: 0 4px 12px rgba(16, 185, 129, 0.38);
}

.rate-pill {
  background: rgba(34, 211, 238, 0.08);
  border: 1px solid rgba(34, 211, 238, 0.28);
  color: var(--cyan);
  padding: 7px 12px;
  border-radius: 10px;
  font-size: 12.5px;
  font-weight: 700;
}

/* Cards & Panels */
.grid {
  display: grid;
  gap: 14px;
}

.cards {
  grid-template-columns: repeat(auto-fit, minmax(175px, 1fr));
}

.card, .panel {
  background: linear-gradient(155deg, rgba(20, 29, 52, 0.96), rgba(13, 19, 36, 0.96));
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: var(--shadow);
  min-width: 0;
  max-width: 100%;
}

.card {
  padding: 16px 18px;
}

.label {
  font-size: 12px;
  color: var(--muted);
  font-weight: 600;
}

.value {
  font-size: 21px;
  font-weight: 800;
  margin-top: 6px;
}

.subval {
  font-size: 12px;
  color: var(--muted);
  margin-top: 4px;
}

.green { color: var(--green); }
.red { color: var(--red); }
.yellow { color: var(--yellow); }
.blue { color: var(--blue); }
.purple { color: var(--purple); }
.cyan { color: var(--cyan); }

.panel {
  padding: 18px 20px;
  margin-top: 16px;
}

.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 14px;
}

.panel h2 {
  font-size: 16px;
  font-weight: 700;
  margin: 0;
}

/* Tables */
.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 780px;
}

th, td {
  padding: 11px 10px;
  border-bottom: 1px solid rgba(36, 49, 79, 0.7);
  text-align: right;
  white-space: nowrap;
}

th {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

tbody tr:hover {
  background: rgba(96, 165, 250, 0.05);
}

/* Badges */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
}

.b-buy { background: rgba(34, 211, 153, 0.14); color: var(--green); border: 1px solid rgba(34, 211, 153, 0.3); }
.b-sell { background: rgba(255, 92, 114, 0.14); color: var(--red); border: 1px solid rgba(255, 92, 114, 0.3); }
.b-watch { background: rgba(245, 196, 81, 0.14); color: var(--yellow); border: 1px solid rgba(245, 196, 81, 0.3); }
.b-neutral { background: rgba(147, 163, 194, 0.12); color: var(--muted); border: 1px solid rgba(147, 163, 194, 0.22); }
.b-purple { background: rgba(167, 139, 250, 0.14); color: var(--purple); border: 1px solid rgba(167, 139, 250, 0.3); }
.b-blue { background: rgba(96, 165, 250, 0.14); color: var(--blue); border: 1px solid rgba(96, 165, 250, 0.3); }

/* Form controls */
button, input, select, textarea {
  font: inherit;
}

button {
  border: 0;
  border-radius: 10px;
  padding: 9px 15px;
  background: var(--blue);
  color: #06101f;
  font-weight: 700;
  cursor: pointer;
  transition: opacity 0.15s ease, transform 0.1s ease;
}

button:hover { opacity: 0.92; }
button:active { transform: scale(0.98); }

button.secondary {
  background: var(--panel2);
  color: var(--text);
  border: 1px solid var(--line);
}

button.success {
  background: var(--green);
  color: #042116;
}

button.danger {
  background: var(--red);
  color: #fff;
}

button.sm {
  padding: 5px 10px;
  font-size: 12px;
}

input, select, textarea {
  background: #0a1224;
  border: 1px solid var(--line);
  color: var(--text);
  border-radius: 9px;
  padding: 9px 11px;
  outline: none;
}

input:focus, select:focus, textarea:focus {
  border-color: var(--blue);
}

.filters {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  align-items: flex-end;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 5px;
  min-width: 150px;
}

.field label {
  font-size: 12px;
  color: var(--muted);
  font-weight: 600;
}

.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }

.chart-box {
  width: 100%;
  height: 460px;
  position: relative;
  background: #090f1f;
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow: hidden;
}

.chart-sub-box {
  width: 100%;
  height: 170px;
  position: relative;
  background: #090f1f;
  border: 1px solid var(--line);
  border-radius: 12px;
  margin-top: 10px;
  overflow: hidden;
}

.chart-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 10px;
}

.chart-legend span {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  display: inline-block;
}

.mini-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 10px;
}

.mini {
  background: #0a1224;
  border: 1px solid var(--line);
  padding: 12px;
  border-radius: 12px;
}

.mini span {
  font-size: 12px;
  color: var(--muted);
  display: block;
}

.mini b {
  display: block;
  font-size: 16px;
  margin-top: 4px;
}

.opp-card {
  background: #0b1326;
  border: 1px solid var(--line);
  border-radius: 13px;
  padding: 14px;
}

.opp-card h3 {
  margin: 0 0 8px;
  font-size: 15px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.toast {
  position: fixed;
  left: 20px;
  bottom: 20px;
  background: #16223e;
  color: #fff;
  padding: 12px 18px;
  border: 1px solid var(--blue);
  border-radius: 11px;
  display: none;
  z-index: 999;
  box-shadow: var(--shadow);
  font-weight: 600;
}

.toast.error {
  border-color: var(--red);
  background: #2c131d;
}

.footer {
  color: var(--muted);
  font-size: 12px;
  margin-top: 24px;
  text-align: center;
}

.seg-btn {
  background: #0a1224;
  color: var(--muted);
  border: 1px solid var(--line);
  padding: 7px 12px;
  border-radius: 8px;
  font-size: 12px;
}

.seg-btn.active {
  background: var(--blue);
  color: #06101f;
  border-color: var(--blue);
}

.chart-box canvas,
.chart-sub-box canvas {
  width: 100%;
  height: 100%;
  display: block;
}

@media (max-width: 1080px) {
  .side { width: 205px; }
  .main { margin-right: 205px; width: calc(100% - 205px); padding: 18px; }
  .two, .three { grid-template-columns: 1fr; }
}

@media (max-width: 720px) {
  .app { display: block; }
  .side {
    position: static;
    width: 100%;
    height: auto;
    border-left: 0;
    border-bottom: 1px solid var(--line);
    padding: 12px;
  }
  .side-footer { display: none; }
  .nav {
    flex-direction: row;
    overflow-x: auto;
    gap: 6px;
    padding-bottom: 4px;
  }
  .nav a { white-space: nowrap; padding: 8px 11px; font-size: 13px; }
  .main { margin: 0; width: 100%; padding: 14px; }
  .cards { grid-template-columns: repeat(2, 1fr); }
}

/* Always win over responsive media queries when sidebar is collapsed */
body.sidebar-collapsed .side {
  transform: translateX(115%) !important;
  width: 0 !important;
  height: 0 !important;
  padding: 0 !important;
  margin: 0 !important;
  border: 0 !important;
  opacity: 0 !important;
  pointer-events: none !important;
  overflow: hidden !important;
}

body.sidebar-collapsed .main {
  margin-right: 0 !important;
  width: 100% !important;
  max-width: 100% !important;
  padding-right: 54px !important;
}

body.sidebar-collapsed .sidebar-toggle-float {
  display: inline-flex !important;
  align-items: center;
  gap: 5px;
}

/* ==============================================================
   LIVE TICKER TAPE, DISCLAIMER BANNER, FAVORITES & PLAN STYLES
   ============================================================== */

body {
  padding-bottom: 38px !important;
}

/* Bottom Ticker Tape */
.radar-bottom-ticker {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: 34px;
  background: rgba(9, 14, 26, 0.96);
  border-top: 1px solid rgba(59, 130, 246, 0.35);
  box-shadow: 0 -4px 18px rgba(0, 0, 0, 0.45);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  z-index: 9999;
  display: flex;
  align-items: center;
  direction: ltr;
  overflow: hidden;
  user-select: none;
  font-family: inherit;
}

.radar-ticker-badge {
  flex-shrink: 0;
  height: 100%;
  padding: 0 14px;
  background: linear-gradient(135deg, rgba(37, 99, 235, 0.35), rgba(16, 185, 129, 0.25));
  border-right: 1px solid rgba(59, 130, 246, 0.35);
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 11.5px;
  font-weight: 800;
  color: #93c5fd;
  direction: rtl;
  z-index: 2;
}

.radar-ticker-track-wrap {
  position: relative;
  overflow: hidden;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
}

.radar-ticker-track {
  display: flex;
  align-items: center;
  gap: 24px;
  white-space: nowrap;
  animation: radarTickerScroll 45s linear infinite;
  will-change: transform;
}

.radar-ticker-track:hover {
  animation-play-state: paused;
}

@keyframes radarTickerScroll {
  0% { transform: translateX(0); }
  100% { transform: translateX(-50%); }
}

.radar-ticker-item {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 12px;
  color: #e2e8f0;
  text-decoration: none;
  padding: 3px 8px;
  border-radius: 6px;
  background: rgba(30, 41, 59, 0.45);
  border: 1px solid rgba(51, 65, 85, 0.5);
  transition: all 0.15s ease;
}

.radar-ticker-item:hover {
  background: rgba(59, 130, 246, 0.25);
  border-color: rgba(96, 165, 250, 0.6);
  transform: translateY(-1px);
}

.radar-ticker-tag {
  font-size: 9.5px;
  font-weight: 700;
  padding: 1px 5px;
  border-radius: 4px;
}
.radar-ticker-tag.crypto { background: rgba(59, 130, 246, 0.25); color: #93c5fd; }
.radar-ticker-tag.tse { background: rgba(16, 185, 129, 0.25); color: #6ee7b7; }
.radar-ticker-tag.forex { background: rgba(167, 139, 250, 0.25); color: #ddd6fe; }

.watch-drag-handle { cursor: grab; color: #7dd3fc; font-size: 18px; line-height: 1; user-select: none; padding: 3px; }
.watch-drag-handle:active { cursor: grabbing; }
.watch-row-dragging { opacity: .45; outline: 1px dashed #38bdf8; }

/* Disclaimer Banner */
.radar-disclaimer-banner {
  background: linear-gradient(90deg, rgba(245, 158, 11, 0.12), rgba(15, 23, 42, 0.7));
  border: 1px solid rgba(245, 158, 11, 0.3);
  border-radius: 10px;
  padding: 8px 14px;
  margin-bottom: 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  font-size: 12px;
  color: #cbd5e1;
  line-height: 1.6;
}

.radar-disclaimer-banner b {
  color: #fbbf24;
}

.radar-disclaimer-close {
  background: transparent;
  border: none;
  color: #94a3b8;
  font-size: 14px;
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 4px;
}
.radar-disclaimer-close:hover {
  color: #f87171;
  background: rgba(239, 68, 68, 0.15);
}

/* Favorite Star Button */
.fav-star-btn {
  background: transparent;
  border: none;
  cursor: pointer;
  font-size: 15px;
  line-height: 1;
  padding: 2px 5px;
  color: #64748b;
  transition: all 0.15s ease;
  vertical-align: middle;
}
.fav-star-btn:hover {
  transform: scale(1.2);
  color: #fbbf24;
}
.fav-star-btn.active {
  color: #fbbf24;
  text-shadow: 0 0 8px rgba(251, 191, 36, 0.55);
}

/* Plan Badges */
.badge.b-bronze { background: rgba(217, 119, 6, 0.18); color: #f59e0b; border: 1px solid rgba(217, 119, 6, 0.45); }
.badge.b-silver { background: rgba(148, 163, 184, 0.22); color: #e2e8f0; border: 1px solid rgba(148, 163, 184, 0.45); }
.badge.b-gold { background: rgba(234, 179, 8, 0.22); color: #facc15; border: 1px solid rgba(234, 179, 8, 0.55); text-shadow: 0 0 6px rgba(250, 204, 21, 0.35); }
.badge.b-vip { background: linear-gradient(135deg, rgba(168, 85, 247, 0.25), rgba(236, 72, 153, 0.25)); color: #f472b6; border: 1px solid rgba(236, 72, 153, 0.5); text-shadow: 0 0 8px rgba(244, 114, 182, 0.4); }

/* Print & PDF Export Rules */
@media print {
  .side, .radar-bottom-ticker, .sidebar-toggle-float, .top-actions, .filters, #clearLogsModal {
    display: none !important;
  }
  .main {
    margin: 0 !important;
    width: 100% !important;
    padding: 10px !important;
  }
  body {
    background: #fff !important;
    color: #111 !important;
    padding: 0 !important;
  }
  .panel, .card {
    border: 1px solid #cbd5e1 !important;
    background: #fff !important;
    color: #111 !important;
    break-inside: avoid;
    box-shadow: none !important;
  }
  table th, table td {
    color: #111 !important;
    border-bottom: 1px solid #e2e8f0 !important;
  }
}
