/* public/app.css — Bourse Offers (dark by default, light theme with data-theme="light") */
:root, :root[data-theme="dark"] {
  --bg: #07101d; --bg-2: #0b1727; --card: #0f1d31; --card-2: #13243c; --line: rgba(120, 160, 210, .16);
  --text: #eef2f8; --muted: #93a3bb; --accent: #2ec4b6; --accent-2: #7fe3d8; --gold: #e8b923;
  --up: #2fbf71; --down: #ef5b5b; --warn: #f0a93b; --shadow: 0 10px 30px rgba(0, 0, 0, .35);
  --ui: 'Vazirmatn', 'Segoe UI', Tahoma, Arial, sans-serif;
}
:root[data-theme="light"] {
  --bg: #f3f6fa; --bg-2: #e8eef6; --card: #ffffff; --card-2: #f5f8fc; --line: rgba(20, 50, 90, .12);
  --text: #13233a; --muted: #5d6d84; --accent: #0f8f84; --accent-2: #0b6f66; --gold: #a97c00;
  --up: #16884d; --down: #c93636; --warn: #b26a00; --shadow: 0 8px 24px rgba(20, 40, 80, .08);
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); font-family: var(--ui); font-size: 15px; line-height: 1.7; }
a { color: var(--accent); }
button { font-family: inherit; }
.ltr { direction: ltr; unicode-bidi: plaintext; }
.muted { color: var(--muted); }
.up { color: var(--up); }
.down { color: var(--down); }
.hidden, [hidden] { display: none !important; } /* a class with its own display (e.g. .badge) must not override the hidden attribute */

/* ---------- login ---------- */
.login-page { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px;
  background: radial-gradient(ellipse at 30% 10%, rgba(46, 196, 182, .14), transparent 55%), radial-gradient(ellipse at 80% 90%, rgba(232, 185, 35, .10), transparent 50%), var(--bg); }
.login-panel { width: 100%; max-width: 380px; }
.lang-switch { display: flex; margin: 0 auto 16px; width: fit-content; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; direction: ltr; background: var(--card); }
.lang-btn { background: transparent; border: 0; color: var(--muted); padding: 8px 24px; cursor: pointer; font-size: 14px; }
.lang-btn.active { background: var(--accent); color: #04211e; font-weight: 800; }
.login-card { background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 28px 24px; box-shadow: var(--shadow); }
.brand { text-align: center; font-weight: 800; font-size: 22px; direction: ltr; }
.brand span { color: var(--accent); }
.brand-sub { text-align: center; font-size: 12px; color: var(--muted); margin-bottom: 14px; }
.login-card h1 { font-size: 22px; text-align: center; margin: 4px 0; }
.login-card .sub { text-align: center; color: var(--muted); font-size: 13px; margin-bottom: 18px; }
.field { position: relative; margin-bottom: 12px; }
.field input { width: 100%; padding: 13px 14px; border-radius: 10px; border: 1px solid var(--line); background: var(--bg-2); color: var(--text); font-size: 15px; font-family: inherit; outline: none; direction: ltr; }
.field input:focus { border-color: var(--accent); }
.toggle-pass { position: absolute; top: 50%; transform: translateY(-50%); right: 8px; background: none; border: 0; color: var(--muted); cursor: pointer; padding: 6px; }
.primary-btn { width: 100%; padding: 13px; border: 0; border-radius: 10px; background: var(--accent); color: #04211e; font-weight: 800; font-size: 16px; cursor: pointer; margin-top: 6px; }
.primary-btn:disabled { opacity: .6; cursor: default; }
#msg { color: var(--down); font-size: 13px; text-align: center; min-height: 20px; margin-top: 12px; }
.home-link { display: block; width: fit-content; margin: 14px auto 0; font-size: 13px; text-decoration: none; }

/* ---------- header ---------- */
.hdr { position: sticky; top: 0; z-index: 20; background: color-mix(in srgb, var(--bg) 92%, transparent); backdrop-filter: blur(8px); border-bottom: 1px solid var(--line); }
.hdr-in { max-width: 1200px; margin: 0 auto; padding: 10px 16px; display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.hdr-brand { font-weight: 800; font-size: 19px; direction: ltr; white-space: nowrap; }
.hdr-brand span { color: var(--accent); }
.hdr-ver { font-size: 11px; color: var(--muted); border: 1px solid var(--line); border-radius: 6px; padding: 0 6px; margin-inline-start: 6px; direction: ltr; }
.hdr-by { font-size: 12px; color: var(--muted); }
.hdr-mid { display: flex; gap: 8px 14px; align-items: center; flex-wrap: wrap; font-size: 13px; color: var(--muted); flex: 1; }
.hdr-item { white-space: nowrap; }
.user-chip { display: inline-flex; align-items: center; padding: 3px 11px; border-radius: 999px; border: 1px solid var(--line); background: var(--card); font-size: 13px; font-weight: 700; white-space: nowrap; }
.menu-who { padding: 6px 12px 8px; margin-bottom: 4px; border-bottom: 1px solid var(--line); font-size: 13px; font-weight: 700; color: var(--muted); }
.badge { display: inline-flex; align-items: center; gap: 6px; padding: 2px 10px; border-radius: 999px; border: 1px solid var(--line); font-size: 12px; white-space: nowrap; }
.badge .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); }
.badge.open .dot { background: var(--up); }
.badge.closed .dot { background: var(--down); }
.badge.stale { color: var(--warn); border-color: var(--warn); }
.hdr-user { display: flex; align-items: center; gap: 8px; position: relative; }
.icon-btn { background: var(--card); border: 1px solid var(--line); color: var(--text); border-radius: 10px; padding: 6px 12px; cursor: pointer; font-size: 14px; }
.menu { position: absolute; top: 110%; inset-inline-end: 0; background: var(--card); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow); min-width: 250px; padding: 6px; z-index: 30; }
.menu button, .menu a { display: block; width: 100%; text-align: start; background: none; border: 0; color: var(--text); padding: 9px 12px; border-radius: 8px; cursor: pointer; font-size: 14px; text-decoration: none; }
.menu button:hover, .menu a:hover { background: var(--card-2); }

