/* ===== Trading — premium market UI ===== */
:root {
  --bg: #070b16;
  --bg-2: #0c1325;
  --panel: #101a31;
  --panel-2: #18233f;
  --line: #283651;
  --line-soft: #1b2540;
  --txt: #eef2fb;
  --txt-dim: #9aa7c9;
  --txt-mute: #6b7aa0;
  --brand: #e7b84e;
  --brand-soft: #ffd87a;
  --accent: #5b8cff;
  --up: #25d186;
  --up-bg: rgba(37, 209, 134, .13);
  --dn: #ff5d74;
  --dn-bg: rgba(255, 93, 116, .13);
  --flat: #8190b5;
  --radius: 18px;
  --radius-sm: 12px;
  --shadow: 0 18px 44px rgba(0, 0, 0, .5);
  --font: "Cairo", "Segoe UI", "Tahoma", system-ui, -apple-system, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background:
    radial-gradient(950px 520px at 88% -10%, rgba(91, 140, 255, .12), transparent 60%),
    radial-gradient(1100px 620px at 8% 0%, rgba(231, 184, 78, .08), transparent 55%),
    var(--bg) fixed;
  color: var(--txt);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.55;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}
[dir="rtl"] { direction: rtl; }
a { color: inherit; text-decoration: none; }
::-webkit-scrollbar { height: 10px; width: 10px; }
::-webkit-scrollbar-thumb { background: var(--line); border-radius: 8px; }
::-webkit-scrollbar-thumb:hover { background: #34456b; }

/* ---- top bar ---- */
.topbar {
  position: sticky; top: 0; z-index: 50;
  display: flex; align-items: center; gap: 18px;
  padding: 14px 24px;
  background: rgba(9, 14, 26, .72);
  backdrop-filter: blur(16px) saturate(150%);
  -webkit-backdrop-filter: blur(16px) saturate(150%);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; }
.brand .dot { width: 15px; height: 15px; border-radius: 5px; transform: rotate(45deg);
  background: linear-gradient(135deg, var(--brand-soft), var(--brand));
  box-shadow: 0 0 18px rgba(231, 184, 78, .55); }
.brand-name { font-weight: 900; font-size: 22px; letter-spacing: .4px;
  background: linear-gradient(90deg, var(--brand-soft), var(--brand));
  -webkit-background-clip: text; background-clip: text; color: transparent; }
.nav { display: flex; gap: 4px; margin-inline-start: 8px; }
.nav a {
  padding: 8px 14px; border-radius: 10px; color: var(--txt-dim);
  font-weight: 600; transition: .15s;
}
.nav a:hover { background: var(--panel); color: var(--txt); }
.nav a.active { background: var(--panel-2); color: var(--brand-soft);
  box-shadow: inset 0 -2px 0 var(--brand); }
.search { margin-inline-start: auto; display: flex; gap: 8px; align-items: center; }
.search input {
  width: 320px; max-width: 38vw; padding: 10px 14px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 12px;
  color: var(--txt); font-size: 13px; font-family: var(--font);
}
.search input::placeholder { color: var(--txt-mute); }
.search input:focus { outline: none; border-color: var(--brand); }
.search { position: relative; }
.search-results {
  position: absolute; top: calc(100% + 8px); inset-inline-start: 0;
  width: 420px; max-width: 70vw; max-height: 60vh; overflow-y: auto;
  background: var(--panel); border: 1px solid var(--line); border-radius: 12px;
  box-shadow: var(--shadow); z-index: 100; display: none; padding: 6px;
}
.search-results.open { display: block; }
.search-results .sr-item {
  display: grid; grid-template-columns: 1fr auto auto; gap: 11px;
  align-items: center; padding: 9px 11px; border-radius: 9px; cursor: pointer;
}
.search-results .sr-item:hover, .search-results .sr-item.hl { background: var(--panel-2); }
.search-results .sr-logo { width: 30px; height: 30px; border-radius: 8px; background: var(--panel-2);
  display: grid; place-items: center; font-weight: 800; color: var(--brand-soft); font-size: 11px; }
.search-results .sr-nm b { font-weight: 700; }
.search-results .sr-nm span { color: var(--txt-mute); font-size: 12px; display: block; }
.search-results .sr-px { font-weight: 800; font-variant-numeric: tabular-nums; }
.search-results .sr-empty { padding: 16px; text-align: center; color: var(--txt-mute); }
.btn {
  padding: 10px 18px; border-radius: 12px; border: 1px solid transparent;
  background: linear-gradient(135deg, var(--brand-soft), var(--brand));
  color: #2a1d02; font-weight: 800; cursor: pointer;
  font-family: var(--font); font-size: 13px; transition: .18s;
  box-shadow: 0 6px 18px rgba(231, 184, 78, .22);
}
.btn:hover { filter: brightness(1.06); transform: translateY(-1px); box-shadow: 0 10px 26px rgba(231, 184, 78, .34); }
.btn.ghost { background: transparent; border-color: var(--line); color: var(--txt-dim); box-shadow: none; }
.btn.ghost:hover { color: var(--txt); border-color: var(--brand); filter: none; }

/* ---- index strip ---- */
.indexstrip {
  display: flex; align-items: center; gap: 26px; flex-wrap: wrap;
  padding: 12px 24px; background: rgba(8, 13, 28, .55);
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line-soft); font-size: 13px;
}
.idx { display: flex; align-items: center; gap: 10px; }
.idx .k { color: var(--txt-mute); font-weight: 700; letter-spacing: .04em; }
.idx .v { font-weight: 800; font-variant-numeric: tabular-nums; }
.idx .src { margin-inline-start: auto; color: var(--txt-mute); }
.pill { padding: 2px 10px; border-radius: 999px; font-weight: 800; font-size: 12px; font-variant-numeric: tabular-nums; }
.pill.up { color: var(--up); background: var(--up-bg); }
.pill.dn { color: var(--dn); background: var(--dn-bg); }
.pill.flat { color: var(--flat); background: rgba(129,144,181,.12); }

