/* ============================================
   SCREENER DUBAI — Source-grouped dashboard
   TradingView-inspired dark theme
   ============================================ */

*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }

:root {
  --bg-primary: #0c0e15;
  --bg-secondary: #131722;
  --bg-card: #1c1f2e;
  --bg-card-hover: #242842;
  --bg-row-hover: rgba(41, 98, 255, 0.06);
  --text-primary: #d1d4dc;
  --text-secondary: #787b86;
  --text-white: #ffffff;
  --text-muted: #5d606b;
  --accent-blue: #2962ff;
  --green: #26a69a;
  --green-bg: rgba(38, 166, 154, 0.1);
  --red: #ef5350;
  --red-bg: rgba(239, 83, 80, 0.1);
  --orange: #ff9800;
  --border: rgba(255, 255, 255, 0.06);
  --border-hover: rgba(255, 255, 255, 0.12);
  --radius-sm: 6px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --font: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --mono: 'JetBrains Mono', 'Fira Code', monospace;
  --container: 1400px;
  --header-h: 56px;
  --ease: cubic-bezier(0.4, 0, 0.2, 1);
}

html { scroll-behavior: smooth; -webkit-font-smoothing: antialiased; }

body {
  font-family: var(--font);
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.5;
  overflow-x: hidden;
}

a { color: inherit; text-decoration: none; }
button { cursor: pointer; font-family: inherit; border: none; background: none; }
table { border-collapse: collapse; width: 100%; }
.container { max-width: var(--container); margin: 0 auto; padding: 0 24px; }

/* ============================================ VIDEO BG */

.video-bg { position: fixed; inset: 0; z-index: 0; pointer-events: none; }
.video-bg::after {
  content: ''; position: absolute; inset: 0;
  background: linear-gradient(180deg,
    rgba(12,14,21,.75) 0%, rgba(12,14,21,.5) 25%,
    rgba(12,14,21,.82) 60%, rgba(12,14,21,.97) 100%);
}
.video-bg video { width: 100%; height: 100%; object-fit: cover; }
.header, main, .footer { position: relative; z-index: 1; }

/* ============================================ HEADER */

.header {
  position: fixed; top: 0; left: 0; right: 0;
  height: var(--header-h); z-index: 100;
  background: rgba(12,14,21,.85);
  backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border);
}

.header-inner {
  max-width: var(--container); margin: 0 auto; padding: 0 24px;
  height: 100%; display: flex; align-items: center; gap: 24px;
}

.logo {
  display: flex; align-items: center; gap: 10px;
  font-size: 18px; font-weight: 700; color: var(--text-white); flex-shrink: 0;
}

.header-status {
  margin-left: auto; display: flex; align-items: center; gap: 10px;
  font-size: 12px; color: var(--text-secondary);
}

.status-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--orange); transition: background .3s; }
.status-dot.connected { background: var(--green); }
.status-dot.error { background: var(--red); }

.status-sep { color: var(--border-hover); }

.stat-inline {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text-muted);
}
.stat-inline span { color: var(--text-primary); font-weight: 600; }

/* ============================================ HERO */

.hero {
  padding: calc(var(--header-h) + 40px) 0 24px;
  text-align: center;
}

.hero-title {
  font-size: clamp(24px, 4.5vw, 48px);
  font-weight: 800; line-height: 1.15;
  color: var(--text-white); margin-bottom: 12px;
  letter-spacing: -0.02em;
  animation: fadeInUp .5s var(--ease) .1s both;
}

