:root {
  --bg: #0b0f17;
  --bg-2: #111723;
  --card: #141b29;
  --card-2: #1a2334;
  --line: #243049;
  --text: #e8edf6;
  --muted: #8b97ad;
  --dim: #75839c;
  --accent: #f5b83d;
  --accent-ink: #1b1405;
  --accent-text: #f5b83d;
  --accent-soft: rgba(245, 184, 61, .08);
  --accent-line: rgba(245, 184, 61, .35);
  --promo-from: rgba(245, 184, 61, .16);
  --info-bg: rgba(91, 140, 255, .14);
  --shadow: 0 10px 30px rgba(0, 0, 0, .4);
  color-scheme: dark;
  --green: #22c58b;
  --green-bg: rgba(34, 197, 139, .12);
  --red: #f0566b;
  --red-bg: rgba(240, 86, 107, .12);
  --blue: #5b8cff;
  --radius: 14px;
  --font: "Manrope", system-ui, -apple-system, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, monospace;
}

/* Светлая тема */
:root[data-theme="light"] {
  --bg: #f4f6fa;
  --bg-2: #eef1f6;
  --card: #ffffff;
  --card-2: #f1f4f9;
  --line: #dfe4ec;
  --text: #121826;
  --muted: #5a6478;
  --dim: #5f6a7d;
  --accent-text: #a5680a;
  --accent-soft: rgba(245, 184, 61, .14);
  --accent-line: rgba(214, 150, 30, .45);
  --promo-from: rgba(245, 184, 61, .22);
  --green: #0a7d55;
  --green-bg: rgba(14, 154, 106, .1);
  --red: #cc2a45;
  --red-bg: rgba(220, 53, 80, .09);
  --info-bg: rgba(60, 110, 230, .1);
  --shadow: 0 10px 30px rgba(20, 30, 50, .12);
  color-scheme: light;
}
:root[data-theme="light"] .card, :root[data-theme="light"] .sidebar { box-shadow: 0 1px 2px rgba(20, 30, 50, .04); }

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
svg { fill: currentColor; }
button, input, select, textarea { font: inherit; color: inherit; }

/* ---------- layout ---------- */
.layout { display: flex; min-height: 100vh; }
.sidebar {
  width: 240px; flex-shrink: 0;
  background: var(--bg-2);
  border-right: 1px solid var(--line);
  padding: 20px 14px;
  position: sticky; top: 0; height: 100vh;
  display: flex; flex-direction: column; gap: 24px;
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 17px; letter-spacing: -.01em; }
.logo {
  width: 32px; height: 32px; border-radius: 9px;
  display: grid; place-items: center;
  background: var(--accent); color: var(--accent-ink);
  font-size: 13px; font-weight: 800;
}
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav a {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px; border-radius: 10px;
  color: var(--muted); font-weight: 600;
  transition: background .15s, color .15s;
}
.nav a svg { width: 20px; height: 20px; flex-shrink: 0; }
.nav .short { display: none; }
.nav a:hover { background: var(--card); color: var(--text); }
.nav a.active { background: var(--card-2); color: var(--text); }
.nav a.active svg { color: var(--accent-text); }
.sidebar-promo { margin-top: auto; }

.main { flex: 1; min-width: 0; }
.topbar { display: none; }
.view { max-width: 1180px; margin: 0 auto; padding: 28px 28px 60px; }
.mobile-only { display: none; }

/* ---------- typography ---------- */
h1 { font-size: 26px; font-weight: 800; letter-spacing: -.02em; margin: 0; }
h2 { font-size: 17px; font-weight: 700; margin: 0 0 14px; }
h3 { font-size: 15px; font-weight: 700; margin: 0; }
.muted { color: var(--muted); }
.dim { color: var(--dim); }
.mono { font-family: var(--mono); font-feature-settings: "tnum"; }
.pos { color: var(--green); }
.neg { color: var(--red); }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 22px; flex-wrap: wrap; }
.page-head p { margin: 4px 0 0; color: var(--muted); }