/* ---- layout ---- */
.wrap { max-width: 1500px; margin: 0 auto; padding: 22px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px; }
@media (max-width: 1050px) { .grid-3 { grid-template-columns: 1fr; } }

.panel {
  background: linear-gradient(180deg, var(--panel), var(--bg-2));
  border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); overflow: hidden;
  transition: border-color .18s, box-shadow .18s;
}
.panel:hover { border-color: #35466c; }
.panel-h {
  display: flex; align-items: center; gap: 10px;
  padding: 15px 18px; border-bottom: 1px solid var(--line-soft);
  background: linear-gradient(180deg, rgba(255,255,255,.02), transparent);
}
.panel-h h3 { margin: 0; font-size: 15px; font-weight: 800; }
.panel-h .ico { width: 26px; height: 26px; display: grid; place-items: center;
  border-radius: 8px; background: var(--panel-2); }
.panel-h .count { margin-inline-start: auto; color: var(--txt-mute); font-size: 12px;
  background: var(--panel-2); padding: 3px 10px; border-radius: 999px; }

/* ---- mover rows ---- */
.movers { padding: 6px; }
.mover {
  display: grid; grid-template-columns: 1fr auto auto;
  align-items: center; gap: 12px; padding: 10px 12px; border-radius: 10px;
  transition: .12s; cursor: pointer;
}
.mover:hover { background: var(--panel-2); box-shadow: inset 2px 0 0 var(--brand); }
.mover .logo { width: 34px; height: 34px; border-radius: 9px; background: var(--panel-2);
  display: grid; place-items: center; font-weight: 800; color: var(--brand-soft); font-size: 12px; }
.mover .nm { display: flex; flex-direction: column; min-width: 0; }
.mover .nm b { font-size: 14px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mover .nm span { color: var(--txt-mute); font-size: 12px; }
.mover .px { text-align: end; font-weight: 800; font-variant-numeric: tabular-nums; font-size: 15px; }
.mover .meta { text-align: end; color: var(--txt-mute); font-size: 11px; }

/* ---- table ---- */
.section-h { display: flex; align-items: center; gap: 12px; margin: 26px 4px 14px; }
.section-h h2 { margin: 0; font-size: 18px; font-weight: 800; }
.section-h .count { color: var(--txt-mute); font-size: 12px; background: var(--panel);
  padding: 4px 12px; border-radius: 999px; border: 1px solid var(--line); }
.section-h .filter { margin-inline-start: auto; }
.section-h .filter input {
  width: 280px; max-width: 50vw; padding: 9px 14px; background: var(--panel);
  border: 1px solid var(--line); border-radius: 10px; color: var(--txt); font-family: var(--font);
}
.section-h .filter input:focus { outline: none; border-color: var(--brand); }

.tablewrap { background: linear-gradient(180deg, var(--panel), var(--bg-2));
  border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); }
table.market { width: 100%; border-collapse: collapse; }
table.market thead th {
  position: sticky; top: 0; background: linear-gradient(180deg, #131e38, #0d1730); color: var(--txt-dim);
  font-size: 12px; font-weight: 700; text-align: center; padding: 14px 10px;
  border-bottom: 1px solid var(--line); white-space: nowrap; cursor: pointer; user-select: none;
  letter-spacing: .02em;
}
table.market thead th:hover { color: var(--brand-soft); }
table.market thead th.start { text-align: start; }
table.market tbody td { padding: 13px 10px; text-align: center; border-bottom: 1px solid var(--line-soft);
  font-variant-numeric: tabular-nums; white-space: nowrap; }
table.market tbody tr { transition: .12s; cursor: pointer; }
table.market tbody tr:hover { background: var(--panel-2); box-shadow: inset 0 0 0 1px rgba(231,184,78,.12); }
table.market tbody tr:last-child td { border-bottom: none; }
.co { display: flex; align-items: center; gap: 11px; text-align: start; }
.co .logo { width: 30px; height: 30px; border-radius: 8px; background: var(--panel-2);
  display: grid; place-items: center; font-weight: 800; color: var(--brand-soft); font-size: 11px; flex: none; }
.co b { font-weight: 700; }
.co small { color: var(--txt-mute); display: block; }
.sym { color: var(--brand-soft); font-weight: 800; }
.num { font-weight: 700; }
.up-t { color: var(--up); } .dn-t { color: var(--dn); } .flat-t { color: var(--flat); }

/* ---- stock page ---- */
.stock-head { display: flex; align-items: flex-start; gap: 18px; flex-wrap: wrap; margin-bottom: 20px; }
.stock-head .logo-lg { width: 64px; height: 64px; border-radius: 16px; background: var(--panel-2);
  display: grid; place-items: center; font-weight: 800; color: var(--brand-soft); font-size: 20px; }
.stock-head h1 { margin: 0; font-size: 26px; }
.stock-head .sub { color: var(--txt-mute); margin-top: 4px; }
.stock-head .price { margin-inline-start: auto; text-align: end; }
.stock-head .price .big { font-size: 38px; font-weight: 800; font-variant-numeric: tabular-nums; }
.kpis { display: grid; grid-template-columns: repeat(5, 1fr); gap: 12px; margin-bottom: 20px; }
@media (max-width: 980px){ .kpis { grid-template-columns: repeat(3, 1fr); } }
@media (max-width: 560px){ .kpis { grid-template-columns: repeat(2, 1fr); } }
.kpi { background: linear-gradient(180deg, var(--panel), var(--bg-2)); border: 1px solid var(--line);
  border-radius: var(--radius-sm); padding: 15px 16px; transition: .18s;
  display: flex; flex-direction: column; justify-content: center; text-align: center; min-height: 78px; }
.kpi:hover { border-color: #35466c; transform: translateY(-2px); box-shadow: 0 10px 24px rgba(0,0,0,.3); }
.kpi .k { color: var(--txt-mute); font-size: 12px; font-weight: 600; }
.kpi .v { font-size: 20px; font-weight: 800; margin-top: 7px; font-variant-numeric: tabular-nums; }
.cols { display: grid; grid-template-columns: 2fr 1fr; gap: 18px; }
@media (max-width: 950px) { .cols { grid-template-columns: 1fr; } .stock-head .price { margin-inline-start: 0; text-align: start; } }
.deflist { display: grid; grid-template-columns: 1fr 1fr; gap: 1px; background: var(--line-soft); }
.deflist .row { display: flex; justify-content: space-between; gap: 12px; padding: 11px 16px; background: var(--panel); }
.deflist .row .k { color: var(--txt-dim); }
.deflist .row .v { font-weight: 700; font-variant-numeric: tabular-nums; }
canvas { max-width: 100%; }

/* ---- sector cards (dashboard) ---- */
.sector-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr));
  gap: 14px; align-items: start; }
