/* Конвертер валют — web-calculator.ru. Scoped под #cv-calc. Дизайн-система inputs-style.css. */

/* Единый шрифт Unbounded sans-serif — перебиваем serif из inputs-style */
#cv-calc, #cv-calc .calculator,
#cv-calc input, #cv-calc select, #cv-calc button, #cv-calc textarea,
#cv-calc .label-text, #cv-calc .tax-result span,
#cv-calc .tax-result .amount-group span, #cv-calc .amount-group span:first-child {
  font-family: "Unbounded", sans-serif;
}
#cv-calc .calculator { color: #000; }
#cv-calc [hidden] { display: none !important; }

/* ── Переключатель источника (ЦБ / MOEX) ────────────────────── */
#cv-calc .cv-sourcebar { display: flex; gap: 6px; margin-bottom: 12px; }
#cv-calc .cv-src-tab {
  flex: 1; padding: 11px 8px; border: 1px solid #ddd; border-radius: 12px; background: #fff; color: #000;
  font-family: "Unbounded", sans-serif; font-size: 12px; cursor: pointer; transition: .15s;
}
#cv-calc .cv-src-tab:hover { border-color: #bbb; background: #fafafa; }
#cv-calc .cv-src-tab.is-active { border-color: #000; box-shadow: inset 0 0 0 1px #000; }
#cv-calc .cv-src-note {
  margin: -4px 0 12px; font-size: 11px; line-height: 1.5; color: #8a5a00;
  background: #fff7e6; border: 1px solid #ffe0a3; border-radius: 12px; padding: 10px 14px;
}

/* ── Строка источника курса ─────────────────────────────────── */
#cv-calc .cv-mode-row {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  flex-wrap: wrap; margin-bottom: 12px;
}
#cv-calc .cv-source { font-size: 12px; opacity: .7; }
#cv-calc .cv-source b, #cv-calc #cv-date { font-weight: 600; opacity: 1; }
#cv-calc .cv-datebtn {
  width: auto; padding: 7px 12px; border: 1px solid #ddd; border-radius: 20px; background: #fff; color: #000;
  font-family: "Unbounded", sans-serif; font-size: 11px; cursor: pointer;
}
#cv-calc .cv-datebtn:hover { border-color: #000; }
#cv-calc .cv-datebtn.is-active { border-color: #000; box-shadow: inset 0 0 0 1px #000; }
#cv-calc .cv-date-wrap { display: flex; gap: 8px; align-items: flex-end; margin-bottom: 12px; flex-wrap: wrap; }
#cv-calc .cv-date-wrap .form-group { flex: 1 1 200px; margin-bottom: 0; }
#cv-calc .cv-date-wrap input[type="date"] {
  font-size: 12px; height: 64px; padding: 22px 16px 6px; margin-bottom: 0;
  -webkit-appearance: none; appearance: none; text-align: left;
}
#cv-calc .cv-date-reset {
  width: auto; height: 42px; padding: 0 16px; border: 1px solid #ddd; border-radius: 12px; background: #fff; color: #000;
  font-family: "Unbounded", sans-serif; font-size: 11px; cursor: pointer; white-space: nowrap;
}
#cv-calc .cv-date-reset:hover { border-color: #000; }

/* ── Блок конвертации ───────────────────────────────────────── */
#cv-calc .cv-convert {
  display: grid; grid-template-columns: 1fr auto 1fr; gap: 8px; align-items: start; margin-bottom: 10px;
}
#cv-calc .cv-side { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
#cv-calc .cv-side .form-group { margin-bottom: 0; }
#cv-calc .cv-side .form-group input {
  font-size: 16px; font-weight: 600; height: 64px; margin-bottom: 0; text-align: left; padding-left: 16px;
}
#cv-calc .cv-swap {
  align-self: center; width: 44px; height: 44px; min-width: 44px; padding: 0; margin-top: 20px;
  border: 1px solid #ddd; border-radius: 50%; background: #fff; color: #000; cursor: pointer;
  font-size: 18px; line-height: 1; display: flex; align-items: center; justify-content: center; transition: .15s;
}
#cv-calc .cv-swap:hover { border-color: #000; transform: rotate(180deg); }