/* ---------- cards & grid ---------- */
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
}
.grid { display: grid; gap: 14px; }
.kpis { grid-template-columns: repeat(4, 1fr); margin-bottom: 14px; }
.two { grid-template-columns: 1.6fr 1fr; margin-bottom: 14px; }
.three { grid-template-columns: repeat(3, 1fr); margin-bottom: 14px; }
.kpi .label { color: var(--muted); font-size: 13px; font-weight: 600; }
.kpi .value { font-family: var(--mono); font-size: 24px; font-weight: 600; margin-top: 6px; letter-spacing: -.02em; }
.kpi .sub { color: var(--dim); font-size: 12.5px; margin-top: 2px; }

/* ---------- buttons & forms ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 10px 16px; border-radius: 10px;
  border: 1px solid var(--line); background: var(--card-2);
  font-weight: 700; cursor: pointer; white-space: nowrap;
  transition: transform .1s, background .15s, border-color .15s;
}
.btn:hover { border-color: #33415f; }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.06); }
.btn.danger { color: var(--red); }
.btn.sm { padding: 6px 10px; font-size: 13px; border-radius: 8px; }
.btn svg { width: 18px; height: 18px; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; }

.form { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; }
.form.filters { grid-template-columns: 1fr 1fr 2fr; }
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field.span2 { grid-column: span 2; }
.field.span4 { grid-column: 1 / -1; }
.field label { font-size: 13px; color: var(--muted); font-weight: 600; }
.input, select.input, textarea.input {
  width: 100%;
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 12px;
  outline: none;
  transition: border-color .15s;
}
.input:focus { border-color: var(--accent); }
textarea.input { resize: vertical; min-height: 80px; }
.seg { display: inline-flex; background: var(--bg-2); border: 1px solid var(--line); border-radius: 10px; padding: 3px; }
.seg button { border: 0; background: none; padding: 7px 16px; border-radius: 8px; font-weight: 700; color: var(--muted); cursor: pointer; }
.seg button.on-buy { background: var(--green-bg); color: var(--green); }
.seg button.on-sell { background: var(--red-bg); color: var(--red); }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip {
  border: 1px solid var(--line); background: var(--bg-2);
  padding: 6px 12px; border-radius: 999px; font-size: 13px; font-weight: 600;
  color: var(--muted); cursor: pointer;
}
.chip.on { border-color: var(--accent); color: var(--accent-text); background: var(--accent-soft); }

/* ---------- tables ---------- */
.table-wrap { overflow-x: auto; margin: 0 -18px; padding: 0 18px; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th { text-align: left; color: var(--dim); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; padding: 0 10px 10px; white-space: nowrap; }
td { padding: 11px 10px; border-top: 1px solid var(--line); white-space: nowrap; }
tr.clickable { cursor: pointer; }
tr.clickable:hover td { background: var(--card-2); }
td.num, th.num { text-align: right; font-family: var(--mono); font-feature-settings: "tnum"; }
.side { display: inline-block; padding: 2px 8px; border-radius: 6px; font-size: 12px; font-weight: 700; text-transform: uppercase; }
.side.buy { background: var(--green-bg); color: var(--green); }
.side.sell { background: var(--red-bg); color: var(--red); }

/* ---------- bars ---------- */
.bars { display: flex; flex-direction: column; gap: 10px; }
.bar-row { display: grid; grid-template-columns: 92px 1fr 90px; gap: 10px; align-items: center; font-size: 13.5px; }
.bar-row .name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-track { height: 8px; background: var(--bg-2); border-radius: 99px; position: relative; overflow: hidden; }
.bar-track .mid { position: absolute; left: 50%; top: 0; bottom: 0; width: 1px; background: var(--line); }
.bar-fill { position: absolute; top: 0; bottom: 0; border-radius: 99px; }
.bar-row .val { text-align: right; font-family: var(--mono); font-size: 13px; }
.bar-row .meta { grid-column: 2 / 4; color: var(--dim); font-size: 12px; margin-top: -6px; }

/* ---------- chart ---------- */
.chart { width: 100%; height: 240px; display: block; }
.chart .grid-line { stroke: var(--line); stroke-width: 1; }
.chart .axis { fill: var(--dim); font-size: 11px; font-family: var(--mono); }

/* ---------- insights & promo ---------- */
.insights { display: flex; flex-direction: column; gap: 10px; }
.insight { display: flex; gap: 12px; padding: 12px; border-radius: 12px; background: var(--bg-2); border: 1px solid var(--line); font-size: 14px; }
.insight .ico { width: 28px; height: 28px; border-radius: 8px; display: grid; place-items: center; flex-shrink: 0; font-size: 15px; }
.insight.good .ico { background: var(--green-bg); }
.insight.bad .ico { background: var(--red-bg); }
.insight.info .ico { background: var(--info-bg); }
.promo {
  border-radius: var(--radius);
  padding: 18px;
  background: linear-gradient(135deg, var(--promo-from), transparent 60%), var(--card);
  border: 1px solid var(--accent-line);
}
.promo h3 { margin-bottom: 6px; }
.promo p { margin: 0 0 14px; color: var(--muted); font-size: 14px; }
.promo.compact { padding: 14px; }
.promo.compact p { font-size: 13px; margin-bottom: 10px; }
.partner {
  display: flex; align-items: center; gap: 14px;
  padding: 14px; border-radius: 12px; background: var(--bg-2); border: 1px solid var(--line);
}
.partner .avatar { width: 40px; height: 40px; border-radius: 10px; background: var(--card-2); display: grid; place-items: center; font-weight: 800; color: var(--accent-text); flex-shrink: 0; }
.partner .info { flex: 1; min-width: 0; }
.partner .info p { margin: 2px 0 0; color: var(--muted); font-size: 13px; }
.badge { font-size: 11px; font-weight: 700; padding: 2px 7px; border-radius: 6px; background: var(--card-2); color: var(--muted); margin-left: 6px; vertical-align: middle; }
.disclaimer { color: var(--dim); font-size: 12.5px; margin-top: 18px; }

.check { display: flex; align-items: center; justify-content: space-between; padding: 10px 0; border-top: 1px solid var(--line); font-size: 14px; }
.check:first-of-type { border-top: 0; }
.verdict { font-size: 20px; font-weight: 800; margin: 4px 0 12px; }

/* ---------- empty / dropzone ---------- */
.empty { text-align: center; padding: 56px 20px; }
.empty .big { font-size: 42px; margin-bottom: 8px; }
.empty h2 { margin-bottom: 6px; }
.empty p { color: var(--muted); max-width: 440px; margin: 0 auto 20px; }
.drop {
  border: 2px dashed var(--line); border-radius: var(--radius);
  padding: 30px 20px; text-align: center; cursor: pointer;
  transition: border-color .15s, background .15s;
}
.drop:hover, .drop.over { border-color: var(--accent); background: var(--accent-soft); }
.drop strong { display: block; margin-bottom: 4px; }
.steps { margin: 0; padding-left: 20px; color: var(--muted); font-size: 14px; }
.steps li { margin-bottom: 6px; }
.steps b { color: var(--text); font-weight: 600; }

.result-big { font-family: var(--mono); font-size: 40px; font-weight: 600; color: var(--accent-text); letter-spacing: -.02em; }

.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 20px);
  background: var(--card-2); border: 1px solid var(--line);
  padding: 12px 18px; border-radius: 12px; font-weight: 600; font-size: 14px;
  opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; z-index: 50;
  box-shadow: var(--shadow);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- responsive ---------- */
