/* ============ Tokens ============ */
:root {
  --bg: #050505;
  --bg-2: #090909;
  --card: #0c0c0c;
  --card-2: #101010;
  --card-3: #161616;
  --input: #0e0e0e;
  --line: #1c1c1c;
  --line-2: #262626;
  --text: #f2f2f2;
  --muted: #8a8a8a;
  --dim: #5c5c5c;
  /* Фирменный акцент (оформление) */
  --accent: #8b7cff;
  --accent-2: #a397ff;
  --accent-ink: #120d33;
  --accent-a: rgba(139, 124, 255, .13);
  --accent-b: rgba(139, 124, 255, .30);
  /* Прибыль — зелёный остаётся только для результата */
  --green: #3ddc84;
  --green-ink: #04140b;
  --green-a: rgba(61, 220, 132, .12);
  --red: #f05454;
  --red-a: rgba(240, 84, 84, .12);
  --red-b: rgba(240, 84, 84, .26);
  --yellow: #f2c94c;
  --yellow-a: rgba(242, 201, 76, .11);
  --yellow-b: rgba(242, 201, 76, .26);
  --blue: #6aa8ff;
  --radius: 20px;
  --radius-sm: 12px;
  --font: 'Inter Tight', 'Segoe UI', system-ui, -apple-system, Roboto, Arial, sans-serif;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; cursor: pointer; }
img { max-width: 100%; display: block; }
kbd {
  font: 600 11px var(--font);
  padding: 1px 6px;
  border: 1px solid var(--line-2);
  border-bottom-width: 2px;
  border-radius: 5px;
  color: var(--text);
}
::selection { background: var(--accent); color: var(--accent-ink); }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: #222; border-radius: 10px; border: 2px solid var(--bg); }
::-webkit-scrollbar-track { background: transparent; }

.pos { color: var(--green); }
.neg { color: var(--red); }
.zero { color: var(--yellow); }
.muted { color: var(--muted); }
.dim { color: var(--dim); }
.nowrap { white-space: nowrap; }
.hidden { display: none !important; }

/* ============ Icons ============ */
.ico { display: inline-flex; width: 18px; height: 18px; flex: none; }
.ico svg { width: 100%; height: 100%; }

/* ============ Layout ============ */
.app {
  display: grid;
  grid-template-columns: 236px minmax(0, 1fr);
  min-height: 100vh;
}
.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding: 20px 14px;
  border-right: 1px solid var(--line);
  background: var(--bg);
  z-index: 40;
}
.brand { display: flex; align-items: center; gap: 12px; padding: 4px 6px 10px; }
.brand-mark {
  width: 42px; height: 42px;
  display: grid; place-items: center;
  border: 1px solid var(--line-2);
  border-radius: 12px;
  background: var(--card-2);
  color: var(--accent);
}
.brand-mark svg { width: 24px; height: 24px; }
.brand-text { display: flex; flex-direction: column; line-height: 1.1; }
.brand-text b { font-size: 19px; font-weight: 800; letter-spacing: -.02em; }
.brand-text b span { color: var(--accent); }
.brand-text small {
  font-size: 9.5px; font-weight: 600; letter-spacing: .22em;
  text-transform: uppercase; color: var(--muted); margin-top: 3px;
}
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav a {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px;
  border-radius: 12px;
  color: var(--muted);
  font-weight: 500;
  transition: background .15s, color .15s;
}
.nav a:hover { color: var(--text); background: var(--card-2); }
.nav a.active { color: var(--text); background: var(--card-3); }
.nav a.active .ico { color: var(--accent); }
.sidebar-foot { margin-top: auto; display: flex; flex-direction: column; gap: 10px; }
.sidebar-hint { margin: 0; text-align: center; font-size: 12px; color: var(--dim); }

.main { min-width: 0; padding: 30px 40px 80px; }
.fab { display: none; }

