/* ============================================================
   FinToolbox — Margin & Leverage Calculator (tool-specific)
   Global/shared styles (.card .fld .input .bk .btn .tag …) live in
   /css/styles.css. The tab pattern is ported from security-shield.css
   under a local .m-tab namespace so the two tools stay independent.
   ============================================================ */

/* The hidden attribute must beat any display:flex/grid on conditional reveal
   targets (panels, exchange warning tag, etc). */
.margin-tool [hidden] { display: none !important; }

/* Visually-hidden heading used to bridge the H1 → H3 outline (one per panel).
   Visible to crawlers and screen readers; absent from layout / pointer events. */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* ---------- Tab strip ---------- */
.m-tabs {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
  border-bottom: 1px solid var(--line);
  margin-bottom: 18px;
}
.m-tab {
  appearance: none;
  background: none;
  border: none;
  cursor: pointer;
  padding: 10px 18px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-3);
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  border-radius: 6px 6px 0 0;
}
.m-tab:hover { color: var(--text); background: var(--card-hi); }
.m-tab.on { color: var(--text); border-bottom-color: var(--green); }
.m-tab:focus-visible { outline: 2px solid var(--green); outline-offset: 2px; }

.m-panel { display: none; }
.m-panel.on { display: block; }

/* ---------- Input grid (each tab body) ---------- */
.m-form {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}
@media (max-width: 560px) { .m-form { grid-template-columns: 1fr; } }

/* Leverage field gets a row with input + risk badge on the right. */
.m-lev-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.m-lev-row .wrap { flex: 1 1 auto; min-width: 120px; }
.m-lev-row .tag { white-space: nowrap; }

/* Exchange limit chip lives right under the leverage row. */
.m-exchange-row {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
  margin-top: 6px;
  font-size: 11.5px;
  color: var(--text-3);
}
.m-exchange-row select {
  background: var(--card);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 4px 8px;
  font-size: 11.5px;
}

/* ---------- Output (re-use .bk from styles.css) ---------- */
.m-out h3 { margin: 0 0 10px; font-size: 14px; font-weight: 700; }
/* Breathing room on the result column so the numbers don't kiss the card edge. */
.m-out .bk .v,
.m-out .bk .tag { padding-right: 10px; }

/* Risk warning box — neutral card with a red accent stripe. */
.m-warning {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  padding: 14px 16px;
  border-radius: 10px;
  background: color-mix(in srgb, var(--red) 7%, var(--card));
  border: 1px solid color-mix(in srgb, var(--red) 25%, transparent);
  font-size: 12.5px;
  color: var(--text-2);
  line-height: 1.5;
}
.m-warning .icon {
  flex: 0 0 auto;
  width: 22px; height: 22px;
  border-radius: 50%;
  display: grid; place-items: center;
  background: var(--red);
  color: #fff;
  font-weight: 700;
  font-size: 13px;
}

/* Inline note for "no liquidation at 1×" */
.m-liq-note {
  margin: 8px 0 0;
  font-size: 11.5px;
  color: var(--text-3);
  font-style: italic;
}

/* ---------- Cross-link card pair ---------- */
.m-cross {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
@media (max-width: 560px) { .m-cross { grid-template-columns: 1fr; } }
.m-cross .card { padding: 14px 16px; }
.m-cross h4 { margin: 0 0 4px; font-size: 13px; }
.m-cross p { margin: 0 0 8px; font-size: 12.5px; color: var(--text-2); line-height: 1.55; }
