/* ==========================================================================
   EDGE Alpha — alpha.css
   Additive layer for /alpha pages. Loads AFTER spx-theme.css and only ever
   styles `alpha-`-prefixed classes, so nothing in the existing terminal moves.
   Colours come from the theme's Redesign V1 tokens; both themes are handled
   there, so this file has no prefers-color-scheme rules of its own.
   ========================================================================== */

/* ── 1. Page frame ───────────────────────────────────────────────────────── */
.alpha-page {
  color: var(--text);
  font-family: var(--font-sans, 'Inter', system-ui, sans-serif);
}

.alpha-titlebar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 20px;
}

.alpha-titlebar__text { flex: 1 1 auto; min-width: 0; }

.alpha-title {
  font-size: var(--fs-xl, 24px);
  font-weight: 700;
  color: var(--text);
  line-height: 1.2;
  letter-spacing: -0.01em;
}

.alpha-subtitle {
  font-size: var(--fs-sm, 12px);
  color: var(--text-muted);
  margin-top: 4px;
}

.alpha-titlebar__actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  flex-shrink: 0;
}

.alpha-lede {
  font-size: var(--fs-body, 14px);
  color: var(--text);
  line-height: 1.6;
  margin-bottom: 12px;
}

.alpha-muted { color: var(--text-muted); font-size: var(--fs-sm, 12px); }

.alpha-more { margin-top: 12px; font-size: var(--fs-sm, 12px); }
.alpha-more a { color: var(--link-text, var(--teal)); text-decoration: none; font-weight: 600; }
.alpha-more a:hover { text-decoration: underline; }

.alpha-empty {
  text-align: center;
  color: var(--text-muted);
  padding: 24px 12px;
  border: 1px dashed var(--border-strong);
  border-radius: var(--r-sm, 10px);
  font-size: var(--fs-sm, 12px);
}

.alpha-idea-id {
  font-size: var(--fs-md, 14px);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  margin: 4px 0 8px;
}

/* ── 2. Cards ────────────────────────────────────────────────────────────── */
.alpha-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg, 14px);
  padding: 16px 18px;
  margin-bottom: 16px;
}

.alpha-card__title {
  font-size: var(--fs-md, 14px);
  font-weight: 700;
  color: var(--text);
  margin-bottom: 12px;
}

.alpha-card__body { line-height: 1.55; color: var(--text); }

/* ── 3. Stats ────────────────────────────────────────────────────────────── */
.alpha-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
  margin-bottom: 20px;
}

.alpha-stat {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md, 12px);
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}

.alpha-stat__label {
  font-size: var(--fs-label, 12px);
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.alpha-stat__value {
  font-size: var(--fs-lg, 18px);
  font-weight: 700;
  color: var(--text);
  font-variant-numeric: tabular-nums;
  line-height: 1.2;
  word-break: break-word;
}

.alpha-stat__hint { font-size: var(--fs-label, 12px); color: var(--text-subtle, var(--text-muted)); }

/* ── 4. Tables ───────────────────────────────────────────────────────────── */
.alpha-tablewrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border: 1px solid var(--border);
  border-radius: var(--r-md, 12px);
  background: var(--surface);
}

.alpha-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: var(--fs-sm, 12px);
}

.alpha-table__th {
  padding: 10px 12px;
  text-align: left;
  font-size: var(--fs-label, 12px);
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-muted);
  background: var(--surface-2, var(--surface-muted));
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 2;
  white-space: nowrap;
}