@media (max-width: 1000px) {
  .kpis { grid-template-columns: repeat(2, 1fr); }
  .two, .three { grid-template-columns: 1fr; }
  .form { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 760px) {
  .mobile-only { display: flex; }
  .topbar {
    display: flex; align-items: center; justify-content: space-between;
    padding: calc(12px + env(safe-area-inset-top)) 16px 12px;
    background: var(--bg); border-bottom: 1px solid var(--line);
    position: sticky; top: 0; z-index: 10;
  }
  .icon-btn { width: 38px; height: 38px; border-radius: 10px; background: var(--card); border: 1px solid var(--line); align-items: center; justify-content: center; color: var(--muted); }
  .icon-btn svg { width: 20px; height: 20px; }
  .sidebar {
    position: fixed; top: auto; bottom: 0; left: 0; right: 0; height: auto; width: auto;
    padding: 6px 6px calc(6px + env(safe-area-inset-bottom));
    border-right: 0; border-top: 1px solid var(--line);
    z-index: 20; flex-direction: row;
  }
  .sidebar .brand, .sidebar-promo, .nav-settings { display: none !important; }
  .nav { flex-direction: row; width: 100%; justify-content: space-around; }
  .nav a { flex-direction: column; gap: 3px; padding: 6px 2px; font-size: 11px; flex: 1 1 0; min-width: 0; }
  .nav a span { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .nav .long { display: none; }
  .nav .short { display: inline; }
  .nav a.nav-add svg { background: var(--accent); color: var(--accent-ink); border-radius: 50%; padding: 3px; width: 26px; height: 26px; margin: -3px 0; }
  .view { padding: 18px 16px calc(96px + env(safe-area-inset-bottom)); }
  h1 { font-size: 22px; }
  .kpi .value { font-size: 20px; }
  .card { padding: 14px; }
  .table-wrap { margin: 0 -14px; padding: 0 14px; }
  .form { grid-template-columns: 1fr 1fr; gap: 12px; }
  .field.span2 { grid-column: 1 / -1; }
  .form.filters { grid-template-columns: 1fr 1fr; }
  .form.filters .field:last-child { grid-column: 1 / -1; }
  .bar-row { grid-template-columns: 76px 1fr 78px; }
}
@media (max-width: 360px) {
  .nav a { font-size: 10px; }
}

/* ---------- переключатель темы ---------- */
.theme-btn {
  display: flex; align-items: center; gap: 10px; width: 100%;
  padding: 10px 12px; border-radius: 10px; border: 0; background: none;
  color: var(--muted); font-weight: 600; cursor: pointer; text-align: left;
}
.theme-btn:hover { background: var(--card); color: var(--text); }
.theme-btn svg, .icon-btn svg { width: 20px; height: 20px; }
.theme-btn .moon, :root[data-theme="light"] .theme-btn .sun, .icon-btn .moon, :root[data-theme="light"] .icon-btn .sun { display: none; }
:root[data-theme="light"] .theme-btn .moon, :root[data-theme="light"] .icon-btn .moon { display: block; }
.topbar-actions { display: flex; gap: 8px; }
@media (max-width: 760px) {
  .sidebar .theme-btn { display: none; }
  .icon-btn { cursor: pointer; padding: 0; }
}

/* ---------- скриншоты ---------- */
.shots { display: flex; flex-wrap: wrap; gap: 10px; padding: 10px; border: 2px dashed var(--line); border-radius: 12px; transition: border-color .15s, background .15s; }
.shots.over { border-color: var(--accent); background: var(--accent-soft); }
.shot-list { display: contents; }
.shot { position: relative; width: 120px; height: 84px; border-radius: 10px; overflow: hidden; border: 1px solid var(--line); background: var(--bg-2); }
.shot img { width: 100%; height: 100%; object-fit: cover; cursor: zoom-in; display: block; }
.shot-del {
  position: absolute; top: 4px; right: 4px; width: 24px; height: 24px; border-radius: 50%;
  border: 0; background: rgba(0, 0, 0, .65); color: #fff; font-size: 16px; line-height: 1; cursor: pointer;
}
.shot-add {
  width: 120px; height: 84px; border-radius: 10px; background: var(--bg-2); border: 1px solid var(--line);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  cursor: pointer; color: var(--muted); font-size: 12.5px; font-weight: 600; text-align: center; padding: 4px;
}
.shot-add[hidden] { display: none; }
.shot-add:hover { border-color: var(--accent); color: var(--text); }
.shot-add svg { width: 22px; height: 22px; }
.shot-add small { font-size: 10.5px; font-weight: 500; }
.has-shots { font-size: 12px; }
.lightbox { position: fixed; inset: 0; z-index: 60; background: rgba(5, 8, 14, .88); display: grid; place-items: center; padding: 20px; cursor: zoom-out; }
.lightbox[hidden] { display: none; }
.lightbox img { max-width: 100%; max-height: 100%; border-radius: 10px; box-shadow: 0 20px 60px rgba(0, 0, 0, .5); }
@media (max-width: 760px) {
  .shot, .shot-add { width: calc(50% - 5px); height: 96px; }
  .shot-add small { display: none; }
}
