/* Одна таблица стилей на весь сервис. Цвета — CSS-переменные, тёмная тема
   переопределяет их же: биржевой зелёный/красный обязаны читаться в обеих. */
:root {
  --bg-1: #f6f8fb;
  --bg-2: #eef2f8;
  --card: #ffffff;
  --text: #16202e;
  --muted: #6a7688;
  --border: #dfe5ee;
  --accent: #1f5fbf;
  --accent-soft: #e8f0fd;
  --up: #12874b;
  --up-soft: #e6f5ec;
  --down: #c92c3c;
  --down-soft: #fdeaec;
  --hold: #8a6d1f;
  --hold-soft: #fbf3dd;
  --grid: #e7ecf3;
  --error-bg: #fdeaec;
  --error-border: #f3c2c8;
  --error-text: #8e1c28;
  --notice-bg: #eef6ff;
  --notice-border: #c9dffb;
  --shadow: 0 1px 2px rgba(16, 32, 56, .06), 0 8px 24px rgba(16, 32, 56, .06);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg-1: #0e131b;
    --bg-2: #131a24;
    --card: #172029;
    --text: #e7edf5;
    --muted: #93a1b4;
    --border: #263241;
    --accent: #6aa8ff;
    --accent-soft: #1b2b41;
    --up: #3ecf8e;
    --up-soft: #14301f;
    --down: #ff6b7a;
    --down-soft: #34161b;
    --hold: #e0be6a;
    --hold-soft: #2e2716;
    --grid: #222c39;
    --error-bg: #34161b;
    --error-border: #5d2730;
    --error-text: #ffb3bc;
    --notice-bg: #17273a;
    --notice-border: #27405e;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 10px 28px rgba(0, 0, 0, .35);
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  margin: 0;
  color: var(--text);
  background: linear-gradient(180deg, var(--bg-1), var(--bg-2));
  background-attachment: fixed;
  font: 15px/1.55 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
        "Helvetica Neue", Arial, sans-serif;
  -webkit-text-size-adjust: 100%;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.45rem; margin: 0 0 .6rem; }
h2 { font-size: 1.05rem; margin: 1.2rem 0 .5rem; }
p { margin: .5rem 0; }

/* --- Шапка --- */
.top {
  display: flex; align-items: center; gap: 1rem; flex-wrap: wrap;
  max-width: 1080px; margin: 0 auto; padding: .9rem 1.1rem;
}
.brand { display: flex; align-items: center; gap: .5rem; font-weight: 700;
         color: var(--text); text-decoration: none; }
.brand:hover { text-decoration: none; }
.brand-mark {
  display: grid; place-items: center; width: 30px; height: 30px; border-radius: 9px;
  background: var(--accent); color: #fff; font-weight: 700;
}
.topsearch { flex: 1 1 200px; }
.topsearch input {
  width: 100%; padding: .5rem .8rem; border-radius: 9px;
  border: 1px solid var(--border); background: var(--card); color: var(--text);
}
.top-right { display: flex; align-items: center; gap: .9rem; flex-wrap: wrap; }
.nav-link, .logout { color: var(--muted); }
.balance {
  padding: .35rem .7rem; border-radius: 999px;
  background: var(--accent-soft); color: var(--accent); font-weight: 600;
}
.balance:hover { text-decoration: none; }

.page { max-width: 1080px; margin: 0 auto; padding: .5rem 1.1rem 2rem; }

/* --- Карточки --- */
.card {
  background: var(--card); border: 1px solid var(--border); border-radius: 14px;
  padding: 1rem 1.1rem; margin: 0 0 1rem; box-shadow: var(--shadow);
}
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.center { text-align: center; }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.secid { color: var(--muted); font-weight: 400; font-size: .85em; margin-left: .35rem; }

.error, .notice {
  padding: .6rem .8rem; border-radius: 10px; margin: .6rem 0;
}
.error { background: var(--error-bg); border: 1px solid var(--error-border); color: var(--error-text); }
.notice { background: var(--notice-bg); border: 1px solid var(--notice-border); }

.chg.up, .up { color: var(--up); }
.chg.down, .down { color: var(--down); }

button, .primary {
  font: inherit; cursor: pointer; border-radius: 10px; padding: .55rem 1rem;
  border: 1px solid var(--border); background: var(--card); color: var(--text);
}
button:hover { border-color: var(--accent); }
button.primary, .auth-submit {
  background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600;
}
button[disabled] { opacity: .6; cursor: default; }
input[type=text], input[type=email], input[type=password], input[type=search] {
  font: inherit; padding: .5rem .7rem; border-radius: 10px;
  border: 1px solid var(--border); background: var(--card); color: var(--text);
}