.alpha-table tbody td {
  padding: 9px 12px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.alpha-table tbody tr:last-child td { border-bottom: none; }
.alpha-table tbody tr:hover td { background: var(--surface-2, var(--surface-muted)); }

.alpha-table__empty {
  text-align: center;
  color: var(--text-muted);
  padding: 40px 12px;
  font-size: var(--fs-sm, 12px);
  white-space: normal;
}

/* Key/value variant used for trade levels */
.alpha-levels td:first-child {
  width: 150px;
  color: var(--text-muted);
  font-weight: 500;
}

.alpha-levels__rr { margin-top: 12px; font-size: var(--fs-sm, 12px); color: var(--text-muted); }
.alpha-levels__rr strong { color: var(--text); font-weight: 700; }

/* ── 5. Badges, chips and pills ──────────────────────────────────────────── */
.alpha-badge,
.alpha-dir,
.alpha-verdict,
.alpha-score {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  border-radius: var(--r-pill, 999px);
  font-size: var(--fs-label, 12px);
  font-weight: 600;
  line-height: 1.45;
  padding: 2px 10px;
  white-space: nowrap;
  border: 1px solid transparent;
}

.alpha-badge { background: var(--surface-2, var(--surface-muted)); color: var(--text-muted); }

.alpha-badge--neutral,
.alpha-badge--muted {
  background: var(--surface-2, var(--surface-muted));
  color: var(--text-muted);
  border-color: var(--border);
}

.alpha-badge--info {
  background: color-mix(in srgb, var(--info-text, var(--blue-strong)) 10%, var(--surface));
  border-color: color-mix(in srgb, var(--info-text, var(--blue-strong)) 25%, var(--border));
  color: var(--info-text, var(--blue-strong));
}

.alpha-badge--good {
  background: color-mix(in srgb, var(--pos-text, var(--green-deep)) 10%, var(--surface));
  border-color: color-mix(in srgb, var(--pos-text, var(--green-deep)) 25%, var(--border));
  color: var(--pos-text, var(--green-deep));
}

.alpha-badge--accent {
  background: color-mix(in srgb, var(--link-text, var(--teal)) 10%, var(--surface));
  border-color: color-mix(in srgb, var(--link-text, var(--teal)) 25%, var(--border));
  color: var(--link-text, var(--teal));
}

.alpha-badge--bad {
  background: color-mix(in srgb, var(--neg-text, var(--red-deep)) 10%, var(--surface));
  border-color: color-mix(in srgb, var(--neg-text, var(--red-deep)) 25%, var(--border));
  color: var(--neg-text, var(--red-deep));
}

/* Direction chips: colour is never the only signal — the text says Лонг/Шорт */
.alpha-dir { font-weight: 700; }

.alpha-dir--long {
  background: color-mix(in srgb, var(--pos-text, var(--green-deep)) 12%, var(--surface));
  border-color: color-mix(in srgb, var(--pos-text, var(--green-deep)) 30%, var(--border));
  color: var(--pos-text, var(--green-deep));
}

.alpha-dir--short {
  background: color-mix(in srgb, var(--neg-text, var(--red-deep)) 12%, var(--surface));
  border-color: color-mix(in srgb, var(--neg-text, var(--red-deep)) 30%, var(--border));
  color: var(--neg-text, var(--red-deep));
}

.alpha-verdict--good {
  background: color-mix(in srgb, var(--pos-text, var(--green-deep)) 10%, var(--surface));
  border-color: color-mix(in srgb, var(--pos-text, var(--green-deep)) 25%, var(--border));
  color: var(--pos-text, var(--green-deep));
}

.alpha-verdict--neutral {
  background: var(--surface-2, var(--surface-muted));
  border-color: var(--border);
  color: var(--text-muted);
}

.alpha-verdict--bad {
  background: color-mix(in srgb, var(--neg-text, var(--red-deep)) 10%, var(--surface));
  border-color: color-mix(in srgb, var(--neg-text, var(--red-deep)) 25%, var(--border));
  color: var(--neg-text, var(--red-deep));
}

.alpha-score {
  background: color-mix(in srgb, var(--link-text, var(--teal)) 10%, var(--surface));
  border-color: color-mix(in srgb, var(--link-text, var(--teal)) 25%, var(--border));
  color: var(--link-text, var(--teal));
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.alpha-score--muted {
  background: var(--surface-2, var(--surface-muted));
  border-color: var(--border);
  color: var(--text-muted);
  font-weight: 600;
}

/* Demo label — deliberately reads as a label, never as a status */
.alpha-demo {
  display: inline-flex;
  align-items: center;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--text-muted);
  border: 1px dashed var(--border-strong);
  border-radius: var(--r-xs, 6px);
  padding: 1px 6px;
  background: transparent;
  white-space: nowrap;
}

.alpha-ticker,
.alpha-author {
  color: var(--link-text, var(--teal));
  text-decoration: none;
  font-weight: 600;
}

.alpha-ticker:hover,
.alpha-author:hover { text-decoration: underline; }

/* ── 6. Notices ──────────────────────────────────────────────────────────── */
.alpha-notice {
  display: block;
  padding: 10px 14px;
  border-left: 3px solid var(--info-text, var(--blue-strong));
  background: color-mix(in srgb, var(--info-text, var(--blue-strong)) 8%, var(--surface));
  color: var(--text);
  font-size: var(--fs-sm, 12px);
  border-radius: var(--r-sm, 10px);
  margin: 12px 0;
  line-height: 1.5;
}

.alpha-notice--muted {
  border-left-color: var(--text-muted);
  background: var(--surface-2, var(--surface-muted));
  color: var(--text-muted);
}

.alpha-notice--bad {
  border-left-color: var(--neg-text, var(--red-deep));
  background: color-mix(in srgb, var(--neg-text, var(--red-deep)) 8%, var(--surface));
}

.alpha-notice--good {
  border-left-color: var(--pos-text, var(--green-deep));
  background: color-mix(in srgb, var(--pos-text, var(--green-deep)) 8%, var(--surface));
}

/* ── 7. Buttons ──────────────────────────────────────────────────────────── */
.alpha-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 36px;
  padding: 0 16px;
  font-size: var(--fs-sm, 12px);
  font-weight: 600;
  font-family: inherit;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text);
  border-radius: var(--r-sm, 10px);
  cursor: pointer;
  transition: background .15s ease, border-color .15s ease, opacity .15s ease;
  text-decoration: none;
  white-space: nowrap;
  gap: 6px;
}