/* ============ Typography ============ */
.page-head {
  display: flex; align-items: flex-end; justify-content: space-between;
  gap: 24px; flex-wrap: wrap;
  margin-bottom: 30px;
}
.headline {
  margin: 0;
  font-weight: 900;
  font-size: clamp(40px, 6.2vw, 92px);
  line-height: .88;
  letter-spacing: -.05em;
  text-transform: uppercase;
}
.headline span { display: block; color: var(--accent); }
.page-actions { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.section-title { font-size: 20px; font-weight: 700; letter-spacing: -.01em; margin: 0 0 6px; }
.section-sub { margin: 0 0 18px; color: var(--muted); }
.eyebrow {
  font-size: 10px; font-weight: 600; letter-spacing: .14em;
  text-transform: uppercase; color: var(--dim);
}

/* ============ Buttons ============ */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 11px 18px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line-2);
  background: transparent;
  font-weight: 600; font-size: 14px;
  white-space: nowrap;
  transition: background .15s, border-color .15s, transform .1s, opacity .15s;
}
.btn:hover { border-color: #3a3a3a; background: var(--card-2); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .45; pointer-events: none; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn-primary:hover { background: var(--accent-2); border-color: var(--accent-2); }
.btn-danger { color: var(--red); border-color: var(--red-b); }
.btn-danger:hover { background: var(--red-a); border-color: var(--red); }
.btn-sm { padding: 7px 12px; font-size: 13px; border-radius: 10px; }
.btn-icon { padding: 8px; width: 36px; height: 36px; border-radius: 10px; }
.btn-block { width: 100%; }
.link-btn { background: none; border: 0; padding: 0; color: var(--accent); font-weight: 600; }

.seg {
  display: inline-flex; gap: 2px;
  padding: 3px;
  background: var(--input);
  border: 1px solid var(--line-2);
  border-radius: 12px;
}
.seg button {
  border: 0; background: transparent;
  padding: 7px 13px; border-radius: 9px;
  color: var(--muted); font-size: 13px; font-weight: 500;
}
.seg button:hover { color: var(--text); }
.seg button.on { background: #1f1f1f; color: var(--text); }
.seg.seg-dir button.on[data-v="long"] { background: var(--green-a); color: var(--green); }
.seg.seg-dir button.on[data-v="short"] { background: var(--red-a); color: var(--red); }

/* ============ Cards ============ */
.card {
  position: relative;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 24px;
  min-width: 0;
}
.card.glow { overflow: hidden; }
.card.glow::before {
  content: '';
  position: absolute; inset: 0;
  background: radial-gradient(520px 240px at 0 0, rgba(139, 124, 255, .10), transparent 65%);
  pointer-events: none;
}
.card.glow-strong::before {
  background: radial-gradient(620px 300px at 0 0, rgba(139, 124, 255, .18), transparent 65%);
}
.card > * { position: relative; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.card-head h3 { margin: 0; font-size: 17px; font-weight: 700; }
.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.stack { display: flex; flex-direction: column; gap: 16px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.spacer { flex: 1; }

/* ============ Metrics strip ============ */
.metrics {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(104px, 1fr));
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
  overflow: hidden;
}
.metric { padding: 13px 16px 14px; min-width: 0; box-shadow: 1px 0 0 var(--line), 0 1px 0 var(--line); }
.metric .eyebrow { display: block; margin-bottom: 6px; line-height: 1.3; }
.metric b { font-size: 19px; font-weight: 600; letter-spacing: -.01em; white-space: nowrap; }
.metric small { display: block; color: var(--dim); font-size: 11.5px; margin-top: 2px; }

.big-total { display: flex; align-items: baseline; gap: 22px; flex-wrap: wrap; margin-bottom: 18px; }
.big-total b { font-size: clamp(44px, 6vw, 72px); font-weight: 700; letter-spacing: -.04em; line-height: 1; }
.big-total span { font-size: 22px; color: var(--muted); font-weight: 500; }

/* ============ Badges & chips ============ */
.badge {
  display: inline-flex; align-items: center;
  padding: 2px 7px;
  border-radius: 6px;
  font-size: 10.5px; font-weight: 800; letter-spacing: .03em;
  line-height: 1.5;
  white-space: nowrap;
}
.b-tp { background: var(--green); color: var(--green-ink); }
.b-sl { background: var(--red); color: #1d0606; }
.b-be { background: var(--yellow); color: #1d1605; }
.b-open { background: #2a2a2a; color: var(--text); }
.b-long { background: var(--green-a); color: var(--green); }
.b-short { background: var(--red-a); color: var(--red); }

.chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 5px 12px;
  border: 1px solid var(--line-2);
  border-radius: 999px;
  background: var(--card-2);
  color: var(--muted);
  font-size: 13px;
  white-space: nowrap;
}
button.chip:hover { color: var(--text); border-color: #3a3a3a; }
.chip.on { color: var(--accent); border-color: var(--accent-b); background: var(--accent-a); }
.chip.bad.on { color: var(--red); border-color: var(--red-b); background: var(--red-a); }
.chip .x { border: 0; background: none; padding: 0; color: var(--dim); font-size: 15px; line-height: 1; }
.chip .x:hover { color: var(--red); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }

/* ============ Forms ============ */
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field > label, .label {
  font-size: 11px; font-weight: 600; letter-spacing: .08em;
  text-transform: uppercase; color: var(--dim);
}
.field .hint { font-size: 12px; color: var(--dim); }
.input, .select, .textarea {
  width: 100%;
  padding: 10px 12px;
  background: var(--input);
  border: 1px solid var(--line-2);
  border-radius: 10px;
  color: var(--text);
  font: inherit; font-size: 14px;
  outline: none;
  transition: border-color .15s, background .15s;
}
.input::placeholder, .textarea::placeholder { color: #4a4a4a; }
.input:focus, .select:focus, .textarea:focus { border-color: var(--accent); background: #0f0d1c; }
.select { appearance: none; padding-right: 32px; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%238a8a8a' stroke-width='2.5'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; }
.textarea { resize: vertical; min-height: 84px; line-height: 1.5; }
input[type="datetime-local"].input, input[type="date"].input { color-scheme: dark; }
.form-grid { display: grid; gap: 14px; grid-template-columns: repeat(4, minmax(0, 1fr)); }
.form-grid .span-2 { grid-column: span 2; }
.form-grid .span-4 { grid-column: 1 / -1; }
.form-section { padding: 20px 0; border-top: 1px solid var(--line); }
.form-section:first-child { border-top: 0; padding-top: 4px; }
.form-section > h4 {
  margin: 0 0 14px;
  font-size: 13px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase;
  color: var(--muted);
  display: flex; align-items: center; gap: 10px;
}
.form-section > h4 .n {
  font-size: 11px; color: var(--accent);
  border: 1px solid var(--accent-b); border-radius: 6px; padding: 1px 6px;
}
.input-group { display: flex; gap: 6px; }
.input-group .input { flex: 1; }
.check {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--line-2); border-radius: 10px;
  background: var(--input);
  cursor: pointer;
  font-size: 14px;
}
.check input { accent-color: var(--accent); width: 16px; height: 16px; margin: 2px 0 0; flex: none; }
.check:has(input:checked) { border-color: var(--accent-b); background: #100e1d; }
.stars { display: inline-flex; gap: 4px; }
.stars button { border: 0; background: none; padding: 2px; color: #333; font-size: 22px; line-height: 1; }
.stars button.on { color: var(--yellow); }

.preview-strip {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
  gap: 1px; background: var(--line);
  border: 1px solid var(--line); border-radius: 14px; overflow: hidden;
  margin-top: 14px;
}
.preview-strip > div { background: var(--card-2); padding: 10px 14px; }
.preview-strip b { display: block; font-size: 16px; font-weight: 600; margin-top: 3px; }

/* Dropzones */
.shots { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.dropzone {
  border: 1.5px dashed var(--line-2);
  border-radius: 14px;
  padding: 14px;
  background: var(--input);
  min-height: 150px;
  display: flex; flex-direction: column; gap: 10px;
  transition: border-color .15s, background .15s;
}
.dropzone.active { border-color: var(--accent-b); }
.dropzone.drag { border-color: var(--accent); background: #100e1d; }
.dropzone-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.dropzone-head b { font-size: 13px; }
.dropzone-empty { flex: 1; display: grid; place-items: center; text-align: center; color: var(--dim); font-size: 13px; padding: 10px; }
.thumbs { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 8px; }
.thumb { position: relative; aspect-ratio: 16 / 10; border-radius: 10px; overflow: hidden; border: 1px solid var(--line-2); background: #111; cursor: zoom-in; }
.thumb img { width: 100%; height: 100%; object-fit: cover; }
.thumb .del {
  position: absolute; top: 4px; right: 4px;
  width: 22px; height: 22px; border-radius: 6px; border: 0;
  background: rgba(0, 0, 0, .75); color: #fff; font-size: 14px; line-height: 1;
}
.thumb .del:hover { background: var(--red); }

/* ============ Tables ============ */
.table-wrap { overflow-x: auto; margin: 0 -24px; padding: 0 24px; }
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th {
  text-align: left;
  font-size: 10px; font-weight: 600; letter-spacing: .12em; text-transform: uppercase;
  color: var(--dim);
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
  user-select: none;
}
.table th.sortable { cursor: pointer; }
.table th.sortable:hover { color: var(--muted); }
.table th.sorted { color: var(--accent); }
.table td { padding: 12px 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
@media (max-width: 1560px) { .table .c-tags { display: none; } }
@media (max-width: 1300px) { .table .c-vol { display: none; } }
.table tbody tr { transition: background .1s; }
.table tbody tr.clickable { cursor: pointer; }
.table tbody tr.clickable:hover { background: var(--card-3); }
.table .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.table tfoot td { font-weight: 700; border-bottom: 0; color: var(--text); }

/* Binance: живые цены */
.live-dot { font-size: 12px; display: inline-flex; align-items: center; gap: 6px; }
.live-dot::before { content: ''; width: 7px; height: 7px; border-radius: 50%; background: var(--green); animation: live-pulse 1.6s ease-in-out infinite; }
@keyframes live-pulse { 50% { opacity: .25; } }
.tick-up { animation: tick-up .8s ease-out; }
.tick-down { animation: tick-down .8s ease-out; }
@keyframes tick-up { from { color: var(--green); background: var(--green-a); } }
@keyframes tick-down { from { color: var(--red); background: var(--red-a); } }
@media (prefers-reduced-motion: reduce) { .live-dot::before, .tick-up, .tick-down { animation: none; } }
@media (max-width: 640px) { .table .c-sm-hide { display: none; } }
.sym { font-weight: 700; }
.sym small { display: block; font-weight: 400; color: var(--dim); font-size: 12px; }
.bar-cell { position: relative; min-width: 120px; }
.bar-track { height: 6px; border-radius: 6px; background: #1a1a1a; position: relative; overflow: hidden; }
.bar-fill { position: absolute; top: 0; bottom: 0; border-radius: 6px; }

/* ============ Calendar ============ */
.cal-layout { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 16px; align-items: start; margin-top: 16px; }
.cal-toolbar { display: flex; align-items: center; justify-content: flex-end; gap: 8px; margin-bottom: 18px; flex-wrap: wrap; }
.cal-toolbar .month-label {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 7px 14px; border: 1px solid var(--line-2); border-radius: 10px;
  font-weight: 600; font-size: 14px; background: var(--input);
}
.cal-toolbar h3 { margin: 0 auto 0 0; font-size: 17px; }
.cal { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)) 92px; gap: 6px; }
.cal-dow { text-align: center; font-size: 10px; font-weight: 600; letter-spacing: .14em; color: var(--dim); padding: 4px 0 8px; text-transform: uppercase; }
.cal-day {
  position: relative;
  min-height: 96px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: #0e0e0e;
  padding: 8px 9px;
  display: flex; flex-direction: column; gap: 4px;
  text-align: left;
  cursor: pointer;
  transition: border-color .15s, transform .1s;
  min-width: 0;
}
.cal-day:hover { border-color: #333; }
.cal-day.out { visibility: hidden; }
.cal-day .d { font-size: 11px; color: var(--dim); font-weight: 600; }
.cal-day .v { font-size: 14px; font-weight: 700; margin-top: auto; white-space: nowrap; }
.cal-day .cnt { font-size: 11px; color: var(--muted); }
.cal-day.tp { background: linear-gradient(180deg, rgba(61, 220, 132, .16), rgba(61, 220, 132, .07)); border-color: rgba(61, 220, 132, .22); }
.cal-day.tp .v { color: var(--green); }
.cal-day.sl { background: linear-gradient(180deg, rgba(240, 84, 84, .16), rgba(240, 84, 84, .07)); border-color: rgba(240, 84, 84, .22); }
.cal-day.sl .v { color: var(--red); }
.cal-day.be { background: linear-gradient(180deg, rgba(242, 201, 76, .15), rgba(242, 201, 76, .06)); border-color: rgba(242, 201, 76, .22); }
.cal-day.be .v { color: var(--yellow); }
.cal-day.today .d { color: var(--accent); }
.cal-day.sel { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent) inset; }
.cal-day .badges { display: flex; gap: 3px; flex-wrap: wrap; }
.cal-week {
  border-radius: 12px; border: 1px dashed var(--line-2);
  padding: 8px 9px; display: flex; flex-direction: column; justify-content: space-between;
  font-size: 11px; color: var(--dim); min-height: 96px;
}
.cal-week b { font-size: 14px; }

.day-panel .day-title { font-size: 10.5px; font-weight: 600; letter-spacing: .16em; color: var(--muted); text-transform: uppercase; padding-bottom: 14px; border-bottom: 1px solid var(--line); margin-bottom: 14px; }
.day-empty { text-align: center; padding: 26px 0; color: var(--dim); font-size: 14px; }
.trade-mini {
  display: flex; align-items: center; gap: 10px;
  width: 100%;
  padding: 11px 12px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--card-2);
  margin-bottom: 8px;
  text-align: left;
  transition: border-color .15s;
}
.trade-mini:hover { border-color: #333; }
.trade-mini .sym { flex: 1; min-width: 0; }
.trade-mini .v { font-weight: 700; font-variant-numeric: tabular-nums; }

/* ============ Charts ============ */
.chart { position: relative; }
.chart svg { display: block; width: 100%; overflow: visible; }
.chart .y-labels { position: absolute; left: 0; top: 0; bottom: 0; width: 100%; pointer-events: none; }
.chart .y-labels span { position: absolute; left: 0; transform: translateY(-50%); font-size: 10.5px; color: var(--dim); }
.chart .x-labels { display: flex; justify-content: space-between; font-size: 10.5px; color: var(--dim); margin-top: 6px; padding-left: 34px; }
.chart .tip {
  position: absolute; top: 0;
  pointer-events: none;
  background: #151515; border: 1px solid var(--line-2); border-radius: 10px;
  padding: 7px 10px; font-size: 12.5px; white-space: nowrap;
  transform: translate(-50%, -110%);
  opacity: 0; transition: opacity .1s;
  z-index: 3;
}
.chart .tip.show { opacity: 1; }
.chart .cursor { position: absolute; top: 0; bottom: 0; width: 1px; background: #333; pointer-events: none; opacity: 0; }
.chart .cursor.show { opacity: 1; }
.chart-empty { display: grid; place-items: center; min-height: 160px; color: var(--dim); font-size: 14px; text-align: center; }
.chart-head { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.chart-head .eyebrow + b { font-size: 15px; }

.donut-wrap { display: flex; align-items: center; gap: 22px; flex-wrap: wrap; }
.legend { display: flex; flex-direction: column; gap: 8px; font-size: 14px; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 8px; vertical-align: middle; }

.vbars { display: flex; align-items: stretch; gap: 3px; height: 140px; }
.vbars .col { flex: 1; display: flex; flex-direction: column; position: relative; min-width: 0; }
.vbars .half { flex: 1; display: flex; }
.vbars .half.top { align-items: flex-end; border-bottom: 1px solid var(--line-2); }
.vbars .half.bot { align-items: flex-start; }
.vbars .bar { width: 100%; border-radius: 3px; min-height: 0; }

/* ============ Stats ============ */
.leak {
  display: flex; align-items: center; gap: 14px;
  padding: 12px 14px; border-radius: 12px; border: 1px solid var(--line);
  background: var(--card-2); margin-bottom: 8px;
}
.leak .name { flex: 1; min-width: 0; font-weight: 600; }
.leak .name small { display: block; color: var(--dim); font-weight: 400; }
.leak .v { font-weight: 700; font-variant-numeric: tabular-nums; }

/* ============ Assistant ============ */
.assistant-layout { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 16px; align-items: start; }
.chat { display: flex; flex-direction: column; min-height: 560px; }
.chat-log { flex: 1; display: flex; flex-direction: column; gap: 14px; padding-bottom: 16px; }
.msg-user {
  align-self: flex-end;
  max-width: 82%;
  background: var(--accent); color: var(--accent-ink);
  padding: 12px 18px; border-radius: 16px 16px 4px 16px;
  font-weight: 500; white-space: pre-wrap;
}
.msg-ai {
  align-self: flex-start;
  max-width: 92%;
  background: var(--card-2);
  border: 1px solid var(--line-2);
  padding: 14px 18px; border-radius: 16px 16px 16px 4px;
}
.msg-ai .who { font-size: 13px; font-weight: 700; color: var(--accent); margin-bottom: 6px; display: block; }
.msg-ai p { margin: 0 0 10px; }
.msg-ai p:last-child { margin-bottom: 0; }
.msg-ai ul, .msg-ai ol { margin: 0 0 10px; padding-left: 20px; }
.msg-ai li { margin-bottom: 4px; }
.msg-ai h4 { margin: 12px 0 6px; font-size: 15px; }
.msg-ai code { background: #1b1b1b; padding: 1px 5px; border-radius: 5px; font-size: 13px; }
.msg-ai.err { border-color: var(--red-b); }
.msg-ai.err .who { color: var(--red); }
.typing { display: inline-flex; gap: 4px; padding: 4px 0; }
.typing i { width: 6px; height: 6px; border-radius: 50%; background: var(--accent); animation: blink 1.2s infinite; }
.typing i:nth-child(2) { animation-delay: .2s; }
.typing i:nth-child(3) { animation-delay: .4s; }
@keyframes blink { 0%, 80%, 100% { opacity: .2; } 40% { opacity: 1; } }
.chat-input { display: flex; gap: 10px; align-items: flex-end; border-top: 1px solid var(--line); padding-top: 16px; }
.chat-input .textarea { min-height: 52px; max-height: 200px; }
.bot-face {
  width: 112px; height: 112px; border-radius: 50%;
  background: var(--accent);
  display: grid; place-items: center;
  box-shadow: 0 0 60px rgba(139, 124, 255, .35);
  flex: none;
}
.bot-face svg { width: 62%; }
.suggest { display: flex; flex-direction: column; gap: 8px; }
.suggest button {
  text-align: left; padding: 11px 14px; border-radius: 12px;
  border: 1px solid var(--line-2); background: var(--card-2); color: var(--text);
  font-size: 14px;
}
.suggest button:hover { border-color: var(--accent-b); color: var(--accent); }

/* ============ Rules ============ */
.rule-item {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 14px; border: 1px solid var(--line); border-radius: 12px;
  background: var(--card-2); margin-bottom: 8px;
}
.rule-item.dragging { opacity: .4; }
.rule-item.over { border-color: var(--accent); }
.rule-item .handle { cursor: grab; color: var(--dim); font-size: 18px; line-height: 1; user-select: none; }
.rule-item .n { color: var(--accent); font-weight: 800; font-size: 13px; min-width: 22px; }
.rule-item .txt { flex: 1; min-width: 0; }
.rule-item .txt input { width: 100%; }
.rule-item .meta { font-size: 12px; color: var(--dim); white-space: nowrap; }

/* ============ News ============ */
/* color-scheme: normal — иначе Chrome подкладывает белый фон под прозрачный iframe виджета */
.news-frame { color-scheme: normal; height: 720px; border-radius: 14px; overflow: hidden; border: 1px solid var(--line); background: #0b0b0b; }
.news-frame .tradingview-widget-container, .news-frame .tradingview-widget-container__widget { height: 100%; }
.news-offline { display: grid; place-items: center; height: 100%; color: var(--dim); text-align: center; padding: 20px; }

/* ============ Modal ============ */
.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(0, 0, 0, .72);
  backdrop-filter: blur(6px);
  display: flex; align-items: flex-start; justify-content: center;
  padding: 4vh 16px;
  overflow-y: auto;
  z-index: 100;
  animation: fade .15s ease;
}
.modal {
  width: min(760px, 100%);
  background: var(--card);
  border: 1px solid var(--line-2);
  border-radius: 22px;
  box-shadow: 0 30px 80px rgba(0, 0, 0, .6);
  animation: rise .18s ease;
  position: relative;
  overflow: hidden;
}
.modal.wide { width: min(1040px, 100%); }
.modal.small { width: min(440px, 100%); }
.modal::before {
  content: ''; position: absolute; inset: 0;
  background: radial-gradient(600px 200px at 0 0, rgba(139, 124, 255, .08), transparent 65%);
  pointer-events: none;
}
.modal-head { position: relative; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 20px 24px; border-bottom: 1px solid var(--line); }
.modal-head h2 { margin: 0; font-size: 20px; font-weight: 800; letter-spacing: -.01em; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.modal-body { position: relative; padding: 20px 24px; }
.modal-foot { position: relative; display: flex; gap: 10px; justify-content: flex-end; flex-wrap: wrap; padding: 16px 24px; border-top: 1px solid var(--line); background: var(--card-2); }
.modal-foot .left { margin-right: auto; display: flex; gap: 10px; flex-wrap: wrap; }
@keyframes fade { from { opacity: 0; } }
@keyframes rise { from { opacity: 0; transform: translateY(12px); } }

.lightbox {
  position: fixed; inset: 0; z-index: 200;
  background: rgba(0, 0, 0, .92);
  display: grid; place-items: center; padding: 24px;
  cursor: zoom-out; animation: fade .15s ease;
}
.lightbox img { max-width: 100%; max-height: 100%; border-radius: 10px; }

.detail-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 1px; background: var(--line); border: 1px solid var(--line); border-radius: 14px; overflow: hidden; }
.detail-grid > div { background: var(--card-2); padding: 11px 14px; min-width: 0; }
.detail-grid b { display: block; font-weight: 600; margin-top: 3px; overflow-wrap: anywhere; }
.note-block { padding: 14px 16px; border: 1px solid var(--line); border-radius: 12px; background: var(--card-2); }
.note-block p { margin: 6px 0 0; white-space: pre-wrap; color: #d6d6d6; }
.shot-big { border-radius: 12px; overflow: hidden; border: 1px solid var(--line-2); cursor: zoom-in; background: #111; }

/* ============ Toasts ============ */
.toasts { position: fixed; right: 20px; bottom: 20px; display: flex; flex-direction: column; gap: 8px; z-index: 300; }
.toast {
  padding: 12px 16px; border-radius: 12px;
  background: #151515; border: 1px solid var(--line-2);
  box-shadow: 0 10px 30px rgba(0, 0, 0, .5);
  font-size: 14px; max-width: 340px;
  animation: rise .18s ease;
}
.toast.ok { border-color: var(--accent-b); }
.toast.err { border-color: var(--red-b); }

/* ============ Filters ============ */
.filters { display: grid; grid-template-columns: 2fr repeat(4, minmax(0, 1fr)); gap: 10px; margin-bottom: 12px; }
.filters-2 { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 18px; }
.empty-state { text-align: center; padding: 50px 20px; color: var(--muted); }
.empty-state h3 { color: var(--text); margin: 0 0 6px; font-size: 20px; }
.empty-state p { margin: 0 0 18px; }

.calc-out { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1px; background: var(--line); border: 1px solid var(--line); border-radius: 16px; overflow: hidden; }
.calc-out > div { background: var(--card-2); padding: 16px 18px; }
.calc-out b { display: block; font-size: 26px; font-weight: 700; letter-spacing: -.02em; margin-top: 4px; }
.calc-out .hero { grid-column: 1 / -1; background: linear-gradient(135deg, rgba(139, 124, 255, .16), rgba(139, 124, 255, .04)); }
.calc-out .hero b { font-size: 46px; color: var(--accent); }

/* ============ Responsive ============ */
@media (max-width: 1280px) {
  .cal-layout { grid-template-columns: 1fr; }
  .assistant-layout { grid-template-columns: 1fr; }
}
@media (max-width: 1100px) {
  .main { padding: 26px 24px 80px; }
  .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .filters { grid-template-columns: 1fr 1fr; }
  .filters > :first-child { grid-column: 1 / -1; }
}
@media (max-width: 900px) {
  .app { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed; top: auto; bottom: 0; left: 0; right: 0;
    height: auto; flex-direction: row; gap: 0;
    padding: 6px 6px calc(6px + env(safe-area-inset-bottom));
    border-right: 0; border-top: 1px solid var(--line);
    background: rgba(5, 5, 5, .94); backdrop-filter: blur(10px);
  }
  .brand, .sidebar-foot { display: none; }
  .nav { flex-direction: row; overflow-x: auto; width: 100%; gap: 2px; scrollbar-width: none; }
  .nav::-webkit-scrollbar { display: none; }
  .nav a { flex-direction: column; gap: 3px; padding: 7px 10px; font-size: 10.5px; min-width: 68px; flex: 1 0 auto; }
  .main { padding: 22px 16px 110px; }
  .fab {
    display: grid; place-items: center;
    position: fixed; right: 16px; bottom: 84px; z-index: 45;
    width: 54px; height: 54px; border-radius: 50%; border: 0;
    background: var(--accent); color: var(--accent-ink);
    box-shadow: 0 10px 30px rgba(139, 124, 255, .35);
  }
  .fab .ico { width: 24px; height: 24px; }
  .grid-2, .grid-3 { grid-template-columns: minmax(0, 1fr); }
  .form-grid { grid-template-columns: 1fr 1fr; }
  .form-grid .span-2 { grid-column: 1 / -1; }
  .shots { grid-template-columns: 1fr; }
  .detail-grid { grid-template-columns: 1fr 1fr; }
  .page-head { margin-bottom: 22px; }
  .card { padding: 18px; border-radius: 16px; }
  .table-wrap { margin: 0 -18px; padding: 0 18px; }
  .toasts { left: 16px; right: 16px; bottom: 150px; }
}
@media (max-width: 640px) {
  .cal { grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 3px; }
  .cal-week { display: none; }
  .cal-dow.wk { display: none; }
  .cal-day { min-height: 58px; padding: 5px 4px; border-radius: 8px; overflow: hidden; }
  .cal-day .badges, .cal-day .cnt { display: none; }
  .cal-day .v { font-size: 9.5px; letter-spacing: -.03em; }
  .cal-toolbar h3 { display: none; }
  .cal-toolbar { justify-content: center; }
  .cal-dow { font-size: 9px; letter-spacing: .05em; }
  .modal-head, .modal-body, .modal-foot { padding-left: 16px; padding-right: 16px; }
  .modal-backdrop { padding: 0; }
  .modal { border-radius: 0; min-height: 100vh; border: 0; }
  .filters { grid-template-columns: 1fr; }
  .calc-out .hero b { font-size: 38px; }
  .metric b { font-size: 17px; }
}