/* ---------- layout ---------- */
main { max-width: 1200px; margin: 0 auto; padding: 14px 16px 30px; }
.mkt { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 10px; margin-bottom: 14px; }
.mkt-card { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 12px 14px; }
.mkt-card .lbl { color: var(--muted); font-size: 13px; }
.mkt-card .val { font-size: 22px; font-weight: 800; direction: ltr; text-align: start; }
.mkt-card .row { display: flex; gap: 12px; font-size: 13px; flex-wrap: wrap; }
/* BO-V9: tabs are clear buttons (as in Swing Trading) and the bar sticks under the header while scrolling */
/* one line always: on narrow screens the bar slides sideways (the active tab is scrolled into view) */
.tabs { position: sticky; top: var(--hdr-h, 0px); z-index: 15; display: flex; flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; gap: 6px; background: var(--bg); padding: 8px 0; margin: 0 0 14px; border-bottom: 1px solid var(--line); }
.tabs::-webkit-scrollbar { display: none; }
.tab { flex: 1 0 auto; display: inline-flex; align-items: center; justify-content: center; gap: 6px; background: var(--card); border: 1px solid var(--line); color: var(--muted); padding: 9px 12px; border-radius: 11px; cursor: pointer; font-size: 14.5px; font-weight: 800; white-space: nowrap; transition: background .15s, color .15s, border-color .15s; }
.tab:hover { color: var(--text); border-color: color-mix(in srgb, var(--accent) 55%, var(--line)); }
.tab.is-active { background: var(--accent); border-color: var(--accent); color: #04211e; box-shadow: 0 4px 14px color-mix(in srgb, var(--accent) 30%, transparent); }
.tab:focus-visible { outline: 2px solid var(--accent-2); outline-offset: 2px; }
.tab-ic { font-size: 15px; line-height: 1; }
.tab.is-active .tab-badge { background: #04211e; color: #fff; }
/* medium screens (tablet, small laptop window): tighter tabs and no icons, so all 8 still fit on one line */
@media (max-width: 1180px) { .tab { padding: 8px 10px; font-size: 14px; } }
@media (min-width: 641px) and (max-width: 1080px) { .tab-ic { display: none; } .tab { padding: 8px 8px; font-size: 13.5px; } .tabs { gap: 5px; } }
.panel { display: none; }
.panel.is-active { display: block; }
.panel h2 { font-size: 19px; margin: 4px 0 4px; }
.intro { color: var(--muted); font-size: 14px; margin: 0 0 12px; }
.empty { background: var(--card); border: 1px dashed var(--line); border-radius: 14px; padding: 26px; text-align: center; color: var(--muted); }

/* ---------- fund cards ---------- */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); gap: 12px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 14px; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 10px; transition: border-color .2s, transform .2s; }
.card:hover { border-color: color-mix(in srgb, var(--accent) 45%, var(--line)); transform: translateY(-2px); }
@media (prefers-reduced-motion: reduce) { .card, .card:hover { transition: none; transform: none; } }
.card-top { display: flex; align-items: flex-start; gap: 10px; }
.rank { width: 30px; height: 30px; border-radius: 50%; background: var(--card-2); border: 1px solid var(--line); display: flex; align-items: center; justify-content: center; font-weight: 800; flex: none; }
.sym { font-size: 21px; font-weight: 800; line-height: 1.3; }
.fname { font-size: 12px; color: var(--muted); }
.tags { margin-inline-start: auto; display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.tag { font-size: 12px; padding: 1px 9px; border-radius: 999px; border: 1px solid var(--line); white-space: nowrap; }
.tag.fixed { color: #6fb3ff; border-color: rgba(111, 179, 255, .4); }
.tag.equity { color: var(--up); border-color: rgba(47, 191, 113, .4); }
.tag.gold { color: var(--gold); border-color: rgba(232, 185, 35, .45); }
.tag.lower { color: var(--warn); border-color: var(--warn); }
.kv { display: grid; grid-template-columns: 1fr 1fr; gap: 4px 12px; font-size: 13px; }
.kv div { display: flex; justify-content: space-between; gap: 8px; }
.kv span:first-child { color: var(--muted); }
.rets { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; text-align: center; }
.rets div { background: var(--card-2); border-radius: 10px; padding: 4px 2px; font-size: 13px; }
.rets b { display: block; font-size: 14px; direction: ltr; }
.src { font-size: 11px; color: var(--muted); }
.chart { height: 150px; width: 100%; }
.why { font-size: 13px; margin: 0; padding-inline-start: 18px; }
.why li { margin-bottom: 2px; }
details.more summary { cursor: pointer; color: var(--accent); font-size: 13px; }
.rejected { margin-top: 14px; font-size: 13px; color: var(--muted); }
.rejected ul { margin: 4px 0; padding-inline-start: 18px; }

/* ---------- industry map ---------- */
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; margin-bottom: 12px; }
.seg button { background: none; border: 0; color: var(--muted); padding: 6px 12px; cursor: pointer; }
.seg button.is-active { background: var(--accent); color: #04211e; font-weight: 700; }
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 8px; }
.tile { border-radius: 12px; padding: 10px; border: 1px solid var(--line); min-height: 92px; }
.tile .n { font-weight: 700; font-size: 14px; line-height: 1.5; }
.tile .r { font-size: 18px; font-weight: 800; direction: ltr; text-align: start; }
.tile .s { font-size: 12px; color: var(--muted); }

/* ---------- tables ---------- */
.tbl-wrap { overflow-x: auto; background: var(--card); border: 1px solid var(--line); border-radius: 14px; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { padding: 9px 12px; text-align: start; border-bottom: 1px solid var(--line); white-space: nowrap; }
th { color: var(--muted); font-weight: 600; font-size: 13px; }
tr:last-child td { border-bottom: 0; }
.num { direction: ltr; text-align: end; }
.add-row { display: flex; gap: 8px; margin-bottom: 12px; flex-wrap: wrap; }
.add-row input { flex: 1; min-width: 180px; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--line); background: var(--card); color: var(--text); font-family: inherit; font-size: 15px; }
.small-btn { background: var(--accent); color: #04211e; border: 0; border-radius: 10px; padding: 8px 16px; font-weight: 700; cursor: pointer; }
.link-btn { background: none; border: 0; color: var(--down); cursor: pointer; font-size: 13px; }
.note { font-size: 13px; color: var(--warn); min-height: 18px; }

/* ---------- help + footer ---------- */
.help { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 16px 18px; }
.help h3 { font-size: 16px; margin: 14px 0 4px; }
.help h3:first-child { margin-top: 0; }
.help p, .help li { font-size: 14px; }
.help .ex { background: var(--card-2); border-radius: 10px; padding: 8px 12px; }
footer { max-width: 1200px; margin: 0 auto; padding: 16px; font-size: 12px; color: var(--muted); border-top: 1px solid var(--line); text-align: center; }
.foot-brand { font-size: 13px; color: var(--text); margin-bottom: 4px; }
.foot-brand b { color: var(--accent); }

.ask-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; background: var(--card); border: 1px solid var(--accent); border-radius: 12px; padding: 8px 12px; margin-bottom: 12px; font-size: 14px; }
.ask-actions { display: inline-flex; gap: 6px; flex-wrap: wrap; }
.mkt-card .live-tag { font-size: 11px; }
.badge.help { color: var(--accent); border-color: var(--accent); }
.live-tag { font-size: 10px; color: var(--accent); margin-inline-start: 4px; }

/* ---------- stock picks and chart window ---------- */
.tag.untested { color: var(--warn); border-color: var(--warn); }
.tag.experimental { color: var(--accent); border-color: var(--accent); }
.sym-link { cursor: pointer; text-decoration: none; transition: color .15s; }
.sym-link:hover { color: var(--accent); }
/* BO-V9: copy button next to symbols and prices (hover on a computer, always faint on a touch screen) */
.sym-wrap { display: inline-flex; align-items: center; gap: 4px; }
.copy-btn { display: inline-flex; align-items: center; justify-content: center; width: 22px; height: 22px; padding: 0; border: 1px solid transparent; border-radius: 6px; background: none; color: var(--muted); cursor: pointer; opacity: 0; transition: opacity .15s, color .15s, background .15s; flex: none; }
.sym-wrap:hover .copy-btn, .copy-btn:focus-visible { opacity: .9; }
.copy-btn:hover { color: var(--accent); background: var(--card-2); border-color: var(--line); }
@media (hover: none) { .copy-btn { opacity: .45; } }
.toast { position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%); z-index: 60; background: var(--text); color: var(--bg); padding: 8px 16px; border-radius: 999px; font-size: 14px; font-weight: 700; box-shadow: var(--shadow); max-width: calc(100% - 32px); text-align: center; }
/* BO-V9: labels on the cards open a help window */
.tag-btn { background: none; font-family: inherit; cursor: pointer; display: inline-flex; align-items: center; gap: 4px; transition: background .15s; }
.tag-btn:hover { background: var(--card-2); }
.tag-q { display: inline-flex; align-items: center; justify-content: center; width: 15px; height: 15px; border-radius: 50%; border: 1px solid currentColor; font-size: 10px; font-weight: 800; line-height: 1; }
.modal-card.info-card { width: min(640px, 100%); max-height: 88vh; overflow-y: auto; }
.info-body p { margin: 0 0 10px; font-size: 14.5px; }
.info-body ul { margin: 0 0 10px; padding-inline-start: 20px; font-size: 14.5px; }
.info-body li { margin-bottom: 4px; }
.info-body p:last-child { color: var(--warn); font-weight: 700; margin-bottom: 0; }
.modal { position: fixed; inset: 0; z-index: 50; background: rgba(0, 0, 0, .55); display: flex; align-items: center; justify-content: center; padding: 12px; }
.modal[hidden] { display: none; }
.modal-card { background: var(--card); border: 1px solid var(--line); border-radius: 16px; width: min(980px, 100%); padding: 12px 14px; box-shadow: var(--shadow); }
.modal-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; font-size: 17px; }
.chart-big { height: min(60vh, 500px); width: 100%; }
.sc-bar { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 6px; direction: ltr; }
.sc-group { display: inline-flex; flex-wrap: wrap; gap: 4px; }
.sc-btn { background: var(--card-2); border: 1px solid var(--line); color: var(--muted); border-radius: 8px; padding: 3px 9px; font-size: 12px; cursor: pointer; font-family: inherit; }
.sc-btn.on { background: var(--accent); color: #04211e; border-color: var(--accent); font-weight: 700; }
.sc-legend { font-size: 12px; min-height: 34px; line-height: 1.5; }
.sc-legend span { margin-inline-end: 6px; }
.sc-sym { font-weight: 700; }
.sc-hint { color: var(--warn); }
.sc-ruler-on { cursor: crosshair; }

/* ---------- alerts ---------- */
.tab-badge { display: inline-block; min-width: 18px; padding: 0 5px; margin-inline-start: 6px; border-radius: 999px; background: var(--down); color: #fff; font-size: 11px; line-height: 18px; text-align: center; }
.al-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 12px; }
.al-box { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 14px 16px; }
.al-box h3, .al-log-title { font-size: 16px; margin: 0 0 8px; }
.al-log-title { margin-top: 16px; }
.al-actions { display: flex; gap: 8px; flex-wrap: wrap; margin: 8px 0; }
.al-row { display: flex; margin: 6px 0; flex-wrap: wrap; }
.al-row input[type="checkbox"] { width: 18px; height: 18px; }
.al-pct { width: 70px; padding: 4px 8px; border-radius: 8px; border: 1px solid var(--line); background: var(--bg-2); color: var(--text); font-family: inherit; direction: ltr; }
.al-item { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 10px 14px; margin-bottom: 8px; }
.al-item.new { border-color: var(--accent); }
.al-item .t { font-weight: 700; }
.al-item .b { font-size: 14px; }

/* ---------- fundamentals table ---------- */
.ft-select { padding: 10px 12px; border-radius: 10px; border: 1px solid var(--line); background: var(--card); color: var(--text); font-family: inherit; font-size: 14px; }
.ft-check { display: inline-flex; align-items: center; gap: 6px; font-size: 14px; cursor: pointer; }
.add-row .ft-check input { flex: none; min-width: 0; width: 18px; height: 18px; padding: 0; }
th.sortable { cursor: pointer; user-select: none; }
th.sortable:hover { color: var(--text); }
th.sorted::after { content: ' ▾'; }
th.sorted.asc::after { content: ' ▴'; }
.ft-name { display: block; font-size: 11px; color: var(--muted); max-width: 180px; overflow: hidden; text-overflow: ellipsis; }
.mini { font-size: 11px; padding: 0 6px; border-radius: 999px; border: 1px solid var(--line); color: var(--muted); margin-inline-start: 4px; }
.mini.warn { color: var(--warn); border-color: var(--warn); }
.mini.bad { color: var(--down); border-color: var(--down); }
#ftBox .tbl-wrap { max-height: 70vh; overflow: auto; }
#ftBox thead th { position: sticky; top: 0; background: var(--card); z-index: 1; }

html[lang="fa"] [data-lang="en"], html[lang="en"] [data-lang="fa"] { display: none !important; }

@media (max-width: 640px) {
  .cards { grid-template-columns: 1fr; }
  .hdr { position: static; } /* on a phone the header scrolls away instead of covering a third of the screen */
  .hdr-mid { order: 3; flex-basis: 100%; }
  /* phone: one line of tabs that slides sideways (the active tab is scrolled into view) */
  .tabs { margin-inline: -16px; padding-inline: 16px; }
  .tab { flex: none; padding: 8px 11px; font-size: 14px; }
  .mkt-card .val { font-size: 19px; }
  .ft-sec { display: none; } /* phone: the industry column gives way to the numbers (the industry filter stays) */
  .ft-name { max-width: 110px; }
  .hide-sm { display: none; } /* phone: track tables keep symbol, dates and the three returns */
  .kv { grid-template-columns: 1fr; }
}

/* BO-V8: admin tools of the history tables */
.track-tools { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin: 8px 0 14px; }
.track-tools .small { font-size: 12px; }
th.chk, td.chk { width: 28px; text-align: center; }
td.chk input, th.chk input { width: 16px; height: 16px; cursor: pointer; vertical-align: middle; }

/* BO-V11: market-open mode */
.badge.live { color: var(--accent); border-color: var(--accent); }
.badge.live::before { content: ''; width: 7px; height: 7px; border-radius: 50%; background: var(--accent); animation: bo-pulse 2s infinite; }
@keyframes bo-pulse { 50% { opacity: .3; } }
@media (prefers-reduced-motion: reduce) { .badge.live::before { animation: none; } }
.tag.qbuy { color: var(--up); border-color: var(--up); font-weight: 700; }
.tag.qsell { color: var(--down); border-color: var(--down); font-weight: 700; }
.kv .live-tag { margin-inline-start: 2px; }
