/* ============================================================================
   PredSouq design system — refined institutional fintech.
   One confident accent, sharp grotesque type, hairline structure, no gradients
   as decoration, no emoji. Dark-first with a precise warm-paper light mode.
   Fonts (loaded per page): Geist (display/UI), Geist (body),
   Geist Mono (figures).
   ============================================================================ */
/* Self-hosted fonts (variable woff2) — no external dependency, so they render even when
   fonts.googleapis.com is blocked by a corporate network or ad-blocker. The Google
   <link> in each page is kept only as a redundant fallback. */
@font-face {
  font-family: "Manrope";
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url("/assets/fonts/manrope.woff2") format("woff2");
}
@font-face {
  font-family: "Geist Mono";
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url("/assets/fonts/geist-mono.woff2") format("woff2");
}
:root {
  /* "Trading floor at night" — deep cool-tinted near-blacks, real elevation steps,
     an electric-cyan accent reserved for live state/focus, color = severity. */
  --bg: #07090d;
  --bg-tint: #090c12;
  --surface: #0e1119;
  --surface-2: #141926;
  --elev: #1a2030;
  --hair: rgba(150, 170, 210, .12);
  --hair-2: rgba(150, 170, 210, .20);
  --ink: #f7faff;
  --ink-2: #c2ccde;
  --ink-3: #8a95ab;
  --accent: #1fe39a;
  --accent-2: #00cf86;
  --accent-ink: #04130d;
  --accent-soft: rgba(0, 207, 134, .14);
  --accent-glow: 0 0 0 1px rgba(0,207,134,.35), 0 8px 30px rgba(0,207,134,.22);
  --pos: #16d989;
  --pos-soft: rgba(22, 217, 137, .16);
  --neg: #ff4d6a;
  --neg-soft: rgba(255, 77, 106, .16);
  --warn: #ffb020;
  --warn-soft: rgba(255, 176, 32, .15);
  --glow-pos: 0 0 24px rgba(22, 217, 137, .28);
  --glow-neg: 0 0 24px rgba(255, 77, 106, .28);
  --r-sm: 11px; --r: 17px; --r-lg: 22px; --r-xl: 30px;
  --shadow: 0 1px 0 rgba(160,180,220,.05) inset, 0 18px 50px rgba(0,0,0,.5);
  --shadow-lg: 0 30px 90px rgba(0,0,0,.62);
  --disp: "Manrope", ui-sans-serif, sans-serif;
  --body: "Manrope", ui-sans-serif, sans-serif;
  --mono: "Geist Mono", ui-monospace, monospace;
  --ease: cubic-bezier(.2, .7, .2, 1);
  --topbg: rgba(7, 9, 13, .72);
}
:root[data-theme="light"] {
  --bg: #f6f7f9;
  --bg-tint: #eef1f5;
  --surface: #ffffff;
  --surface-2: #f1f3f7;
  --elev: #ffffff;
  --hair: rgba(15, 20, 30, .07);
  --hair-2: rgba(15, 20, 30, .12);
  --ink: #060911;
  --ink-2: #1b2433;
  --ink-3: #3b4658;
  --accent: #00cf86;
  --accent-2: #019b66;
  --accent-ink: #04130d;
  --accent-soft: rgba(0, 207, 134, .12);
  --accent-glow: 0 0 0 1px rgba(0,207,134,.30), 0 8px 24px rgba(0,207,134,.18);
  --pos: #0a9466;
  --pos-soft: rgba(10, 148, 102, .12);
  --neg: #d6394f;
  --neg-soft: rgba(214, 57, 79, .11);
  --warn: #b9791a;
  --warn-soft: rgba(185, 121, 26, .13);
  --glow-pos: 0 0 18px rgba(10, 148, 102, .18);
  --glow-neg: 0 0 18px rgba(214, 57, 79, .18);
  --shadow: 0 1px 2px rgba(17,21,28,.04), 0 6px 16px rgba(17,21,28,.05), 0 18px 40px rgba(17,21,28,.06);
  --shadow-lg: 0 12px 28px rgba(17,21,28,.10), 0 40px 80px rgba(17,21,28,.14);
  --topbg: rgba(246, 246, 243, .78);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { overflow-x: hidden; }
body { background: var(--bg); color: var(--ink); font-family: var(--body); font-size: 17px; font-weight: 500; line-height: 1.6; -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility; overflow-x: hidden; }
.mono { font-family: var(--mono); font-variant-numeric: tabular-nums; letter-spacing: -.01em; }
.disp { font-family: var(--disp); letter-spacing: -.02em; }
a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; border: 0; background: none; color: inherit; }
.pos { color: var(--pos); } .neg { color: var(--neg); } .muted { color: var(--ink-3); }
::selection { background: var(--accent-soft); }