/* --- Вход --- */
.auth-page { display: grid; place-items: center; min-height: 60vh; }
.auth-card { width: min(380px, 100%); text-align: center; background: var(--card);
             border: 1px solid var(--border); border-radius: 16px; padding: 1.6rem;
             box-shadow: var(--shadow); }
.auth-brand { font-size: 1.3rem; margin-bottom: .3rem; }
.auth-hint { color: var(--muted); margin-bottom: 1rem; }
.auth-input { width: 100%; margin-bottom: .6rem; text-align: center; }
.auth-code { letter-spacing: .5em; font-size: 1.3rem; }
.auth-submit { width: 100%; margin-bottom: .6rem; }
.auth-note { font-size: .82rem; color: var(--muted); margin-top: 1rem; }
.linklike { background: none; border: none; color: var(--accent); padding: .2rem;
            text-decoration: underline; }

/* --- Индекс и лидеры --- */
.index-title { font-size: 1rem; color: var(--muted); font-weight: 600; margin: 0; }
.index-value { font-size: 2rem; font-weight: 700; display: flex; align-items: baseline;
               gap: .6rem; }
.index-value .chg { font-size: 1rem; }
.movers { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.mover-card h2 { margin-top: 0; }
table.mini, table.rows, table.market { width: 100%; border-collapse: collapse; }
table.mini td { padding: .3rem 0; border-bottom: 1px solid var(--border); }
table.mini tr:last-child td { border-bottom: none; }
table.rows td, table.rows th { padding: .45rem .4rem; border-bottom: 1px solid var(--border);
                               text-align: left; }
table.rows.tight td { padding: .3rem .4rem; font-size: .92rem; }
table.rows th { color: var(--muted); font-weight: 500; }

.bigsearch { display: flex; gap: .5rem; margin-top: .6rem; }
.bigsearch input { flex: 1; }

/* --- Таблица рынка --- */
.table-wrap { overflow-x: auto; }
table.market { min-width: 560px; }
table.market th, table.market td { padding: .5rem .5rem; border-bottom: 1px solid var(--border); text-align: left; }
table.market th { color: var(--muted); font-weight: 500; position: sticky; top: 0;
                  background: var(--card); }
table.market th a { color: var(--muted); }
table.market th a.sorted { color: var(--accent); font-weight: 600; }
table.market tbody tr:hover { background: var(--bg-2); }

.filters { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; margin-bottom: .7rem; }
.chip-row { display: flex; gap: .35rem; flex-wrap: wrap; }
.chip {
  padding: .3rem .7rem; border-radius: 999px; border: 1px solid var(--border);
  color: var(--muted); font-size: .9rem;
}
.chip:hover { text-decoration: none; border-color: var(--accent); }
.chip.active { background: var(--accent-soft); color: var(--accent); border-color: transparent;
               font-weight: 600; }

/* --- Карточка бумаги --- */
.quote-head { display: flex; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }
.quote-head h1 { margin: 0; }
.quote-price { text-align: right; }
.quote-price .price { font-size: 1.9rem; font-weight: 700; }
.quote-price .chg { font-size: 1rem; font-weight: 600; }
.quote-facts, .facts, .returns, .targets, .admin-stats {
  display: grid; gap: .6rem; margin-top: .9rem;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
}
.quote-facts div, .facts div, .returns div, .targets div, .admin-stats div {
  background: var(--bg-2); border-radius: 10px; padding: .5rem .65rem;
}
.quote-facts span, .facts span, .returns span, .targets span, .admin-stats span {
  display: block; color: var(--muted); font-size: .8rem;
}
.facts b, .quote-facts b, .returns b, .targets b, .admin-stats b {
  font-size: 1.05rem; font-variant-numeric: tabular-nums;
}
.facts i, .targets i { font-style: normal; font-size: .8rem; margin-left: .35rem; }

/* --- График --- */
.chart-toolbar { display: flex; justify-content: space-between; gap: .5rem;
                 flex-wrap: wrap; margin-bottom: .6rem; }
.chart-box { position: relative; }
.chart { display: block; width: 100%; height: auto; overflow: visible; }
.chart .grid { stroke: var(--grid); stroke-width: 1; }
.chart .axis { fill: var(--muted); font-size: 10px; }
.chart .candle.up .body { fill: var(--up); }
.chart .candle.up .wick { stroke: var(--up); }
.chart .candle.down .body { fill: var(--down); }
.chart .candle.down .wick { stroke: var(--down); }
.chart .wick { stroke-width: 1; }
.chart .vol { opacity: .32; }
.chart .vol.up { fill: var(--up); }
.chart .vol.down { fill: var(--down); }
.chart .sma { fill: none; stroke-width: 1.4; }
.chart .sma20 { stroke: var(--accent); }
.chart .sma50 { stroke: var(--hold); }
.chart .crosshair { stroke: var(--muted); stroke-dasharray: 3 3; }
.line-chart .line { fill: none; stroke-width: 2; }
.line-chart.up .line { stroke: var(--up); }
.line-chart.down .line { stroke: var(--down); }
.line-chart.up .area { fill: var(--up); opacity: .12; }
.line-chart.down .area { fill: var(--down); opacity: .12; }
.chart-empty { color: var(--muted); padding: 2rem 0; text-align: center; }
.chart-tip {
  position: absolute; pointer-events: none; background: var(--card); color: var(--text);
  border: 1px solid var(--border); border-radius: 8px; padding: .4rem .55rem;
  font-size: .8rem; box-shadow: var(--shadow); white-space: nowrap; z-index: 3;
}
.legend { color: var(--muted); font-size: .85rem; }
.legend .key { display: inline-block; width: 14px; height: 2px; margin: 0 .3rem 0 .8rem;
               vertical-align: middle; }
.legend .key.sma20 { background: var(--accent); }
.legend .key.sma50 { background: var(--hold); }
.spark polyline { fill: none; stroke-width: 1.5; }
.spark.up polyline { stroke: var(--up); }
.spark.down polyline { stroke: var(--down); }

/* --- Разбор --- */
.analyze-card .analyze-form { margin: .6rem 0 1rem; }
.verdict { padding: .12rem .5rem; border-radius: 999px; font-size: .85rem; font-weight: 600; }
.verdict.v-buy { background: var(--up-soft); color: var(--up); }
.verdict.v-sell { background: var(--down-soft); color: var(--down); }
.verdict.v-hold { background: var(--hold-soft); color: var(--hold); }

.verdict-box {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  flex-wrap: wrap; border-radius: 12px; padding: .9rem 1.1rem; margin: .8rem 0;
}
.verdict-box.v-buy { background: var(--up-soft); }
.verdict-box.v-sell { background: var(--down-soft); }
.verdict-box.v-hold { background: var(--hold-soft); }
.verdict-main { font-size: 1.6rem; font-weight: 700; }
.verdict-box.v-buy .verdict-main { color: var(--up); }
.verdict-box.v-sell .verdict-main { color: var(--down); }
.verdict-box.v-hold .verdict-main { color: var(--hold); }
.conf-bar { height: 6px; width: 160px; border-radius: 999px; background: rgba(128,128,128,.25);
            margin-top: .25rem; overflow: hidden; }
.conf-bar i { display: block; height: 100%; background: currentColor; }
.summary { font-size: 1.05rem; }
.analysis ul { margin: .4rem 0; padding-left: 1.1rem; }
.analysis ul.pros li::marker { color: var(--up); }
.analysis ul.cons li::marker { color: var(--down); }
.analysis li { margin: .25rem 0; }
.disclaimer.inline {
  font-size: .82rem; color: var(--muted); background: var(--bg-2);
  border-radius: 10px; padding: .5rem .7rem; margin: .6rem 0;
}
.balance-big { font-size: 2.2rem; font-weight: 700; }

/* --- Подбор «какие акции покупать» --- */
.cta { display: flex; align-items: center; justify-content: space-between; gap: 1rem;
       flex-wrap: wrap; border-color: var(--accent); }
.cta h2 { margin-top: 0; }
.cta p { margin-bottom: 0; max-width: 52ch; }
.cta-btn { display: inline-block; white-space: nowrap; text-align: center; }
a.cta-btn:hover { text-decoration: none; }
.picks { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); }
.pick { margin: 0; }
.pick-head { display: flex; justify-content: space-between; align-items: flex-start;
             gap: .8rem; }