/* ── Кастомный дропдаун валюты ──────────────────────────────── */
#cv-calc .cv-cur { position: relative; }
#cv-calc .cv-cur-btn {
  width: 100%; height: 48px; padding: 0 34px 0 14px; border: 1px solid #ddd; border-radius: 14px;
  background: #fff; color: #000; font-family: "Unbounded", sans-serif; cursor: pointer;
  display: flex; align-items: center; gap: 8px; text-align: left; position: relative; overflow: hidden;
}
#cv-calc .cv-cur-btn:hover { border-color: #000; }
#cv-calc .cv-cur-btn-code { font-size: 13px; font-weight: 700; flex: none; }
#cv-calc .cv-cur-btn-name { font-size: 11px; opacity: .6; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#cv-calc .cv-cur-caret { position: absolute; right: 12px; font-size: 11px; opacity: .5; }
#cv-calc .cv-cur-pop {
  position: absolute; z-index: 30; top: calc(100% + 4px); left: 0; right: 0; min-width: 240px;
  background: #fff; border: 1px solid #000; border-radius: 14px; box-shadow: 0 8px 28px rgba(0,0,0,.14);
  padding: 8px; max-height: 320px; display: flex; flex-direction: column;
}
#cv-calc .cv-cur-search {
  width: 100%; height: 40px; padding: 0 12px; margin: 0 0 8px; border: 1px solid #ddd; border-radius: 10px;
  font-family: "Unbounded", sans-serif; font-size: 12px; color: #000;
}
#cv-calc .cv-cur-search:focus { outline: none; border-color: #000; }
#cv-calc .cv-cur-list { overflow-y: auto; display: flex; flex-direction: column; gap: 2px; }
#cv-calc .cv-cur-opt {
  width: 100%; padding: 9px 10px; border: 0; border-radius: 8px; background: none; cursor: pointer;
  display: flex; align-items: baseline; gap: 8px; text-align: left; font-family: "Unbounded", sans-serif;
}
#cv-calc .cv-cur-opt:hover { background: #f4f4f4; }
#cv-calc .cv-cur-opt.is-active { background: #000; }
#cv-calc .cv-cur-opt.is-active .cv-cur-code, #cv-calc .cv-cur-opt.is-active .cv-cur-name { color: #fff; }
#cv-calc .cv-cur-code { font-size: 12px; font-weight: 700; flex: 0 0 42px; }
#cv-calc .cv-cur-name { font-size: 12px; opacity: .8; }
#cv-calc .cv-cur-none { padding: 12px; font-size: 12px; opacity: .6; text-align: center; }

/* ── Строка курса ───────────────────────────────────────────── */
#cv-calc .cv-rateline {
  display: flex; flex-wrap: wrap; align-items: center; gap: 6px 14px; margin: 4px 0 12px;
  font-size: 12px;
}
#cv-calc .cv-rate-main { font-weight: 600; }
#cv-calc .cv-rate-src { opacity: .55; }
#cv-calc .cv-rate-chg { font-weight: 600; }
#cv-calc .cv-rate-chg.up { color: #0a7a3d; }
#cv-calc .cv-rate-chg.down { color: #c0392b; }

/* ── Чипы (популярные пары) ─────────────────────────────────── */
#cv-calc .cv-chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 0 0 12px; }
#cv-calc .cv-chip {
  width: auto; flex: 0 0 auto; padding: 7px 12px; border: 1px solid #ddd; border-radius: 20px;
  background: #fff; color: #000; font-family: "Unbounded", sans-serif; font-size: 11px; cursor: pointer;
}
#cv-calc .cv-chip:hover { border-color: #000; background: #fafafa; }

/* ── Наценка (доп.параметр) ─────────────────────────────────── */
#cv-calc .cv-adv-toggle {
  width: auto; margin: 2px 0 0; padding: 0; border: 0; background: none;
  font-family: "Unbounded", sans-serif; font-size: 12px; color: #000; cursor: pointer;
  display: inline-flex; align-items: center; gap: 6px; text-decoration: underline; text-underline-offset: 3px;
}
#cv-calc .cv-adv-toggle::after { content: "▾"; transition: transform .2s; }
#cv-calc .cv-adv-toggle.open::after { transform: rotate(180deg); }
#cv-calc .cv-markup { margin-top: 12px; border: 1px solid #eee; border-radius: 14px; padding: 14px; }
#cv-calc .cv-markup .form-group { margin-bottom: 8px; }
#cv-calc .cv-markup .form-group input { font-size: 12px; height: 64px; margin-bottom: 0; }
#cv-calc .cv-hint { margin: 8px 0 0; font-size: 11px; line-height: 1.5; opacity: .6; }