.alpha-btn:hover { background: var(--surface-2, var(--surface-muted)); }

.alpha-btn--primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--on-accent, #fff);
}

.alpha-btn--primary:hover { opacity: .9; background: var(--accent); border-color: var(--accent); }

.alpha-btn--ghost { background: transparent; border-color: var(--border-strong); color: var(--text); }
.alpha-btn--ghost:hover { background: var(--surface-2, var(--surface-muted)); }

.alpha-btn:disabled { opacity: .55; cursor: not-allowed; }
.alpha-btn:disabled:hover { background: var(--surface); }

.alpha-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin-top: 12px;
}

/* ── 8. Forms ────────────────────────────────────────────────────────────── */
.alpha-form {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px 12px;
  max-width: 560px;
  width: 100%;
  margin-top: 12px;
}

.alpha-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
  grid-column: 1 / -1;
}

/* number inputs pair up two per row on wide screens */
.alpha-form .alpha-field:has(input[type="number"]) { grid-column: span 1; }

.alpha-field__label {
  font-size: var(--fs-label, 12px);
  font-weight: 600;
  color: var(--text-muted);
}

.alpha-field__hint { font-size: var(--fs-label, 12px); color: var(--text-subtle, var(--text-muted)); }
.alpha-field__error { font-size: var(--fs-sm, 12px); color: var(--neg-text, var(--red-deep)); }
.alpha-field--invalid .alpha-input { border-color: var(--neg-text, var(--red-deep)); }

.alpha-input {
  width: 100%;
  min-height: 36px;
  padding: 8px 12px;
  font-size: var(--fs-sm, 12px);
  font-family: inherit;
  background: var(--surface-2, var(--surface-muted));
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--r-sm, 10px);
  outline: none;
  transition: border-color .15s ease;
}

.alpha-input:focus-visible {
  border-color: var(--accent);
  outline: 2px solid color-mix(in srgb, var(--accent) 35%, transparent);
  outline-offset: 1px;
}

textarea.alpha-input { resize: vertical; min-height: 84px; line-height: 1.5; }

.alpha-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: flex-end;
  margin-bottom: 16px;
  padding: 14px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg, 14px);
}

.alpha-filters .alpha-field { flex: 1 1 180px; min-width: 180px; grid-column: auto; }

.alpha-filters__actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

/* ── 9. Desk ─────────────────────────────────────────────────────────────── */
.alpha-desk {
  display: grid;
  grid-template-columns: minmax(220px, 260px) minmax(0, 1fr) minmax(260px, 340px);
  gap: 16px;
  align-items: start;
  margin-top: 12px;
}

.alpha-desk__queue {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg, 14px);
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: calc(100vh - 160px);
  overflow-y: auto;
}

.alpha-desk__item {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-left: 3px solid transparent;
  border-radius: var(--r-sm, 10px);
  text-decoration: none;
  color: var(--text);
  background: var(--surface);
  transition: border-color .15s ease, background .15s ease;
}

.alpha-desk__item:hover {
  border-color: var(--border-strong);
  background: var(--surface-2, var(--surface-muted));
}

.alpha-desk__item--active {
  border-left-color: var(--accent);
  border-color: var(--border-strong);
  background: var(--surface-2, var(--surface-muted));
}

.alpha-desk__ticker { font-weight: 700; font-variant-numeric: tabular-nums; }

.alpha-desk__main,
.alpha-desk__side { min-width: 0; }

.alpha-desk__head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 8px;
}

