/* ═══════════════════════════════════════════════════════
   BOND PAIR TRADE CALCULATOR — styles.css
   3-column layout, max-width 1400px, dark theme
   ═══════════════════════════════════════════════════════ */

:root {
  --bg:           #0d0f14;
  --bg2:          #141720;
  --bg3:          #1a1e28;
  --border:       #252936;
  --border2:      #2e3347;
  --text:         #e8eaf2;
  --text-dim:     #7a8099;
  --text-mute:    #4a5068;
  --accent-long:  #4d9fff;
  --accent-short: #ff6b6b;
  --accent-neut:  #a0aec0;
  --profit:       #48bb78;
  --loss:         #fc8181;
  --gold:         #f6c90e;
  --mono:         'IBM Plex Mono', monospace;
  --sans:         'Heebo', sans-serif;
  --radius:       10px;
  --shadow:       0 2px 16px rgba(0,0,0,0.4);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 14px; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  direction: rtl;
  min-height: 100vh;
  line-height: 1.5;
}

/* ── HEADER ── */
.header {
  background: var(--bg2);
  border-bottom: 1px solid var(--border);
  padding: 14px 0;
}
.header-inner {
  max-width: 1400px;
  margin: 0 auto;
  padding: 0 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}
.header-left { display: flex; flex-direction: column; gap: 4px; }
.header-right { display: flex; align-items: center; gap: 12px; flex-shrink: 0; }

.badge {
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.15em;
  color: var(--text-mute);
  text-transform: uppercase;
}

h1 {
  font-size: 20px;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 10px;
}
.long-tag  { color: var(--accent-long); }
.short-tag { color: var(--accent-short); }
.hdr-x { color: var(--text-mute); font-weight: 300; }

.subtitle { font-size: 12px; color: var(--text-dim); }

.last-update { font-family: var(--mono); font-size: 11px; color: var(--text-mute); }

.btn {
  padding: 7px 14px;
  border-radius: 6px;
  border: 1px solid var(--border2);
  background: var(--bg3);
  color: var(--text);
  font-family: var(--sans);
  font-size: 12px;
  cursor: pointer;
  transition: background .15s, border-color .15s;
}
.btn:hover { background: var(--border); border-color: var(--text-mute); }
.btn-reset { border-color: var(--border2); }

/* ── MAIN GRID: 3 equal columns ── */
.main-grid {
  max-width: 1400px;
  margin: 0 auto;
  padding: 16px 20px;
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 14px;
}

.card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
}

.col-stack {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

/* Full-width rows */
.full-row {
  grid-column: 1 / -1;
}

/* Card accent borders */
.card-long  { border-top: 2px solid var(--accent-long); }
.card-short { border-top: 2px solid var(--accent-short); }
.card-params { border-top: 2px solid var(--text-mute); }

.card-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-dim);
  margin-bottom: 12px;
}

.dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--text-mute);
  flex-shrink: 0;
}
.dot-long  { background: var(--accent-long); }
.dot-short { background: var(--accent-short); }

/* ── BOND SEARCH ── */
.bond-search-row {
  display: flex;
  gap: 6px;
  margin-bottom: 12px;
}
.bond-id {
  flex: 1;
  background: var(--bg3);
  border: 1px solid var(--border2);
  border-radius: 6px;
  color: var(--text);
  font-family: var(--mono);
  font-size: 13px;
  padding: 6px 10px;
  direction: ltr;
  text-align: center;
  transition: border-color .15s;
}
.bond-id:focus { outline: none; border-color: var(--accent-long); }

.btn-fetch {
  padding: 6px 12px;
  border-radius: 6px;
  border: 1px solid var(--border2);
  background: var(--bg3);
  color: var(--text-dim);
  font-size: 12px;
  cursor: pointer;
  white-space: nowrap;
  transition: all .15s;
}
.btn-fetch-long:hover  { border-color: var(--accent-long);  color: var(--accent-long); }
.btn-fetch-short:hover { border-color: var(--accent-short); color: var(--accent-short); }
.btn-fetch.loading { opacity: 0.5; pointer-events: none; }