.pick-head h2 { margin: 0; font-size: 1.1rem; }
.pick-score { text-align: center; background: var(--accent-soft); border-radius: 10px;
              padding: .35rem .6rem; color: var(--accent); }
.pick-score b { display: block; font-size: 1.3rem; line-height: 1.1; }
.pick-score span { font-size: .7rem; }
.pick-risk { font-size: .9rem; color: var(--muted); }
.pick-risk span { color: var(--down); font-weight: 600; }

/* --- Админка --- */
.admin-form { display: flex; gap: .5rem; flex-wrap: wrap; }
.admin-form input { flex: 1 1 160px; }
.admin-hint { color: var(--muted); font-size: .85rem; }

/* --- Текстовые страницы --- */
.prose { max-width: 720px; }
.prose h2 { margin-top: 1.4rem; }

/* --- Подвал --- */
.foot { max-width: 1080px; margin: 0 auto; padding: 1rem 1.1rem 3rem; color: var(--muted);
        font-size: .82rem; }
.foot .disclaimer { border-top: 1px solid var(--border); padding-top: .9rem; }
.foot-links { margin-top: .4rem; }

@media (max-width: 620px) {
  .quote-price { text-align: left; }
  .index-value { font-size: 1.6rem; }
  .verdict-main { font-size: 1.3rem; }
}