.alpha-desk__head h2 {
  font-size: var(--fs-md, 14px);
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.alpha-desk__author {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  font-size: var(--fs-sm, 12px);
  color: var(--text-muted);
  margin-bottom: 12px;
}

.alpha-desk__author-history {
  font-size: var(--fs-label, 12px);
  color: var(--text-subtle, var(--text-muted));
  flex-basis: 100%;
  margin-top: 4px;
}

.alpha-desk__actions {
  position: sticky;
  bottom: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md, 12px);
  padding: 12px;
  margin-top: 8px;
  z-index: 5;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

/* ── 10. Modal ───────────────────────────────────────────────────────────── */
.alpha-modal {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: color-mix(in srgb, var(--bg) 45%, #000);
  z-index: 1000;
}

.alpha-modal[hidden] { display: none !important; }

.alpha-modal__panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg, 14px);
  padding: 20px 22px;
  max-width: 520px;
  width: 100%;
  max-height: 85vh;
  overflow-y: auto;
}

.alpha-modal__title { font-size: var(--fs-md, 14px); font-weight: 700; margin-bottom: 14px; }

/* ── 11. Responsive ──────────────────────────────────────────────────────── */
@media (max-width: 1100px) {
  .alpha-desk { grid-template-columns: 1fr; }
  .alpha-desk__queue { max-height: none; }
  .alpha-desk__actions { position: static; }
}

@media (max-width: 760px) {
  .alpha-titlebar { flex-direction: column; align-items: flex-start; gap: 8px; }
  .alpha-titlebar__actions { width: 100%; justify-content: flex-start; }
  .alpha-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .alpha-form { grid-template-columns: 1fr; max-width: none; }
  .alpha-form .alpha-field:has(input[type="number"]) { grid-column: 1 / -1; }
  .alpha-table__th,
  .alpha-table tbody td { padding: 8px 10px; }
  .alpha-filters { padding: 12px; }
  .alpha-desk__queue { flex-direction: row; overflow-x: auto; padding: 8px; }
  .alpha-desk__item { min-width: 180px; flex-shrink: 0; }
}

/* ── Accessibility ───────────────────────────────────────────────────────── */
.alpha-page :focus-visible,
.alpha-modal :focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ── 12. Phase 1.1: вкладки, разделы, чекбоксы, демо-блок ───────────────── */
.alpha-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-bottom: 16px;
  border-bottom: 1px solid var(--border);
}

.alpha-tab {
  display: inline-flex;
  align-items: center;
  padding: 8px 14px;
  font-size: var(--fs-sm, 12px);
  font-weight: 600;
  color: var(--text-muted);
  text-decoration: none;
  border: 1px solid transparent;
  border-bottom: 2px solid transparent;
  border-radius: var(--r-sm, 10px) var(--r-sm, 10px) 0 0;
  margin-bottom: -1px;
}

.alpha-tab:hover { color: var(--text); background: var(--surface-2, var(--surface-muted)); }

.alpha-tab--active {
  color: var(--text);
  border-bottom-color: var(--accent);
  background: var(--surface);
}

.alpha-sectionhead { margin: 24px 0 12px; }

.alpha-sectionhead h2 {
  font-size: var(--fs-md, 14px);
  font-weight: 700;
  color: var(--text);
}

.alpha-sectionhead p {
  font-size: var(--fs-sm, 12px);
  color: var(--text-muted);
  margin-top: 4px;
}

/* Демо-блок отделён визуально, чтобы его нельзя было принять за реальные данные */
.alpha-demoblock {
  border-style: dashed;
  background: var(--surface-2, var(--surface-muted));
}

.alpha-demoblock .alpha-stat { background: var(--surface); border-style: dashed; }

.alpha-checks {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.alpha-check {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 12px;
  font-size: var(--fs-sm, 12px);
  border: 1px solid var(--border);
  border-radius: var(--r-sm, 10px);
  background: var(--surface-2, var(--surface-muted));
  cursor: pointer;
}

.alpha-check:hover { border-color: var(--border-strong); }
.alpha-check input { accent-color: var(--accent); margin: 0; }

.alpha-details { margin-top: 6px; font-size: var(--fs-sm, 12px); }

.alpha-details summary {
  cursor: pointer;
  color: var(--link-text, var(--teal));
  font-weight: 600;
}

.alpha-details > div,
.alpha-details > p {
  margin-top: 8px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--r-sm, 10px);
  background: var(--surface);
  white-space: normal;
  max-width: 520px;
}

.alpha-desk__queuehead {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
  font-size: var(--fs-label, 12px);
  color: var(--text-muted);
  padding: 0 2px 4px;
}

.alpha-desk__queuehead a { color: var(--link-text, var(--teal)); text-decoration: none; }
