* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: 'Segoe UI', system-ui, sans-serif;
  background: #0d0d1a;
  color: #e2e8f0;
  min-height: 100vh;
  padding: 24px;
}

/* ── Header ── */
.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 28px;
}
.header h1 { font-size: 1.4rem; font-weight: 700; letter-spacing: .5px; }
.header h1 span { color: #7c3aed; }
.meta { font-size: .78rem; color: #64748b; text-align: right; line-height: 1.6; }
.meta b { color: #94a3b8; }

/* ── Strategy cards ── */
.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 16px;
  margin-bottom: 28px;
  align-items: start;
}
@media (max-width: 640px) { .cards { grid-template-columns: 1fr; } }

.card {
  background: #131325;
  border: 1px solid #1e1e3a;
  border-radius: 14px;
  padding: 20px;
  position: relative;
  overflow: hidden;
  transition: border-color .2s;
}
.card:hover { border-color: #2d2d5a; }
.card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: var(--accent);
  border-radius: 14px 14px 0 0;
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}
.card-title { font-size: 1rem; font-weight: 600; }
.card-emoji { font-size: 1.3rem; margin-right: 8px; }

.badge {
  font-size: .7rem;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 20px;
  letter-spacing: .4px;
}
.badge-running { background: #052e16; color: #4ade80; }
.badge-stopped { background: #1c1c1c; color: #64748b; }

.card-header-right { display: flex; align-items: center; gap: 8px; }

.stat-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 7px 0;
  border-bottom: 1px solid var(--row-border, #1a1a2e);
  font-size: .85rem;
}
.stat-row:last-child { border-bottom: none; }
.stat-label { color: #64748b; }
.stat-value { font-weight: 600; font-variant-numeric: tabular-nums; }

.pos  { color: #13b847; }
.neg  { color: #d24343; }
.neu  { color: #6d8dba; }

.scan-info {
  margin-top: 14px;
  font-size: .72rem;
  color: #3d3d6b;
}


/* ── Claude usage ── */
.claude-box {
  background: #131325;
  border: 1px solid #1e1e3a;
  border-radius: 14px;
  padding: 18px 20px;
  margin-bottom: 28px;
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0 24px;
  align-items: start;
  margin-top: 20px;
}
.claude-title {
  grid-column: 1 / -1;
  font-size: .85rem;
  font-weight: 700;
  color: #94a3b8;
  margin-bottom: 14px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.claude-title span { color: #a78bfa; }
.claude-cols {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
}
@media (max-width: 640px) { .claude-cols { grid-template-columns: repeat(2, 1fr); } }
.claude-stat {
  background: #0f0f20;
  border-radius: 10px;
  padding: 12px 14px;
}
.claude-stat-label { font-size: .68rem; color: #475569; text-transform: uppercase; letter-spacing: .5px; margin-bottom: 4px; }
.claude-stat-value { font-size: 1rem; font-weight: 700; color: #e2e8f0; font-variant-numeric: tabular-nums; }
.claude-stat-sub   { font-size: .72rem; color: #64748b; margin-top: 2px; }
.claude-models { grid-column: 1 / -1; margin-top: 10px; font-size: .75rem; color: #475569; display: flex; gap: 16px; flex-wrap: wrap; }
.claude-model-pill { background: #0f0f20; border-radius: 8px; padding: 4px 10px; }
.claude-model-pill b { color: #a78bfa; }

/* ── Positions table ── */
.section-title {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 14px;
  color: #94a3b8;
  display: flex;
  align-items: center;
  gap: 8px;
}
.count-badge {
  background: #1e1e3a;
  color: #7c3aed;
  font-size: 1rem;
  padding: 2px 8px;
  border-radius: 20px;
  font-weight: 700;
}

.table-wrap {
  background: #131325;
  border: 1px solid #1e1e3a;
  border-radius: 14px;
  overflow: hidden;
}
table { width: 100%; border-collapse: collapse; font-size: .83rem; }
thead tr { background: #0f0f20; }
th {
  text-align: left;
  padding: 11px 16px;
  color: #475569;
  font-weight: 600;
  font-size: .75rem;
  letter-spacing: .6px;
  text-transform: uppercase;
}
td { padding: 12px 16px; border-top: 1px solid #1a1a2e; vertical-align: middle; }
tr:hover td { background: #161628; }

.strategy-pill {
  font-size: .7rem;
  font-weight: 600;
  padding: 2px 9px;
  border-radius: 12px;
  white-space: nowrap;
}

.question-cell { max-width: 280px; }
.question-text { font-size: .82rem; line-height: 1.4; }
.question-side {
  font-size: .68rem;
  font-weight: 700;
  margin-top: 3px;
  color: #94a3b8;
}

.price-cell { font-variant-numeric: tabular-nums; white-space: nowrap; }
.arrow { color: #475569; margin: 0 4px; }

.days-left { font-size: .75rem; color: #64748b; }

/* ── Mobile: table → cards ── */
@media (max-width: 640px) {
  body { padding: 12px; }
  .cards { grid-template-columns: 1fr; }

  .table-wrap { background: transparent; border: none; border-radius: 0; overflow: visible; }
  table, thead, tbody, th, td, tr { display: block; width: 100%; }
  thead { display: none; }

  tbody tr {
    background: #131325;
    border: 1px solid #1e1e3a;
    border-radius: 12px;
    margin-bottom: 10px;
    overflow: hidden;
  }
  tr.row-profit { background: #091a0e; border-color: #0f3320; }
  tr.row-loss   { background: #1a0909; border-color: #33100f; }
  tbody tr:hover td { background: transparent !important; }

  tbody td {
    position: relative;
    display: block;
    padding: 8px 14px 8px 90px;
    border-top: 1px solid #1a1a2e;
    font-size: .83rem;
    text-align: right;
    line-height: 1.5;
    background: transparent !important;
  }
  tbody td:first-child { border-top: none; }
  tbody td:not([data-label]) { padding-left: 14px; }

  tbody td::before {
    content: attr(data-label);
    position: absolute;
    left: 14px;
    top: 9px;
    color: #475569;
    font-size: .68rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .5px;
    white-space: nowrap;
  }
  tbody td[data-label=""] { padding-left: 14px; padding-top: 10px; padding-bottom: 12px; text-align: right; }
  tbody td[data-label=""]::before { display: none; }

  .question-cell  { max-width: 100%; }
  .question-text  { text-align: right; font-size: .8rem; line-height: 1.4; }
  .question-side  { text-align: right; }
  .price-cell     { text-align: right; }
  .days-left      { text-align: right; }
}

.btn-close {
  background: rgba(248,113,113,.10);
  border: 1px solid rgba(248,113,113,.35);
  color: #fca5a5;
  font-size: .73rem;
  font-weight: 600;
  padding: 5px 14px;
  border-radius: 8px;
  cursor: pointer;
  white-space: nowrap;
  transition: background .15s, border-color .15s, color .15s;
}
.btn-close:hover  { background: rgba(248,113,113,.22); border-color: #f87171; color: #fff; }
.btn-close:active { background: rgba(248,113,113,.32); }
.btn-close:disabled { opacity: .35; cursor: not-allowed; }

.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: #131325;
  border: 1px solid #2d2d5a;
  border-radius: 10px;
  padding: 10px 20px;
  font-size: .83rem;
  opacity: 0;
  pointer-events: none;
  transition: opacity .25s;
  z-index: 999;
}
.toast.show { opacity: 1; }
.toast.ok  { border-color: #4ade80; color: #4ade80; }
.toast.err { border-color: #f87171; color: #f87171; }

.empty-state {
  text-align: center;
  padding: 40px;
  color: #334155;
  font-size: .9rem;
}

/* ── Spinner / refresh ── */
.refresh-dot {
  display: inline-block;
  width: 7px; height: 7px;
  background: #4ade80;
  border-radius: 50%;
  margin-right: 6px;
  animation: pulse 2s infinite;
}
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: .3; }
}

/* ── Claude header pills ── */
.claude-header {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  justify-content: center;
}
.claude-pill {
  background: #0f0f20;
  border: 1px solid #1e1e3a;
  border-radius: 8px;
  padding: 4px 10px;
  font-size: .72rem;
  color: #64748b;
  white-space: nowrap;
  line-height: 1.4;
}
.claude-pill b { color: #a78bfa; }
.claude-pill .pos { color: #4ade80; }
@media (max-width: 860px) { .claude-header { display: none; } }

.error-bar {
  background: #2d0a0a;
  border: 1px solid #7f1d1d;
  color: #fca5a5;
  border-radius: 10px;
  padding: 10px 16px;
  margin-bottom: 20px;
  font-size: .83rem;
  display: none;
}

/* ── P&L row tints ── */
tr.row-profit > td { background: #091a0e; }
tr.row-loss   > td { background: #1a0909; }
tr.row-profit:hover > td { background: #0f3320; }
tr.row-loss:hover   > td { background: #33100f; }
tr.row-profit > td:first-child { border-left: 3px solid #4ade80; padding-left: 13px; }
tr.row-loss   > td:first-child { border-left: 3px solid #f87171; padding-left: 13px; }

/* ── History section ── */
.history-toggle {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 28px;
  margin-bottom: 0;
  padding: 12px 18px;
  background: #131325;
  border: 1px solid #1e1e3a;
  border-radius: 14px;
  cursor: pointer;
  font-size: .9rem;
  font-weight: 600;
  color: #64748b;
  user-select: none;
  transition: border-color .2s, color .2s;
}
.history-toggle:hover { border-color: #2d2d5a; color: #94a3b8; }
.history-toggle.open  { border-radius: 14px 14px 0 0; border-bottom-color: transparent; color: #94a3b8; }
.history-arrow { margin-left: auto; font-size: .7rem; transition: transform .2s; }
.history-toggle.open .history-arrow { transform: rotate(180deg); }

#historySection {
  background: #131325;
  border: 1px solid #1e1e3a;
  border-top: none;
  border-radius: 0 0 14px 14px;
  overflow: hidden;
  margin-bottom: 28px;
}

.result-badge {
  font-size: .68rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 8px;
  white-space: nowrap;
}
.result-tp     { background: #052e16; color: #4ade80; }
.result-sl     { background: #2d0a0a; color: #f87171; }
.result-time   { background: #1a1a1a; color: #64748b; }
.result-manual { background: #1a1530; color: #a78bfa; }

/* ── Card chart ── */
.card-chart-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 12px;
  padding-top: 8px;
  border-top: 1px solid var(--row-border, #1a1a2e);
  cursor: pointer;
  font-size: .72rem;
  color: #334155;
  user-select: none;
  transition: color .15s;
}
.card-chart-toggle:hover { color: #64748b; }
.card-chart-toggle.open  { color: #64748b; }
.card-chart-arrow { font-size: .6rem; transition: transform .2s; }
.card-chart-toggle.open .card-chart-arrow { transform: rotate(180deg); }

.card-chart-panel {
  margin: 12px -20px -20px;
  padding: 12px 14px 14px;
  border-top: 1px solid var(--row-border, #1a1a2e);
}
.card-chart-wrap {
  position: relative;
  height: 140px;
}
.card-chart-empty {
  height: 140px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #334155;
  font-size: .78rem;
}

tr.row-profit .btn-close {
  background: rgba(74,222,128,.10);
  border-color: rgba(74,222,128,.35);
  color: #86efac;
}
tr.row-profit .btn-close:hover {
  background: rgba(74,222,128,.22);
  border-color: #4ade80;
  color: #fff;
}

/* ── Strategy group header row ── */
.group-header > td {
  background: #0b0b18;
  padding: 7px 16px;
  border-top: 1px solid #1e1e3a;
  border-bottom: 1px solid #1e1e3a;
  font-size: .72rem;
  font-weight: 700;
  letter-spacing: .5px;
  text-transform: uppercase;
  color: #475569;
}
.group-header:first-child > td { border-top: none; }
