/* Link-price calculator — scoped under .lp, on site tokens.
   base.css (.tcalc) already handles: .tform/.tgrid/.tfield/.tinput/.ttable/.ttable-wrap/.tactions/.twarn/.twarn--risk.
   This file adds ONLY what is specific to the link-price tool. */

/* ── Fieldset groups ────────────────────────────────────────── */
.lp fieldset {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--ink-2);
  padding: 1rem 1.25rem 1.25rem;
  margin: 0;
}

.lp legend {
  font-family: var(--mono);
  font-size: var(--fs-xs);
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--text-3);
  padding: 0 .5rem;
}

/* Wider grid inside the filter form on larger screens */
@media (min-width: 1024px) {
  .lp .tgrid {
    grid-template-columns: repeat(3, 1fr);
  }
}

/* ── Checkbox fields ────────────────────────────────────────── */
.lp .tfield--check label {
  display: flex;
  align-items: flex-start;
  gap: .5rem;
  cursor: pointer;
  font-size: var(--fs-sm);
  color: var(--text-2);
  font-weight: 500;
}

.lp .tfield--check input[type="checkbox"] {
  margin-top: .15rem;
  width: 1.1rem;
  height: 1.1rem;
  accent-color: var(--green);
  flex: none;
}

/* ── Range min/max input pairs ──────────────────────────────── */
.lp .lp-range {
  display: flex;
  align-items: center;
  gap: .4rem;
}

.lp .lp-range .tinput {
  flex: 1;
  min-width: 0;
}

.lp .lp-range__sep {
  font-size: var(--fs-sm);
  color: var(--text-3);
  white-space: nowrap;
  flex: none;
}

/* ── Result bucket cards ─────────────────────────────────────── */
.lp #lp-result {
  margin-top: 1.5rem;
  display: grid;
  gap: 1rem;
  grid-template-columns: 1fr;
}

@media (min-width: 600px) {
  .lp #lp-result {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (min-width: 900px) {
  .lp #lp-result {
    grid-template-columns: repeat(4, 1fr);
  }
}

.lp .lp-bucket {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--ink-2);
  padding: 1.1rem 1.25rem;
  display: grid;
  gap: .3rem;
}

/* "Все биржи" overall card — one accent spend */
.lp .lp-bucket.is-overall {
  border-color: var(--green);
  background: var(--green-soft);
}

.lp .lp-bucket__name {
  font-family: var(--mono);
  font-size: var(--fs-xs);
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--text-3);
}

.lp .lp-bucket.is-overall .lp-bucket__name {
  color: var(--green-bright);
}

.lp .lp-bucket__med {
  font-family: var(--mono);
  font-size: clamp(1.4rem, 3.5vw, 2rem);
  font-weight: 700;
  line-height: 1.1;
  color: var(--text);
}

.lp .lp-bucket__range {
  font-size: var(--fs-xs);
  color: var(--text-3);
  font-variant-numeric: tabular-nums;
}

.lp .lp-bucket__n {
  font-size: var(--fs-xs);
  color: var(--text-4);
}

/* Warn messages injected by controller — base.css covers .twarn/.twarn--risk;
   ensure spacing inside the result section */
.lp #lp-result .twarn {
  grid-column: 1 / -1;
}

/* ── Estimate section ────────────────────────────────────────── */
.lp .lp-estimate-wrap {
  margin-top: 2rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--line);
}

.lp .lp-estimate-wrap h3 {
  font-size: var(--fs-h3);
  margin: 0 0 1rem;
}

/* Controls row: qty label + input + add button */
.lp .lp-estimate-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .6rem .75rem;
  margin-bottom: 1rem;
}

.lp .lp-estimate-controls label {
  font-size: var(--fs-sm);
  color: var(--text-2);
  white-space: nowrap;
}

.lp .lp-qty-input {
  width: 6rem;
  flex: none;
}

/* Delete button in table rows */
.lp .lp-del {
  font-size: var(--fs-xs);
  color: var(--text-4);
  background: none;
  border: none;
  cursor: pointer;
  padding: .2rem .45rem;
  border-radius: 6px;
  line-height: 1;
  transition: color var(--t-fast), background var(--t-fast);
}

.lp .lp-del:hover {
  color: #e0533d;
  background: rgba(224, 83, 61, .12);
}