/* hero category label */
.hero-cat { font-family: var(--mono); font-size: 10.5px; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; color: var(--accent); margin-bottom: 16px; }

/* logo lockup */
.ps-logo { display: inline-flex; align-items: center; gap: 10px; font-family: var(--disp); font-weight: 600; font-size: 17px; letter-spacing: -.02em; color: var(--ink); }
.ps-logo svg { display: block; }
.ps-mark { color: var(--accent); }
.ps-tag { font-family: var(--mono); font-size: 9.5px; font-weight: 600; letter-spacing: .18em; color: var(--ink-2); border: 1px solid var(--hair-2); border-radius: 6px; padding: 3px 7px; text-transform: uppercase; }

/* buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; font-family: var(--disp); font-weight: 700; font-size: 15px; line-height: 1; padding: 12px 20px; border-radius: 999px; transition: all .16s var(--ease); white-space: nowrap; }
.btn svg { width: 16px; height: 16px; }
.btn-primary { background: var(--accent); color: var(--accent-ink); font-weight: 600; }
.btn-primary:hover { background: var(--accent-2); transform: translateY(-1px); box-shadow: var(--accent-glow); }
.btn-primary:active { transform: translateY(0); }
.btn-ghost { border: 1px solid var(--hair-2); color: var(--ink); }
.btn-ghost:hover { border-color: var(--accent); background: var(--accent-soft); }
.btn-danger { background: var(--neg-soft); color: var(--neg); }
.btn-danger:hover { background: color-mix(in srgb, var(--neg) 22%, transparent); }
.btn:disabled { opacity: .5; cursor: default; transform: none; }
.icon-btn { width: 38px; height: 38px; border-radius: var(--r-sm); border: 1px solid var(--hair-2); display: grid; place-items: center; color: var(--ink-2); transition: all .16s var(--ease); }
.icon-btn svg { width: 17px; height: 17px; }
.icon-btn:hover { color: var(--ink); border-color: var(--accent); }

/* surfaces */
.card { background: var(--surface); border: 1px solid var(--hair); border-radius: var(--r); box-shadow: var(--shadow); }
.pill { display: inline-flex; align-items: center; gap: 6px; font-family: var(--mono); font-size: 12px; font-weight: 600; letter-spacing: .02em; padding: 5px 11px; border-radius: 999px; background: var(--surface-2); color: var(--ink-2); }
.kbadge { font-size: 10px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; padding: 3px 8px; border-radius: 6px; }
.kbadge.up { background: var(--pos-soft); color: var(--pos); }
.kbadge.down { background: var(--neg-soft); color: var(--neg); }
.kbadge.neutral { background: var(--surface-2); color: var(--ink-2); }

/* inputs */
.field label { display: block; font-size: 13px; color: var(--ink-3); margin-bottom: 6px; font-weight: 500; }
.input { width: 100%; background: var(--bg-tint); border: 1px solid var(--hair-2); border-radius: var(--r-sm); padding: 11px 13px; color: var(--ink); font-size: 15px; font-family: var(--body); transition: border-color .15s; }
:root[data-theme="light"] .input { background: var(--surface-2); }
.input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.input.mono { font-family: var(--mono); }

/* live dot */
.live-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--pos); box-shadow: 0 0 0 0 var(--pos-soft); animation: ps-pulse 2.4s infinite; }
@keyframes ps-pulse { 0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--pos) 55%, transparent); } 70% { box-shadow: 0 0 0 7px transparent; } 100% { box-shadow: 0 0 0 0 transparent; } }

/* reveal-on-load / scroll */
.reveal { opacity: 0; transform: translateY(18px); transition: opacity .7s var(--ease), transform .7s var(--ease); }
.reveal.in { opacity: 1; transform: none; }