/* Flash animation when field updates */
@keyframes fieldFlash {
  0%   { background: rgba(77,159,255,0.3); }
  100% { background: transparent; }
}
.flash { animation: fieldFlash 0.8s ease-out; }
.flash-short { animation: fieldFlash 0.8s ease-out; }
@keyframes fieldFlashShort {
  0%   { background: rgba(255,107,107,0.3); }
  100% { background: transparent; }
}
input.flash-short { animation: fieldFlashShort 0.8s ease-out; }

/* ── FIELDS ── */
.field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 10px;
}

.field { display: flex; flex-direction: column; gap: 4px; }

.field-info { justify-content: center; }

label {
  font-size: 10px;
  font-weight: 600;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.num-wrap {
  display: flex;
  align-items: stretch;
  background: var(--bg3);
  border: 1px solid var(--border2);
  border-radius: 6px;
  overflow: hidden;
  transition: border-color .15s;
}
.num-wrap:focus-within { border-color: var(--text-mute); }

.num-wrap input[type="number"] {
  flex: 1;
  background: transparent;
  border: none;
  color: var(--text);
  font-family: var(--mono);
  font-size: 13px;
  padding: 6px 8px;
  text-align: center;
  outline: none;
  min-width: 0;
  -moz-appearance: textfield;
}
.num-wrap input[type="number"]::-webkit-inner-spin-button,
.num-wrap input[type="number"]::-webkit-outer-spin-button { -webkit-appearance: none; }

.computed { color: var(--text-dim) !important; cursor: default; }
.computed-long  { color: var(--accent-long)  !important; font-weight: 600; }
.computed-short { color: var(--accent-short) !important; font-weight: 600; }

.spins {
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--border2);
}
.spins button {
  flex: 1;
  background: transparent;
  border: none;
  color: var(--text-mute);
  font-size: 8px;
  cursor: pointer;
  padding: 0 5px;
  transition: color .1s, background .1s;
  line-height: 1;
}
.spins button:hover { color: var(--text); background: var(--border); }
.spins.disabled { opacity: 0.2; pointer-events: none; }

/* ── INFO CHIP ── */
.info-chip {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: 20px;
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 600;
  border: 1px solid;
}
.chip-long  { color: var(--accent-long);  border-color: rgba(77,159,255,0.3);  background: rgba(77,159,255,0.07); }
.chip-short { color: var(--accent-short); border-color: rgba(255,107,107,0.3); background: rgba(255,107,107,0.07); }
.info-sub { font-size: 10px; color: var(--text-mute); margin-top: 3px; }

/* ── SEP ── */
.sep { height: 1px; background: var(--border); margin: 12px 0; }

/* ── MULTIPLIER ── */
.mult-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
}
.mult-lbl { font-size: 11px; font-weight: 600; color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.06em; }
.mult-val { font-family: var(--mono); font-size: 18px; font-weight: 700; color: var(--accent-short); }

/* ── SLIDERS ── */
input[type="range"] {
  width: 100%;
  -webkit-appearance: none;
  height: 4px;
  border-radius: 2px;
  background: var(--border2);
  outline: none;
  cursor: pointer;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 16px; height: 16px;
  border-radius: 50%;
  background: var(--text);
  border: 2px solid var(--bg2);
  box-shadow: 0 0 4px rgba(0,0,0,0.5);
  cursor: pointer;
}

.range-ticks {
  display: flex;
  justify-content: space-between;
  margin-top: 4px;
  padding: 0 2px;
}
.tick {
  display: flex;
  flex-direction: column;
  align-items: center;
  cursor: pointer;
  gap: 2px;
}
.tick-line { width: 1px; height: 5px; background: var(--border2); }
.tick-lbl  { font-size: 9px; color: var(--text-mute); font-family: var(--mono); }
.tick.active .tick-line { background: var(--accent-short); }
.tick.active .tick-lbl  { color: var(--accent-short); }

/* ── PERIOD SLIDER ── */
.period-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}
.period-lbl { font-size: 11px; font-weight: 600; color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.06em; }
.period-val { font-family: var(--mono); font-size: 16px; font-weight: 700; color: var(--text); }

