:root {
  --bg: #0a0a08;
  --panel: #141410;
  --line: #2a2a22;
  --amber: #e8b04b;
  --text: #e8e6df;
  --dim: #8a8778;
  --buy: #4ade80;
  --sell: #f87171;
  --hold: #9ca3af;
  --mono: "JetBrains Mono", ui-monospace, "SF Mono", Menlo, monospace;
}

* { box-sizing: border-box; }

html { overflow-y: scroll; } /* reserve scrollbar gutter so updates don't shift layout */
body { overflow-x: hidden; }

/* Arabic uses Cairo / Droid Arabic Kufi; numbers stay in the mono face */
html[lang="ar"] body {
  font-family: "Cairo", "Droid Arabic Kufi", "Segoe UI", Tahoma, sans-serif;
}
html[lang="ar"] .price,
html[lang="ar"] .change,
html[lang="ar"] .buysell b,
html[lang="ar"] .action {
  font-family: var(--mono);
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--mono);
  font-size: 14px;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  padding: 20px 24px;
  border-bottom: 1px solid var(--line);
  position: relative;
  overflow: hidden;
}
/* always-moving scan line: page never looks frozen between pushes */
header::after {
  content: '';
  position: absolute;
  left: 0;
  bottom: -1px;
  height: 1px;
  width: 22%;
  background: linear-gradient(90deg, transparent, var(--amber), transparent);
  animation: scan 4s linear infinite;
}
@keyframes scan {
  0% { transform: translateX(-100%); opacity: 0; }
  15%, 85% { opacity: 1; }
  100% { transform: translateX(560%); opacity: 0; }
}

h1 {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: 3px;
  margin: 0;
  color: var(--text);
}
h1 span { color: var(--amber); }

.head-right {
  display: flex;
  align-items: center;
  gap: 16px;
}

#lang {
  font-family: var(--mono);
  background: transparent;
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 5px 12px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 1px;
  cursor: pointer;
  min-width: 42px;
  transition: border-color 0.2s, color 0.2s;
}
#lang:hover { border-color: var(--amber); color: var(--amber); }

#status {
  font-size: 12px;
  color: var(--dim);
  letter-spacing: 1px;
  display: flex;
  align-items: center;
  gap: 8px;
}
#status.live { color: var(--buy); }
#status .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--dim);
  flex: none;
}
#status.live .dot {
  background: var(--buy);
  animation: pulse 1.6s ease-in-out infinite;
}
@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(74, 222, 128, 0.5); opacity: 1; }
  50% { box-shadow: 0 0 0 6px rgba(74, 222, 128, 0); opacity: 0.5; }
}

main {
  flex: 1;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 1px;
  background: var(--line);
  border-bottom: 1px solid var(--line);
}

.card {
  background: var(--panel);
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.card .top {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
}
.label {
  color: var(--dim);
  letter-spacing: 2px;
  font-size: 12px;
  text-transform: uppercase;
}
.change { font-size: 13px; }
.change.up { color: var(--buy); }
.change.down { color: var(--sell); }

.price {
  font-size: 40px;
  font-weight: 700;
  letter-spacing: -1px;
  font-variant-numeric: tabular-nums;
  border-radius: 4px;
  padding: 2px 6px;
  margin: -2px -6px;
  transition: color 0.3s;
}
.price.flash-up { animation: flashUp 1s ease-out; }
.price.flash-down { animation: flashDown 1s ease-out; }
@keyframes flashUp {
  0% { background: rgba(74, 222, 128, 0.35); color: var(--buy); }
  100% { background: transparent; }
}
@keyframes flashDown {
  0% { background: rgba(248, 113, 113, 0.35); color: var(--sell); }
  100% { background: transparent; }
}

.spark {
  width: 100%;
  height: 28px;
  display: block;
  opacity: 0.85;
}

.caveat {
  font-size: 11px;
  line-height: 1.5;
  color: #d9a441;
  background: rgba(232, 176, 75, 0.08);
  border-inline-start: 2px solid var(--amber);
  padding: 8px 10px;
}

.buysell {
  display: flex;
  gap: 20px;
  font-size: 11px;
  letter-spacing: 1px;
  color: var(--dim);
}
.buysell b { color: var(--text); font-weight: 700; }

.action {
  display: inline-block;
  align-self: flex-start;
  padding: 6px 16px;
  font-weight: 700;
  letter-spacing: 3px;
  border: 1px solid currentColor;
}
.action.BUY { color: var(--buy); }
.action.SELL { color: var(--sell); }
.action.HOLD { color: var(--hold); }

.reason { color: var(--dim); font-size: 12px; line-height: 1.5; }

.track { font-size: 12px; color: var(--dim); }
.changed {
  display: inline-block;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 1px;
  color: var(--amber);
  background: rgba(232, 176, 75, 0.12);
  border: 1px solid rgba(232, 176, 75, 0.4);
  border-radius: 3px;
  padding: 2px 7px;
  margin-bottom: 6px;
}
.track-line { line-height: 1.6; }
.perf { font-weight: 700; }
.perf.up { color: var(--buy); }
.perf.down { color: var(--sell); }
.hist { margin-top: 6px; }
.hist summary {
  cursor: pointer;
  font-size: 11px;
  letter-spacing: 1px;
  color: var(--amber);
}
.hist ul { list-style: none; margin: 8px 0 0; padding: 0; }
.hist li {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 3px 0;
  font-size: 11px;
  border-top: 1px solid var(--line);
}
.h-act { font-weight: 700; }
.h-act.BUY { color: var(--buy); }
.h-act.SELL { color: var(--sell); }
.h-act.HOLD { color: var(--hold); }

.factors {
  border-top: 1px solid var(--line);
  padding-top: 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.factor {
  display: flex;
  gap: 10px;
  font-size: 11px;
  align-items: baseline;
}
.f-ind { width: 12px; flex: none; }
.f-ind.pos { color: var(--buy); }
.f-ind.neg { color: var(--sell); }
.f-ind.neu { color: var(--hold); }
.f-label {
  color: var(--text);
  width: 92px;
  flex: none;
  letter-spacing: 1px;
  text-transform: uppercase;
  font-size: 10px;
}
.f-detail { color: var(--dim); }

footer {
  padding: 28px 24px 20px;
  color: var(--dim);
  font-size: 11px;
  line-height: 1.6;
}

footer { text-align: center; }
footer .cols {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 24px;
  max-width: 1100px;
  margin: 0 auto;
}
footer p { margin: 8px 0 0; }

.ft-brand {
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 3px;
  color: var(--text);
}
.ft-brand span { color: var(--amber); }

.ft-label {
  font-size: 10px;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--amber);
}

.ft-bottom {
  margin-top: 24px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
  font-size: 10px;
  letter-spacing: 1px;
}