/* Total line */
.lp .lp-total {
  margin-top: 1rem;
  font-size: var(--fs-body);
  color: var(--text-2);
  font-variant-numeric: tabular-nums;
}

.lp .lp-total strong {
  color: var(--text);
}

/* PDF action row */
.lp .lp-pdf-action {
  margin-top: 1rem;
}

/* ---- searchable multi-select ---- */
.lp .ms { position: relative; }
.lp .ms__control {
  display: flex; align-items: center; gap: 6px; width: 100%;
  min-height: 42px; padding: 6px 10px; text-align: left; cursor: pointer;
  background: var(--ink-2); color: var(--text-2);
  border: 1px solid var(--line-2); border-radius: var(--radius, 8px);
  font: inherit;
}
.lp .ms__control:focus-visible { outline: 2px solid var(--green-bright); outline-offset: 2px; }
.lp .ms__ph { color: var(--text-4); flex: 1; }
.lp .ms__chips { display: flex; flex-wrap: wrap; gap: 4px; flex: 1; overflow: hidden; }
.lp .ms__chip, .lp .ms__more {
  background: var(--green-soft); color: var(--green-bright);
  border-radius: 6px; padding: 1px 7px; font-size: var(--fs-xs); white-space: nowrap;
}
.lp .ms__more { background: var(--ink-3); color: var(--text-3); }
.lp .ms__caret { color: var(--text-4); margin-left: auto; }
.lp .ms__panel {
  position: absolute; z-index: 20; top: calc(100% + 4px); left: 0; right: 0;
  background: var(--ink-2); border: 1px solid var(--line-2); border-radius: var(--radius, 8px);
  box-shadow: 0 12px 28px rgba(0,0,0,.35); padding: 8px; max-height: 280px; display: flex; flex-direction: column;
}
.lp .ms__search {
  width: 100%; padding: 8px 10px; margin-bottom: 6px; box-sizing: border-box;
  background: var(--ink); color: var(--text-2); border: 1px solid var(--line-2); border-radius: 6px; font: inherit;
}
.lp .ms__list { overflow-y: auto; }
.lp .ms__opt { display: flex; align-items: center; gap: 8px; padding: 6px 6px; border-radius: 6px; cursor: pointer; color: var(--text-2); }
.lp .ms__opt:hover { background: var(--ink-3); }
.lp .ms__opt input { accent-color: var(--green); }
/* uniform control height across the form */
.lp .tinput, .lp .tinput input, .lp .ms__control { min-height: 42px; }
.lp .tinput input { box-sizing: border-box; }

/* ---- смета flow ---- */
.lp .lp-estimate-help { color: var(--text-3); font-size: var(--fs-sm); margin: 0 0 12px; max-width: 60ch; }
.lp .lp-preview {
  display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px 14px;
  padding: 10px 14px; margin-bottom: 12px;
  background: var(--ink-2); border: 1px dashed var(--line-2); border-radius: var(--radius, 8px);
}
.lp .lp-preview__seg { color: var(--text-2); font-weight: 600; }
.lp .lp-preview__cost { color: var(--green-bright); font-variant-numeric: tabular-nums; }
.lp .lp-empty td { color: var(--text-4); text-align: center; padding: 18px; }

/* ---- stats tables ---- */
.lp-stats { display: grid; grid-template-columns: 1fr; gap: 18px; }
@media (min-width: 720px) { .lp-stats { grid-template-columns: 1fr 1fr; } }
.lp-stats__card h3 { margin: 0 0 8px; font-size: var(--fs-sm); color: var(--text-2); }
.lp-stats__card .ttable { width: 100%; }
.lp-stats__card td:nth-child(2), .lp-stats__card td:nth-child(3),
.lp-stats__card th:nth-child(2), .lp-stats__card th:nth-child(3) { text-align: right; font-variant-numeric: tabular-nums; }

/* ---- mobile/layout fixes: multi-select inside .tinput ---- */
.lp .tinput--ms { display: block; padding: 0; border: 0; background: none; border-radius: 0; }
.lp .ms__opt input[type="checkbox"] { flex: 0 0 auto; width: 18px; height: 18px; min-height: 0; margin: 0; }
.lp .ms__opt span { flex: 1; min-width: 0; line-height: 1.3; }
.lp .lp-empty td { white-space: normal; }
