:root {
  color-scheme: dark;
  --surface-1:      #1a1a19;
  --page-plane:     #0d0d0d;
  --text-primary:   #ffffff;
  --text-secondary: #c3c2b7;
  --text-muted:     #898781;
  --gridline:       #2c2c2a;
  --border:         rgba(255, 255, 255, 0.10);

  --series-1: #3987e5; /* blue   — облигации */
  --series-2: #d95926; /* orange — фонды/ETF */
  --series-3: #199e70; /* aqua   — валюта */
  --series-4: #c98500; /* yellow — фьючерсы */

  --good: #0ca30c;
  --critical: #e66767;
}

* { box-sizing: border-box; }
html, body {
  margin: 0; padding: 0;
  background: var(--page-plane);
  color: var(--text-primary);
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
}
body { padding: 32px 20px; }
.wrap { max-width: 1040px; margin: 0 auto; }
a { color: inherit; }

.topbar { display: flex; align-items: center; justify-content: space-between; margin-bottom: 28px; gap: 16px; }
.wordmark { font-size: 18px; font-weight: 600; letter-spacing: -0.01em; text-decoration: none; }
.wordmark span { color: var(--text-muted); font-weight: 400; }
.topbar-actions { display: flex; align-items: center; gap: 10px; }

.btn {
  background: var(--surface-1); border: 1px solid var(--border);
  color: var(--text-primary); font-size: 13px; padding: 8px 14px;
  border-radius: 8px; cursor: pointer; font-family: inherit;
}
.btn:hover { border-color: var(--text-muted); }
.btn-ghost { background: none; }
.btn-primary { background: var(--series-1); border-color: var(--series-1); color: #fff; font-weight: 600; }

.card {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px 22px;
  margin-bottom: 16px;
}
.card-title {
  font-size: 12px; text-transform: uppercase; letter-spacing: 0.04em;
  color: var(--text-muted); margin: 0 0 14px 0; font-weight: 600;
  display: flex; align-items: center; justify-content: space-between;
}

.kpi-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 16px; }
@media (max-width: 720px) { .kpi-row { grid-template-columns: repeat(2, 1fr); } }
.stat-label { font-size: 12px; color: var(--text-muted); margin-bottom: 6px; }
.stat-value { font-size: 26px; font-weight: 600; letter-spacing: -0.01em; }
.stat-delta { font-size: 13px; margin-top: 4px; font-variant-numeric: tabular-nums; color: var(--text-muted); }
.stat-delta.good { color: var(--good); }
.stat-delta.critical { color: var(--critical); }

.stackbar { display: flex; height: 28px; border-radius: 6px; overflow: hidden; background: var(--gridline); }
.stackbar .seg { height: 100%; margin-right: 2px; }
.stackbar .seg:last-child { margin-right: 0; }
.legend { display: flex; flex-wrap: wrap; gap: 16px; margin-top: 14px; }
.legend-item { display: flex; align-items: center; gap: 7px; font-size: 13px; color: var(--text-secondary); }
.swatch { width: 10px; height: 10px; border-radius: 2px; flex: none; }
.legend-item b { color: var(--text-primary); font-variant-numeric: tabular-nums; }

table { width: 100%; border-collapse: collapse; font-size: 14px; }
th {
  text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: 0.03em;
  color: var(--text-muted); font-weight: 600; padding: 0 10px 10px 10px;
  border-bottom: 1px solid var(--gridline);
}
td { padding: 12px 10px; border-bottom: 1px solid var(--gridline); font-variant-numeric: tabular-nums; }
tr.row { cursor: pointer; transition: background 0.1s; }
tr.row:hover { background: rgba(255, 255, 255, 0.03); }
tr.row:last-child td { border-bottom: none; }
.ticker { font-weight: 600; font-variant-numeric: normal; }
.asset-name { color: var(--text-muted); font-size: 12px; font-variant-numeric: normal; }
.type-pill {
  font-size: 11px; padding: 3px 8px; border-radius: 20px; font-variant-numeric: normal;
  background: rgba(255, 255, 255, 0.06); color: var(--text-secondary);
}
.pnl.good { color: var(--good); }
.pnl.critical { color: var(--critical); }
.empty-state { color: var(--text-muted); font-size: 14px; padding: 8px 4px; }