.gradient-text {
  background: linear-gradient(135deg, #2962ff, #7c4dff, #e040fb);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text;
}

.hero-subtitle {
  max-width: 680px; margin: 0 auto;
  font-size: 15px; color: var(--text-secondary); line-height: 1.6;
  animation: fadeInUp .5s var(--ease) .2s both;
}

/* ============================================ SOURCE BLOCKS */

.section { padding: 24px 0 80px; }

.source-blocks {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
}

.source-block {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  transition: border-color .2s var(--ease), box-shadow .2s var(--ease);
  animation: fadeInUp .4s var(--ease) both;
}

.source-block:nth-child(1) { animation-delay: 0s; }
.source-block:nth-child(2) { animation-delay: .05s; }
.source-block:nth-child(3) { animation-delay: .1s; }
.source-block:nth-child(4) { animation-delay: .15s; }
.source-block:nth-child(5) { animation-delay: .2s; }
.source-block:nth-child(6) { animation-delay: .25s; }
.source-block:nth-child(7) { animation-delay: .3s; }

.source-block:hover {
  border-color: var(--border-hover);
  box-shadow: 0 8px 32px rgba(0,0,0,.25);
}

/* Source block header */
.sb-header {
  padding: 16px 20px 12px;
  border-bottom: 1px solid var(--border);
}

.sb-title-row {
  display: flex; align-items: center; gap: 10px; margin-bottom: 4px;
}

.sb-dot {
  width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0;
}

.sb-logo {
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; transition: opacity .2s;
}
.sb-logo img { display: block; }
a.sb-logo:hover { opacity: .7; }

.sb-name a {
  color: inherit; text-decoration: none;
  transition: opacity .2s;
}
.sb-name a:hover { opacity: .7; }

.sb-name {
  font-size: 16px; font-weight: 700; color: var(--text-white);
}

.sb-status {
  margin-left: auto;
  font-size: 10px; font-weight: 700; text-transform: uppercase;
  letter-spacing: .5px; padding: 2px 10px; border-radius: 100px;
}

.sb-status.online { background: var(--green-bg); color: var(--green); }
.sb-status.pending { background: rgba(255,152,0,.12); color: var(--orange); }
.sb-status.error { background: var(--red-bg); color: var(--red); }

.sb-desc {
  font-size: 12px; color: var(--text-muted); line-height: 1.4;
}

/* Source block body */
.sb-body { padding: 0; }

/* Table inside source block */
.sb-table { width: 100%; }

.sb-table thead { background: rgba(255,255,255,.02); }

.sb-table th {
  padding: 8px 16px; font-size: 10px; font-weight: 600;
  text-transform: uppercase; letter-spacing: .5px;
  color: var(--text-muted); text-align: left;
  border-bottom: 1px solid var(--border); white-space: nowrap;
}

.sb-table th.r { text-align: right; }

.sb-table td {
  padding: 8px 16px; font-size: 13px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap; transition: background .15s;
}

.sb-table tbody tr { cursor: pointer; transition: background .15s; }
.sb-table tbody tr:hover { background: var(--bg-row-hover); }
.sb-table tbody tr:last-child td { border-bottom: none; }

.td-sym { font-weight: 600; color: var(--text-white); }

.td-num {
  text-align: right; font-family: var(--mono);
  font-size: 13px; font-weight: 500; color: var(--text-primary);
}

.td-last { color: var(--text-white); font-weight: 600; }

.td-chg { text-align: right; font-family: var(--mono); font-weight: 600; }
.td-chg.up { color: var(--green); }
.td-chg.down { color: var(--red); }
.td-chg.flat { color: var(--text-muted); }

.no-data { color: var(--text-muted); }

/* Sparkline mini-chart */
.sparkline { vertical-align: middle; margin-left: 6px; opacity: .85; }
[data-f="spark"] { display: inline; }

/* Range bar (price position in day high-low range) */
[data-f="range"] { display: block; }
.range-bar {
  height: 2px; background: rgba(255,255,255,.06);
  border-radius: 1px; margin-top: 4px; overflow: hidden;
}
.range-fill {
  height: 100%; border-radius: 1px;
  background: var(--green);
  transition: width .3s var(--ease);
}

/* Flash */
.flash-green { animation: flashGreen .6s ease; }
.flash-red { animation: flashRed .6s ease; }

@keyframes flashGreen { 0% { background: var(--green-bg); } 100% { background: transparent; } }
@keyframes flashRed { 0% { background: var(--red-bg); } 100% { background: transparent; } }

/* Pending source placeholder */
.sb-pending {
  padding: 32px 20px;
  text-align: center;
}

.sb-pending-icon {
  margin-bottom: 12px;
  animation: pendingSpin 4s linear infinite;
}

@keyframes pendingSpin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

.sb-pending-text {
  font-size: 14px; font-weight: 600;
  color: var(--text-muted); margin-bottom: 16px;
}

.sb-pending-pairs {
  display: flex; flex-wrap: wrap; gap: 6px;
  justify-content: center;
}

.sb-pending-pair {
  display: inline-block;
  padding: 4px 12px; border-radius: 100px;
  background: rgba(255,255,255,.04);
  border: 1px solid var(--border);
  font-size: 12px; font-weight: 500; color: var(--text-secondary);
}

.sb-pending-pair small {
  color: var(--text-muted); font-weight: 400;
}

/* ============================================ ORDERBOOK MODAL */

.modal-overlay {
  display: none; position: fixed; inset: 0; z-index: 200;
  background: rgba(0,0,0,.6); backdrop-filter: blur(4px);
  align-items: center; justify-content: center;
}
.modal-overlay.open { display: flex; }

.modal {
  background: var(--bg-secondary);
  border: 1px solid var(--border-hover);
  border-radius: var(--radius-lg);
  width: 90%; max-width: 480px; max-height: 80vh;
  overflow: hidden; display: flex; flex-direction: column;
  animation: modalIn .2s var(--ease);
}

@keyframes modalIn {
  from { opacity: 0; transform: scale(.95) translateY(10px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}

.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px; border-bottom: 1px solid var(--border);
}
.modal-header h3 { font-size: 16px; font-weight: 700; color: var(--text-white); }
.modal-close { font-size: 24px; color: var(--text-secondary); padding: 4px; }
.modal-close:hover { color: var(--text-white); }

.modal-body { padding: 16px 20px; overflow-y: auto; }

.orderbook { display: flex; flex-direction: column; gap: 2px; font-family: var(--mono); font-size: 12px; }

.ob-row {
  display: grid; grid-template-columns: 1fr 1fr 1fr;
  gap: 8px; padding: 3px 8px; border-radius: 3px; position: relative;
}
.ob-asks .ob-row { color: var(--red); }
.ob-bids .ob-row { color: var(--green); }
.ob-row .ob-price { text-align: center; font-weight: 600; }
.ob-row .ob-volume { text-align: right; color: var(--text-secondary); }
.ob-row .ob-total { text-align: right; color: var(--text-muted); font-size: 11px; }
.ob-row .ob-bar { position: absolute; top: 0; bottom: 0; border-radius: 3px; opacity: .08; }
.ob-asks .ob-bar { right: 0; background: var(--red); }
.ob-bids .ob-bar { right: 0; background: var(--green); }

.ob-spread {
  text-align: center; padding: 8px; font-size: 13px; font-weight: 600;
  color: var(--text-white); background: rgba(255,255,255,.03);
  border-radius: 4px; margin: 4px 0;
}

.ob-loading { text-align: center; color: var(--text-muted); padding: 20px; }

/* ============================================ FOOTER */

.footer { border-top: 1px solid var(--border); padding: 20px 0; }
.footer-inner {
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; color: var(--text-muted);
}

/* ============================================ ANIMATIONS */

@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ============================================ RESPONSIVE */

@media (max-width: 1024px) {
  .source-blocks { grid-template-columns: 1fr; }
}

@media (max-width: 768px) {
  .hero-title { font-size: clamp(22px, 7vw, 36px); }
  .header-status .stat-inline { display: none; }
  .header-status .status-sep { display: none; }
  .sb-table { min-width: 500px; }
  .sb-body { overflow-x: auto; -webkit-overflow-scrolling: touch; }
}

/* Scrollbar */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--bg-primary); }
::-webkit-scrollbar-thumb { background: var(--bg-card); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

::selection { background: rgba(41,98,255,.3); color: var(--text-white); }

/* ============================================ LANG TOGGLE */

.lang-toggle {
  font-size: 11px; font-weight: 700; text-transform: uppercase;
  letter-spacing: .5px; padding: 3px 10px; border-radius: 100px;
  background: rgba(255,255,255,.06); color: var(--text-secondary);
  border: 1px solid var(--border); cursor: pointer;
  transition: all .2s var(--ease);
}
.lang-toggle:hover { background: rgba(255,255,255,.12); color: var(--text-white); }

/* ============================================ UPDATE INTERVAL */

.sb-interval {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 11px; color: var(--text-muted);
  margin-left: 8px; font-weight: 400;
}
.sb-interval::before {
  content: ''; width: 4px; height: 4px; border-radius: 50%;
  background: currentColor; flex-shrink: 0;
}

/* ============================================ FOOTER DEMO */

.footer-inner { flex-direction: column; gap: 6px; }
.footer-demo {
  font-size: 11px; color: var(--text-muted);
  max-width: 600px; text-align: center; line-height: 1.5;
  opacity: .7;
}

/* ============================================ INLINE ORDERBOOK */

.sb-orderbook {
  padding: 12px 16px; border-top: 1px solid var(--border);
  background: rgba(0,0,0,.15);
}

.sb-ob-title {
  font-size: 11px; font-weight: 600; text-transform: uppercase;
  letter-spacing: .5px; color: var(--text-muted); margin-bottom: 8px;
}

.sb-ob-grid {
  display: grid; grid-template-columns: 1fr auto 1fr; gap: 8px;
}

.sb-ob-side { display: flex; flex-direction: column; gap: 1px; }

.sb-ob-row {
  display: grid; grid-template-columns: 1fr 1fr;
  gap: 4px; font-family: var(--mono); font-size: 11px;
  padding: 2px 6px; border-radius: 2px; position: relative;
}

.sb-ob-row .ob-bar {
  position: absolute; top: 0; bottom: 0; border-radius: 2px; opacity: .08;
}

.sb-ob-asks .sb-ob-row { color: var(--red); }
.sb-ob-asks .ob-bar { right: 0; background: var(--red); }
.sb-ob-bids .sb-ob-row { color: var(--green); }
.sb-ob-bids .ob-bar { right: 0; background: var(--green); }

.sb-ob-row .price { text-align: right; font-weight: 600; }
.sb-ob-row .vol { text-align: left; color: var(--text-secondary); }

.sb-ob-spread {
  display: flex; align-items: center; justify-content: center;
  font-family: var(--mono); font-size: 11px; font-weight: 600;
  color: var(--text-white); writing-mode: vertical-lr;
  text-orientation: mixed; white-space: nowrap;
}

.sb-orderbook-container { border-top: 1px solid var(--border); }
.sb-orderbook + .sb-orderbook { border-top: 1px solid var(--border); }

/* Error status block */
.sb-status.error { background: var(--red-bg); color: var(--red); }

/* ============================================ SPACE VIDEO */

.space-video-section {
  position: relative; z-index: 1;
  width: 100%; overflow: hidden;
  margin-top: -40px;
}

.space-video {
  width: 100%; height: auto;
  display: block;
  object-fit: cover;
}

.space-overlay {
  position: absolute;
  inset: 0;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  text-align: center;
  padding: 40px 24px;
  background: radial-gradient(ellipse at center, rgba(0,0,0,.35) 0%, transparent 65%);
}

.space-title {
  font-size: clamp(24px, 4vw, 52px);
  font-weight: 800; line-height: 1.15;
  letter-spacing: -0.03em;
  margin-bottom: 20px;
  background: linear-gradient(135deg, #ffffff 0%, #a78bfa 25%, #60a5fa 50%, #34d399 75%, #ffffff 100%);
  background-size: 300% 300%;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  animation: spaceGradient 8s ease infinite;
  filter: drop-shadow(0 0 40px rgba(124, 77, 255, .4)) drop-shadow(0 4px 20px rgba(0,0,0,.5));
}

@keyframes spaceGradient {
  0%, 100% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
}

.space-subtitle {
  font-size: clamp(13px, 1.6vw, 18px);
  font-weight: 600;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: rgba(255,255,255,.6);
  text-shadow: 0 0 30px rgba(124, 77, 255, .3), 0 2px 10px rgba(0,0,0,.5);
  animation: spacePulse 4s ease-in-out infinite;
}

@keyframes spacePulse {
  0%, 100% { opacity: .6; }
  50% { opacity: 1; }
}

.space-overlay::before {
  content: '';
  position: absolute;
  top: 50%; left: 50%;
  width: 600px; height: 600px;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  background: radial-gradient(circle, rgba(41, 98, 255, .08) 0%, rgba(124, 77, 255, .04) 40%, transparent 70%);
  animation: spaceGlow 6s ease-in-out infinite;
  pointer-events: none;
}

@keyframes spaceGlow {
  0%, 100% { transform: translate(-50%, -50%) scale(1); opacity: .5; }
  50% { transform: translate(-50%, -50%) scale(1.2); opacity: 1; }
}

/* Separator line above space section */
.space-video-section::before {
  content: '';
  position: absolute; top: 0; left: 10%; right: 10%;
  height: 1px; z-index: 2;
  background: linear-gradient(90deg, transparent, rgba(124, 77, 255, .3), rgba(41, 98, 255, .3), transparent);
}