/* ── Результат ──────────────────────────────────────────────── */
#cv-calc .calculator__result { margin-top: 16px; display: none; }
#cv-calc .tax-result .amount-group span:first-child { font-size: 12px; line-height: 15px; text-align: right; }
#cv-calc .tax-result.cv-main span, #cv-calc .tax-result.cv-main .amount-group span:first-child { font-weight: 700; }
#cv-calc .tax-result.cv-main .amount-group span:first-child { font-size: 15px; }
#cv-calc .tax-result.cv-main b { font-weight: 700; }
#cv-calc .cv-result-actions {
  display: flex; flex-wrap: wrap; gap: 8px; border: 0; padding: 0; margin-top: 8px;
}
#cv-calc .cv-result-actions button {
  flex: 1 1 auto; max-width: none; width: auto; padding: 10px 14px;
  border: 1px solid #ddd; border-radius: 12px; background: #fff; color: #000;
  font-family: "Unbounded", sans-serif; font-size: 12px; cursor: pointer;
}
#cv-calc .cv-result-actions button:hover { border-color: #000; }
#cv-calc .cv-result-actions button.open { border-color: #000; box-shadow: inset 0 0 0 1px #000; }

/* метод расчёта */
#cv-calc .cv-steps { margin-top: 10px; display: flex; flex-direction: column; gap: 6px; }
#cv-calc .cv-step { font-size: 12px; line-height: 1.55; color: #000; }
#cv-calc .cv-step b { font-weight: 700; }

/* таблица всех валют */
#cv-calc .cv-all { margin-top: 12px; }
#cv-calc .cv-all-scroll { overflow-x: auto; max-height: 420px; overflow-y: auto; border: 1px solid #eee; border-radius: 12px; }
#cv-calc table.cv-all-tbl, #cv-calc #cv-all-table { width: 100%; border-collapse: collapse; font-size: 12px; }
#cv-calc #cv-all-table th, #cv-calc #cv-all-table td {
  border-bottom: 1px solid #eee; padding: 8px 10px; text-align: right; white-space: nowrap;
}
#cv-calc #cv-all-table th { position: sticky; top: 0; background: #f7f9fc; font-weight: 600; z-index: 1; }
#cv-calc #cv-all-table th:nth-child(2), #cv-calc #cv-all-table td:nth-child(2),
#cv-calc #cv-all-table th:first-child, #cv-calc #cv-all-table td:first-child { text-align: left; }

/* динамика */
#cv-calc .cv-dyn { margin-top: 12px; border: 1px solid #eee; border-radius: 14px; padding: 14px; }
#cv-calc .cv-dyn-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 10px; }
#cv-calc .cv-dyn-title { font-size: 12px; font-weight: 600; }
#cv-calc .cv-dyn-periods { display: flex; gap: 6px; flex-wrap: wrap; }
#cv-calc .cv-dyn-p {
  width: auto; padding: 6px 10px; border: 1px solid #ddd; border-radius: 16px; background: #fff; color: #000;
  font-family: "Unbounded", sans-serif; font-size: 11px; cursor: pointer;
}
#cv-calc .cv-dyn-p:hover { border-color: #000; }
#cv-calc .cv-dyn-p.is-active { border-color: #000; box-shadow: inset 0 0 0 1px #000; }
#cv-calc .cv-dyn-canvas { width: 100%; height: auto; display: block; }
#cv-calc .cv-dyn-stat { display: flex; flex-wrap: wrap; gap: 6px 16px; margin-top: 8px; font-size: 12px; }
#cv-calc .cv-dyn-stat b { font-weight: 600; }
#cv-calc .cv-dyn-stat b.up { color: #0a7a3d; } #cv-calc .cv-dyn-stat b.down { color: #c0392b; }
#cv-calc .cv-dyn-loading { opacity: .6; font-size: 12px; }
#cv-calc .cv-dyn-note { margin: 8px 0 0; font-size: 11px; opacity: .55; line-height: 1.5; }

/* ── Мобайл ─────────────────────────────────────────────────── */
@media screen and (max-width: 767px) {
  #cv-calc .cv-convert { grid-template-columns: 1fr; }
  #cv-calc .cv-swap { margin: 2px auto; transform: rotate(90deg); }
  #cv-calc .cv-swap:hover { transform: rotate(270deg); }
  #cv-calc .cv-result-actions button { flex: 1 1 100%; }
  #cv-calc .cv-cur-pop { min-width: 0; }
}

/* ── Таблицы в тексте ───────────────────────────────────────── */
.cv-text-table { width: 100%; border-collapse: collapse; margin: 8px 0 12px; font-size: 14px; }
.cv-text-table th, .cv-text-table td { border: 1px solid #e5e7eb; padding: 8px 10px; text-align: left; vertical-align: top; }
.cv-text-table th { background: #f7f9fc; font-weight: 600; }
.cv-text-table td:first-child { font-weight: 600; }