.period-ticks {
  display: flex;
  justify-content: space-between;
  margin-top: 4px;
  padding: 0 2px;
}
.ptick {
  display: flex;
  flex-direction: column;
  align-items: center;
  cursor: pointer;
  gap: 2px;
}
.ptick-line { width: 1px; height: 5px; background: var(--border2); }
.ptick-lbl  { font-size: 9px; color: var(--text-mute); font-family: var(--mono); }
.ptick.active .ptick-line { background: var(--text); }
.ptick.active .ptick-lbl  { color: var(--text); }
.ptick.maturity .ptick-line { background: var(--accent-short); height: 7px; }
.ptick.maturity .ptick-lbl  { color: var(--accent-short); }

.period-info {
  font-size: 11px;
  color: var(--text-dim);
  margin-top: 6px;
  line-height: 1.6;
}

/* ── PARAMS 2-COL ── */
.params-2col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

/* ── RESULTS ── */
.res-grid {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr 1fr;
  gap: 8px;
  margin-bottom: 10px;
}

.annual-strip {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 10px;
}

.ri { display: flex; flex-direction: column; gap: 2px; }
.rl { font-size: 10px; color: var(--text-dim); font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; }
.rs { font-size: 10px; color: var(--text-mute); margin-top: 2px; }

.rv {
  font-family: var(--mono);
  font-size: 19px;
  font-weight: 700;
  line-height: 1.2;
  color: var(--text-dim);
}
.rv.positive { color: var(--profit); }
.rv.negative { color: var(--loss); }
.rv.gold     { color: var(--gold); }
.rv.neutral  { color: var(--text-dim); }

/* ── HINT ── */
.hint {
  font-size: 11px;
  color: var(--text-mute);
  padding: 8px 10px;
  background: var(--bg3);
  border-radius: 6px;
  border: 1px solid var(--border);
  line-height: 1.6;
}

/* ── BREAKDOWN ── */
.bd-table { display: flex; flex-direction: column; gap: 1px; }

.bd-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 5px 10px;
  border-radius: 5px;
  transition: background .1s;
}
.bd-row:hover { background: rgba(255,255,255,0.02); }
.bd-row.bd-total { background: rgba(77,159,255,0.05); border: 1px solid rgba(77,159,255,0.1); margin: 2px 0; }
.bd-row.bd-note { opacity: 0.65; }
.bd-row.bd-note .bd-name { font-size: 10px; color: var(--text-mute); }

.bd-sep { height: 1px; background: var(--border); margin: 4px 0; }
.bd-name { font-size: 12px; color: var(--text-dim); }
.bd-val  { font-family: var(--mono); font-size: 12px; font-weight: 600; text-align: left; }
.bd-val.pos { color: var(--profit); }
.bd-val.neg { color: var(--loss); }

/* ── CHARTS ── */
.charts-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}
.chart-wide { grid-column: 1 / -1; }

.chart-wrap { display: flex; flex-direction: column; gap: 6px; }
.chart-title {
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.chart-sub { font-size: 10px; color: var(--text-mute); font-weight: 400; }
.chart-note { font-size: 10px; color: var(--text-mute); min-height: 16px; }

canvas { max-height: 220px; }

/* ── TOAST ── */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--bg3);
  border: 1px solid var(--border2);
  color: var(--text);
  padding: 10px 20px;
  border-radius: 8px;
  font-size: 13px;
  opacity: 0;
  transition: opacity .3s, transform .3s;
  pointer-events: none;
  z-index: 999;
  white-space: nowrap;
  box-shadow: var(--shadow);
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.err  { border-color: var(--accent-short); color: var(--loss); }

/* ── FOOTER ── */
.footer-note {
  max-width: 1400px;
  margin: 0 auto 24px;
  padding: 0 20px;
  font-size: 10px;
  color: var(--text-mute);
  line-height: 1.8;
}

/* ── RESPONSIVE ── */
@media (max-width: 900px) {
  .main-grid { grid-template-columns: 1fr 1fr; }
  .card-params { grid-column: 1 / -1; }
}
@media (max-width: 600px) {
  .main-grid { grid-template-columns: 1fr; }
  .field-row { grid-template-columns: 1fr; }
  .res-grid  { grid-template-columns: 1fr 1fr; }
  .charts-grid { grid-template-columns: 1fr; }
  h1 { font-size: 16px; }
}