/* skeleton */
.skel { background: linear-gradient(90deg, var(--surface) 25%, var(--surface-2) 37%, var(--surface) 63%); background-size: 400% 100%; animation: ps-sh 1.3s infinite; border-radius: var(--r-sm); }
@keyframes ps-sh { 0% { background-position: 100% 0; } 100% { background-position: -100% 0; } }

/* toast */
.toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%) translateY(16px); background: var(--elev); border: 1px solid var(--hair-2); border-radius: 11px; padding: 12px 18px; font-size: 13.5px; font-weight: 500; opacity: 0; transition: all .26s var(--ease); z-index: 80; box-shadow: var(--shadow-lg); pointer-events: none; }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* scrollbars */
*::-webkit-scrollbar { width: 9px; height: 9px; }
*::-webkit-scrollbar-thumb { background: var(--hair-2); border-radius: 9px; }
*::-webkit-scrollbar-track { background: transparent; }

/* ============================================================================
   Premium layer — glass depth, accent glow, severity colours, live motion.
   ============================================================================ */
.warn { color: var(--warn); }
.kbadge.warn { background: var(--warn-soft); color: var(--warn); }
.pill.warn { background: var(--warn-soft); color: var(--warn); }
.pill.live-on { background: var(--accent-soft); color: var(--accent-2); }

/* glass surfaces with real elevation + a lit top edge (fallback when unsupported) */
.glass { background: color-mix(in srgb, var(--surface) 80%, transparent); border: 1px solid var(--hair); border-radius: var(--r); box-shadow: var(--shadow); }
@supports (backdrop-filter: blur(6px)) {
  .glass { backdrop-filter: blur(16px) saturate(140%); -webkit-backdrop-filter: blur(16px) saturate(140%); }
}
.glass-top { position: sticky; top: 0; z-index: 30; background: var(--topbg); border-bottom: 1px solid var(--hair); }
@supports (backdrop-filter: blur(6px)) { .glass-top { backdrop-filter: blur(16px) saturate(140%); -webkit-backdrop-filter: blur(16px) saturate(140%); } }
.elev-edge { box-shadow: 0 1px 0 rgba(160,180,220,.06) inset, var(--shadow); }
.accent-edge { border-color: color-mix(in srgb, var(--accent) 45%, var(--hair)) !important; box-shadow: var(--accent-glow); }

/* live number flash (applied by PS.tickNumber) */
.tick-up { animation: ps-tick-up .6s var(--ease); }
.tick-down { animation: ps-tick-down .6s var(--ease); }
@keyframes ps-tick-up { 0% { color: var(--pos); text-shadow: var(--glow-pos); } 100% { } }
@keyframes ps-tick-down { 0% { color: var(--neg); text-shadow: var(--glow-neg); } 100% { } }

/* severity alert pulse ring */
.pulse-critical { animation: ps-pulse-crit 1.6s var(--ease) infinite; }
.pulse-warn { animation: ps-pulse-warn 2s var(--ease) infinite; }
@keyframes ps-pulse-crit { 0% { box-shadow: 0 0 0 0 var(--neg-soft); } 70% { box-shadow: 0 0 0 6px transparent; } 100% { box-shadow: 0 0 0 0 transparent; } }
@keyframes ps-pulse-warn { 0% { box-shadow: 0 0 0 0 var(--warn-soft); } 70% { box-shadow: 0 0 0 6px transparent; } 100% { box-shadow: 0 0 0 0 transparent; } }

/* row insert flash for live feeds */
.row-flash { animation: ps-row-flash .9s var(--ease); }
@keyframes ps-row-flash { 0% { background: var(--accent-soft); } 100% { background: transparent; } }

/* premium sparkline last-point glow handled inline; gauge fill */
.bar-track { height: 10px; border-radius: 99px; background: var(--surface-2); overflow: hidden; }
.bar-fill { height: 100%; border-radius: 99px; transition: width .5s var(--ease); }

@media (prefers-reduced-motion: reduce) {
  .tick-up, .tick-down, .pulse-critical, .pulse-warn, .row-flash, .live-dot { animation: none !important; }
}