.detail-header { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 20px; flex-wrap: wrap; gap: 12px; }
.detail-title { font-size: 22px; font-weight: 700; }
.detail-sub { color: var(--text-muted); font-size: 13px; margin-top: 4px; }
.detail-price { text-align: right; }
.detail-price .stat-value { font-size: 30px; }

.detail-grid { display: grid; grid-template-columns: 1.3fr 1fr; gap: 16px; }
@media (max-width: 780px) { .detail-grid { grid-template-columns: 1fr; } }
.fact-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.fact-label { font-size: 12px; color: var(--text-muted); }
.fact-value { font-size: 15px; font-weight: 600; margin-top: 2px; font-variant-numeric: tabular-nums; }

.reco-badge {
  display: inline-block; font-size: 13px; font-weight: 700; letter-spacing: 0.02em;
  padding: 6px 14px; border-radius: 8px; margin-bottom: 14px;
}
.reco-buy { background: rgba(12, 163, 12, 0.15); color: var(--good); }
.reco-sell { background: rgba(230, 103, 103, 0.15); color: var(--critical); }
.reco-hold { background: rgba(255, 255, 255, 0.06); color: var(--text-secondary); }

.ai-badge {
  display: inline-flex; align-items: center; gap: 5px; font-size: 11px;
  color: var(--text-muted); background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border); border-radius: 20px; padding: 3px 9px 3px 7px;
}
.ai-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--series-1); }
.ai-block { margin-top: 16px; }
.ai-block h4 { font-size: 13px; margin: 0 0 6px 0; color: var(--text-primary); }
.ai-block p { font-size: 13.5px; line-height: 1.55; color: var(--text-secondary); margin: 0; }
.ai-meta { font-size: 11px; color: var(--text-muted); margin-top: 14px; }
.ai-empty { color: var(--text-muted); font-size: 13.5px; }

form.inline { display: inline; }

.login-wrap { max-width: 340px; margin: 12vh auto; }
.login-wrap h1 { font-size: 18px; margin-bottom: 20px; }
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 12px; color: var(--text-muted); margin-bottom: 6px; }
input[type=text], input[type=number], input[type=date], input[type=password] {
  width: 100%; background: var(--page-plane); border: 1px solid var(--border);
  color: var(--text-primary); padding: 9px 11px; border-radius: 8px; font-size: 14px;
  font-family: inherit;
}
input:focus { outline: none; border-color: var(--series-1); }
.error-text { color: var(--critical); font-size: 13px; margin-bottom: 14px; }

.autocomplete { position: relative; }
.autocomplete-results {
  position: absolute; top: 100%; left: 0; right: 0; z-index: 10;
  background: var(--surface-1); border: 1px solid var(--border); border-radius: 8px;
  margin-top: 4px; max-height: 240px; overflow-y: auto; display: none;
}
.autocomplete-results.open { display: block; }
.autocomplete-result {
  padding: 8px 11px; cursor: pointer; font-size: 13.5px; border-bottom: 1px solid var(--gridline);
}
.autocomplete-result:last-child { border-bottom: none; }
.autocomplete-result:hover { background: rgba(255, 255, 255, 0.04); }
.autocomplete-result .ac-secid { font-weight: 600; }
.autocomplete-result .ac-name { color: var(--text-muted); font-size: 12px; }

.form-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; align-items: end; }
@media (max-width: 780px) { .form-row { grid-template-columns: 1fr 1fr; } }

hr.section { border: none; border-top: 1px solid var(--border); margin: 28px 0; }
.section-label { font-size: 13px; color: var(--text-muted); margin-bottom: 16px; }
.back-link { font-size: 13px; color: var(--text-muted); text-decoration: none; margin-bottom: 16px; display: inline-block; }
.back-link:hover { color: var(--text-primary); }