.sector-card { background: linear-gradient(180deg, var(--panel), var(--bg-2));
  border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; transition: .18s; }
.sector-card:hover { border-color: var(--brand); }
.sector-card.open { grid-column: 1 / -1; }
.sector-head { display: flex; justify-content: space-between; align-items: center;
  gap: 10px; min-height: 68px; padding: 14px 18px; cursor: pointer; user-select: none; }
.sector-head:hover { background: rgba(255, 255, 255, .02); }
.sector-title { display: flex; align-items: center; gap: 12px; flex: 1; min-width: 0; }
.sector-title > div { min-width: 0; }
.sector-title b { display: block; font-size: 15px; white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis; }
.sector-title small { display: block; color: var(--txt-mute); font-size: 12px; margin-top: 3px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sector-ico { font-size: 20px; opacity: .85; flex-shrink: 0; }
.sector-badges { display: flex; align-items: center; gap: 7px; flex-shrink: 0; }
.sector-badges .pill { font-size: 12px; padding: 3px 9px; }
.sector-badges .chev { color: var(--txt-mute); transition: transform .2s; font-size: 12px; }
.sector-card.open .sector-badges .chev { transform: rotate(180deg); }
.sector-body { display: none; border-top: 1px solid var(--line); padding: 12px 12px 4px; }
.sector-card.open .sector-body { display: block; }
.sector-search input { width: 280px; max-width: 100%; padding: 9px 14px;
  background: var(--bg-2); border: 1px solid var(--line); border-radius: 10px;
  color: var(--txt); font-family: var(--font); margin-bottom: 10px; }
.sector-search input:focus { outline: none; border-color: var(--brand); }
@media (max-width: 620px) { .sector-grid { grid-template-columns: 1fr; } }

/* ---- chart timeframe toggle ---- */
.tf-btn { padding: 4px 12px; border-radius: 8px; border: 1px solid var(--line);
  background: transparent; color: var(--txt-mute); font-family: var(--font);
  font-size: 12px; font-weight: 700; cursor: pointer; transition: .15s; }
.tf-btn:hover { color: var(--txt); border-color: var(--brand); }
.tf-btn.on { background: var(--brand); color: #2a1d02; border-color: transparent; }

/* ---- reports ---- */
.report-body { line-height: 1.95; font-size: 15px; color: var(--txt-dim); }
.report-body h1, .report-body h2 { color: var(--brand-soft); font-size: 19px; margin: 24px 0 12px; }
.report-body h3 { color: var(--brand-soft); font-size: 17px; font-weight: 800; margin: 26px 0 12px;
  padding-bottom: 9px; border-bottom: 1px solid var(--line-soft); }
.report-body h3:first-child, .report-body h1:first-child, .report-body h2:first-child { margin-top: 0; }
.report-body h4 { color: var(--txt); font-size: 15px; margin: 18px 0 8px; }
.report-body p { margin: 11px 0; }
.report-body strong { color: var(--txt); font-weight: 800; }
.report-body ul { list-style: none; padding: 0; margin: 12px 0; }
.report-body li { position: relative; padding-inline-start: 22px; margin: 9px 0; }
.report-body li::before { content: "▸"; position: absolute; inset-inline-start: 0;
  color: var(--brand); font-weight: 800; }

/* ===== loading overlay (slow AI report generation) ===== */
.loading-overlay { position: fixed; inset: 0; z-index: 200; display: none;
  align-items: center; justify-content: center; background: rgba(7, 11, 22, .78);
  backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); }
.loading-overlay.show { display: flex; }
.loading-box { display: flex; flex-direction: column; align-items: center; gap: 18px;
  padding: 34px 40px; border-radius: 18px; background: var(--panel); border: 1px solid var(--line);
  box-shadow: var(--shadow); color: var(--txt); font-weight: 700; max-width: 360px; text-align: center; }
.spinner { width: 46px; height: 46px; border-radius: 50%; border: 4px solid var(--line);
  border-top-color: var(--brand); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.advice-box { margin-top: 18px; padding: 16px 18px; border-radius: var(--radius-sm);
  background: var(--up-bg); border: 1px solid rgba(31,191,117,.3); }
.advice-box.neg { background: var(--dn-bg); border-color: rgba(240,85,107,.3); }
.report-list a { display: flex; gap: 14px; align-items: center; padding: 16px 18px;
  border-bottom: 1px solid var(--line-soft); transition: .12s; }
.report-list a:hover { background: var(--panel-2); }
.report-list .date { font-weight: 800; color: var(--brand-soft); min-width: 110px; }

.empty { text-align: center; color: var(--txt-mute); padding: 60px 20px; }
.crumb { color: var(--txt-mute); margin-bottom: 14px; }
.crumb a:hover { color: var(--brand-soft); }
.back-btn { display: inline-block; padding: 9px 18px; }
.report-notready { margin-top: 12px; padding: 11px 15px; border-radius: 10px; font-size: 13px;
  color: var(--brand-soft); background: rgba(231,184,78,.10); border: 1px solid rgba(231,184,78,.3); max-width: 560px; }
.hist-form { display: flex; gap: 16px; align-items: flex-end; flex-wrap: wrap; padding: 18px; }
.hist-form label { display: flex; flex-direction: column; gap: 6px; font-size: 12px; color: var(--txt-mute); }
.hist-form select, .hist-form input { padding: 10px 12px; border-radius: 10px;
  background: var(--panel-2, #0e1730); color: var(--txt); border: 1px solid var(--line);
  font-family: var(--font); font-size: 13px; min-width: 220px; }
.hist-form input:focus, .hist-form select:focus { outline: none; border-color: var(--brand); }
.hist-form input[type="date"] { color-scheme: dark; min-width: 170px; }
.hist-panel { overflow: visible; }   /* let the autocomplete dropdown show */
.hist-search { position: relative; }
.hist-search > input { min-width: 300px; }
.hist-search .search-results { top: calc(100% + 6px); inset-inline-start: 0; width: 100%; min-width: 300px; }

/* ===== news ===== */
.news-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 1px;
  background: var(--line-soft); }
.news-item { display: block; padding: 14px 16px; background: var(--panel);
  transition: .14s; border-inline-start: 3px solid transparent; }
.news-item:hover { background: var(--panel-2); border-inline-start-color: var(--brand); }
.news-meta { display: flex; align-items: center; gap: 10px; margin-bottom: 6px; }
.news-src { font-weight: 800; color: var(--brand-soft); font-size: 12px; }
.news-time { color: var(--txt-mute); font-size: 11px; margin-inline-start: auto; }
.news-txt { font-size: 13.5px; line-height: 1.7; color: var(--txt-dim);
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.news-tag { padding: 2px 9px; border-radius: 999px; font-weight: 800; font-size: 11px;
  font-variant-numeric: tabular-nums; white-space: nowrap; }
.news-tag.up { color: var(--up); background: var(--up-bg); }
.news-tag.dn { color: var(--dn); background: var(--dn-bg); }
.news-tag.flat { color: var(--flat); background: rgba(129,144,181,.12); }
.news-item.up-news { border-inline-start-color: rgba(37,209,134,.45); }
.news-item.dn-news { border-inline-start-color: rgba(255,93,116,.45); }

/* ===== chatbot ===== */
#chatFab { position: fixed; bottom: 22px; inset-inline-end: 22px; z-index: 60;
  width: 58px; height: 58px; border-radius: 50%; border: none; cursor: pointer;
  background: linear-gradient(135deg, var(--brand-soft), var(--brand)); color: #2a1d02; font-size: 24px;
  box-shadow: 0 10px 28px rgba(231, 184, 78, .4); transition: .18s; }
#chatFab:hover { transform: translateY(-2px) scale(1.05); box-shadow: 0 14px 34px rgba(231, 184, 78, .5); }
.chat-panel { position: fixed; bottom: 90px; inset-inline-end: 22px; z-index: 60;
  width: 360px; max-width: calc(100vw - 32px); height: 520px; max-height: calc(100vh - 130px);
  display: none; flex-direction: column; background: var(--panel, #0d1530);
  border: 1px solid var(--line); border-radius: 16px; overflow: hidden; box-shadow: 0 16px 48px rgba(0,0,0,.5); }
.chat-panel.open { display: flex; }
.chat-head { display: flex; align-items: center; justify-content: space-between;
  padding: 14px 16px; background: var(--panel-2, #0e1730); border-bottom: 1px solid var(--line); font-weight: 800; }
.chat-x { background: none; border: none; color: var(--txt-dim); cursor: pointer; font-size: 16px; }
.chat-body { flex: 1; overflow-y: auto; padding: 14px; display: flex; flex-direction: column; gap: 10px; }
.chat-msg { padding: 10px 13px; border-radius: 12px; max-width: 85%; line-height: 1.6;
  font-size: 14px; white-space: pre-wrap; word-wrap: break-word; }
.chat-msg.user { align-self: flex-end; background: var(--brand); color: #1a1405; border-bottom-right-radius: 4px; }
.chat-msg.bot { align-self: flex-start; background: var(--panel-2, #16203c); color: var(--txt); border-bottom-left-radius: 4px; }
.chat-input { display: flex; gap: 8px; padding: 12px; border-top: 1px solid var(--line); }
.chat-input input { flex: 1; padding: 11px 13px; border-radius: 10px; background: var(--panel-2, #0e1730);
  color: var(--txt); border: 1px solid var(--line); font-family: var(--font); font-size: 14px; }
.badge-src { font-size: 11px; padding: 2px 9px; border-radius: 999px; background: var(--panel-2); color: var(--txt-mute); }
.badge-src.sample { color: var(--brand-soft); }