/* ===== Shared trader-app left sidebar (Markets/Terminal/Perps/Portfolio/Account) ===== */
body.railed { padding-left: 236px; }
.app-rail { position: fixed; left: 0; top: 0; bottom: 0; width: 236px; background: var(--surface); border-right: 1px solid var(--hair); box-shadow: 1px 0 0 var(--hair); display: flex; flex-direction: column; overflow-y: auto; z-index: 60; }
.app-rail .rbrand { display: flex; align-items: center; gap: 9px; font-family: var(--disp); font-weight: 800; font-size: 18px; letter-spacing: -.03em; padding: 22px 18px 14px; white-space: nowrap; }
.app-rail .rbrand .ps-mark { color: var(--accent); display: flex; }
.app-rail nav { display: flex; flex-direction: column; gap: 2px; padding: 6px 12px; }
.app-rail nav a { display: flex; align-items: center; gap: 11px; padding: 10px 13px; border-radius: 11px; font-family: var(--disp); font-weight: 600; font-size: 14.5px; color: var(--ink-2); transition: background .14s, color .14s; }
.app-rail nav a i { display: flex; color: var(--ink-3); transition: color .14s; }
.app-rail nav a:hover { background: var(--surface-2); color: var(--ink); }
.app-rail nav a:hover i { color: var(--ink-2); }
.app-rail nav a.on { background: var(--accent-soft); color: var(--accent); font-weight: 700; }
.app-rail nav a.on i { color: var(--accent); }
.app-rail .rfoot { margin-top: auto; border-top: 1px solid var(--hair); padding: 14px 16px; display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.app-rail .rfoot .bal .l { font-family: var(--mono); font-size: 9.5px; letter-spacing: .1em; color: var(--ink-3); font-weight: 700; }
.app-rail .rfoot .bal .v { font-family: var(--mono); font-weight: 800; font-size: 18px; letter-spacing: -.02em; }
@media (max-width: 900px) {
  body.railed { padding-left: 0; }
  .app-rail { position: sticky; top: 0; width: auto; flex-direction: row; align-items: center; gap: 4px; border-right: 0; border-bottom: 1px solid var(--hair); box-shadow: none; overflow-x: auto; -webkit-overflow-scrolling: touch; }
  /* keep the mark for identity but drop the wordmark so the tabs lead on a cramped bar */
  .app-rail .rbrand { padding: 0 6px 0 14px; font-size: 0; flex: none; }
  .app-rail .rbrand [data-brand-name] { display: none; }
  .app-rail .rbrand .ps-mark svg { width: 22px; height: 22px; }
  .app-rail nav { flex-direction: row; padding: 6px 6px; gap: 2px; flex: 1; }
  .app-rail nav a { padding: 9px 13px; white-space: nowrap; border-radius: 999px; } .app-rail nav a i { display: none; }
  .app-rail nav a.on { background: var(--accent-soft); color: var(--accent); }
  .app-rail .rfoot { margin: 0; border-top: 0; padding: 6px 12px; flex: none; gap: 8px; }
  .app-rail .rfoot .bal { text-align: right; line-height: 1; }
  .app-rail .rfoot .bal .l { font-size: 8px; }
  .app-rail .rfoot .bal .v { font-size: 14px; }
  .app-rail .rfoot .muted { display: none; }
}

/* ===== Accessibility: visible keyboard focus across every interactive element ===== */
/* Mouse users don't see it (:focus-visible only); keyboard users always do. */
a:focus-visible, button:focus-visible, [role="button"]:focus-visible, [tabindex]:focus-visible,
input:focus-visible, select:focus-visible, textarea:focus-visible, summary:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 4px;
}

/* ---- RTL (Arabic) ---- */
[dir="rtl"] body, [dir="rtl"] input, [dir="rtl"] button, [dir="rtl"] select, [dir="rtl"] textarea {
  font-family: "Manrope", "Noto Sans Arabic", "Segoe UI", Tahoma, sans-serif;
}
[dir="rtl"] body.railed { padding-left: 0; padding-right: 236px; }
[dir="rtl"] .app-rail { left: auto; right: 0; border-right: 0; border-left: 1px solid var(--hair); box-shadow: -1px 0 0 var(--hair); }
[dir="rtl"] .app-rail nav a.on { /* accent bar / radius stay symmetric */ }
@media (max-width: 760px) { [dir="rtl"] body.railed { padding-right: 0; } }
