:root {
  --bg: #0b0e12;
  --panel: #13171d;
  --panel-2: #171c24;
  --line: #262c36;
  --text: #e6e8eb;
  --muted: #7c8693;
  --long: #3dd68c;
  --short: #f2495c;
  --accent: #5b8def;
  --warn: #f2c14e;
}

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

body {
  background: var(--bg);
  color: var(--text);
  font-family: "JetBrains Mono", monospace;
  font-size: 13px;
  line-height: 1.5;
  min-height: 100vh;
  padding: 24px;
}

.wrap {
  max-width: 920px;
  margin: 0 auto;
}

/* ---------- Header ---------- */
header {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  margin-bottom: 20px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--line);
  flex-wrap: wrap;
  gap: 12px;
}
.brand {
  display: flex;
  align-items: baseline;
  gap: 10px;
  flex-wrap: wrap;
}
.brand h1 {
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 0.04em;
  white-space: nowrap;
}
.brand .sub {
  color: var(--muted);
  font-size: 11px;
  letter-spacing: 0.08em;
  white-space: nowrap;
}

.mode-toggle {
  display: flex;
  border: 1px solid var(--line);
  border-radius: 6px;
  overflow: hidden;
}
.mode-toggle button {
  background: var(--panel);
  color: var(--muted);
  border: none;
  font-family: inherit;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.06em;
  padding: 8px 18px;
  cursor: pointer;
  transition:
    background 0.15s,
    color 0.15s;
}
.mode-toggle button.active.long {
  background: rgba(61, 214, 140, 0.12);
  color: var(--long);
}
.mode-toggle button.active.short {
  background: rgba(242, 73, 92, 0.12);
  color: var(--short);
}
.mode-toggle button:not(.active):hover {
  color: var(--text);
}

/* ---------- Layout ---------- */
.grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}
@media (max-width: 760px) {
  .grid {
    grid-template-columns: 1fr;
  }
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px 18px;
}
.panel.full {
  grid-column: 1 / -1;
}

.panel h2 {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 12px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.panel h2 .tag {
  color: var(--accent);
  font-size: 10px;
}

/* ---------- Fields ---------- */
.field-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-bottom: 10px;
}
.field-row.two {
  grid-template-columns: repeat(2, 1fr);
}
@media (max-width: 480px) {
  .field-row,
  .field-row.two {
    grid-template-columns: 1fr 1fr;
  }
}

.field label {
  display: block;
  font-size: 10px;
  color: var(--muted);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  margin-bottom: 5px;
}
.field input {
  width: 100%;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 5px;
  color: var(--text);
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  padding: 8px 10px;
  transition: border-color 0.15s;
}
.field input:focus {
  outline: none;
  border-color: var(--accent);
}
.field input::-webkit-outer-spin-button,
.field input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}
.field input[type="number"] {
  -moz-appearance: textfield;
}

/* ---------- Output rows ---------- */
.out-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 6px 0;
  border-bottom: 1px solid var(--line);
  font-size: 12.5px;
}
.out-row:last-child {
  border-bottom: none;
}
.out-row .k {
  color: var(--muted);
}
.out-row .v {
  font-weight: 700;
  font-size: 14px;
}
.v.pos {
  color: var(--long);
}
.v.neg {
  color: var(--short);
}
.v.acc {
  color: var(--accent);
}
.v.warn {
  color: var(--warn);
}

/* ---------- RRR gauge (signature element) ---------- */
.rrr-block {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 4px;
}
.rrr-label {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
}
.rrr-label .val {
  font-size: 28px;
  font-weight: 700;
  line-height: 1;
}
.rrr-label .desc {
  font-size: 11px;
  color: var(--muted);
  letter-spacing: 0.04em;
}
.gauge-track {
  height: 8px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 4px;
  overflow: hidden;
  position: relative;
}
.gauge-fill {
  height: 100%;
  border-radius: 4px;
  transition:
    width 0.25s ease,
    background 0.25s ease;
  width: 0%;
}
.gauge-ticks {
  display: flex;
  justify-content: space-between;
  font-size: 9px;
  color: var(--muted);
  letter-spacing: 0.04em;
}

/* ---------- Tranches ---------- */
.tranche-table {
  width: 100%;
  border-collapse: collapse;
}
.tranche-table th {
  text-align: left;
  font-size: 10px;
  color: var(--muted);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 0 8px 8px 0;
  border-bottom: 1px solid var(--line);
}
.tranche-table td {
  padding: 6px 8px 6px 0;
  border-bottom: 1px solid var(--line);
}
.tranche-table tr:last-child td {
  border-bottom: none;
}
.tranche-table input {
  width: 100%;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 5px;
  color: var(--text);
  font-family: inherit;
  font-size: 12.5px;
  font-weight: 600;
  padding: 6px 8px;
}
.tranche-table input:focus {
  outline: none;
  border-color: var(--accent);
}
.tranche-table .calc {
  font-weight: 700;
  color: var(--text);
  white-space: nowrap;
}

@media (max-width: 560px) {
  .tranche-table thead {
    display: none;
  }
  .tranche-table,
  .tranche-table tbody,
  .tranche-table tr,
  .tranche-table td {
    display: block;
    width: 100%;
  }
  .tranche-table tr {
    border-bottom: 1px solid var(--line);
    padding: 10px 0;
  }
  .tranche-table tr:last-child {
    border-bottom: none;
  }
  .tranche-table td {
    padding: 4px 0;
    border-bottom: none;
  }
  .tranche-table td:first-child {
    font-weight: 700;
    color: var(--accent);
    font-size: 11px;
    letter-spacing: 0.08em;
    text-transform: uppercase;
  }
  .tranche-table td:not(:first-child)::before {
    content: attr(data-label);
    display: block;
    font-size: 10px;
    color: var(--muted);
    letter-spacing: 0.06em;
    text-transform: uppercase;
    margin-bottom: 4px;
  }
  .tranche-table .calc {
    font-size: 16px;
    padding-top: 2px;
  }
}

/* ---------- Footer note ---------- */
.note {
  color: var(--muted);
  font-size: 11px;
  line-height: 1.6;
  margin-top: 4px;
}
.note b {
  color: var(--text);
}

footer {
  text-align: center;
  color: var(--muted);
  font-size: 10px;
  letter-spacing: 0.08em;
  margin-top: 24px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}

/* ---------- utility ---------- */
.hint {
  font-size: 10px;
  color: var(--muted);
  margin-top: 6px;
}
