.catalog-price-control,
.cpc-dialog {
  --cpc-ink: var(--ink, #172026);
  --cpc-muted: var(--muted, #65727d);
  --cpc-line: var(--line, #d9e0e5);
  --cpc-brand: var(--brand, #184e3d);
  --cpc-green: var(--green, #12805c);
  --cpc-red: var(--red, #c93c37);
  --cpc-blue: var(--blue, #2364aa);
  --cpc-yellow: var(--yellow, #b7791f);
}

.catalog-price-control {
  min-width: 0;
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid var(--cpc-line);
  color: var(--cpc-ink);
}

.catalog-price-control[hidden] { display: none !important; }
.catalog-price-control *,
.catalog-price-control *::before,
.catalog-price-control *::after { box-sizing: border-box; }

.cpc-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 12px;
}
.cpc-head h3 { margin: 0; font-size: 17px; }
.cpc-head p { margin: 4px 0 0; color: var(--cpc-muted); font-size: 13px; }
.cpc-gates { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 7px; }

.cpc-status {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  min-height: 27px;
  border-radius: 999px;
  padding: 4px 9px;
  font-size: 12px;
  font-weight: 900;
  line-height: 1.25;
}
.cpc-status.green { background: #dff5eb; color: #096341; }
.cpc-status.blue { background: #e3effd; color: #154f89; }
.cpc-status.yellow { background: #fff4cf; color: #7b510d; }
.cpc-status.red { background: #ffe1df; color: #a92e2a; }
.cpc-status.gray { background: #eef1f3; color: #52606b; }

.cpc-alert {
  margin: 10px 0;
  padding: 11px 12px;
  border: 1px solid var(--cpc-line);
  border-radius: 9px;
  background: #f7f9fa;
  color: var(--cpc-muted);
  overflow-wrap: anywhere;
}
.cpc-alert.ok { border-color: #a9dbc8; background: #eaf9f2; color: #096341; }
.cpc-alert.info { border-color: #b9d5f0; background: #edf5fd; color: #154f89; }
.cpc-alert.warn { border-color: #edd48e; background: #fff8de; color: #7b510d; }
.cpc-alert.err { border-color: #efb8b5; background: #fff0ef; color: #a92e2a; }

.cpc-toolbar {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) minmax(170px, .45fr) auto;
  align-items: end;
  gap: 10px;
  margin: 12px 0;
}
.cpc-field { min-width: 0; }
.cpc-field label,
.cpc-dialog label {
  display: block;
  margin: 0 0 5px;
  color: var(--cpc-muted);
  font-size: 12px;
  font-weight: 900;
}
.cpc-field input,
.cpc-field select,
.cpc-dialog input {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--cpc-line);
  border-radius: 8px;
  padding: 9px 10px;
  background: #fff;
  color: var(--cpc-ink);
  font: inherit;
}
.cpc-field input:focus-visible,
.cpc-field select:focus-visible,
.cpc-dialog input:focus-visible,
.cpc-button:focus-visible,
.cpc-dialog button:focus-visible,
.cpc-dialog summary:focus-visible {
  outline: 3px solid #79b8ef;
  outline-offset: 2px;
}

.cpc-button {
  min-height: 40px;
  border: 1px solid var(--cpc-line);
  border-radius: 8px;
  padding: 8px 12px;
  background: #fff;
  color: var(--cpc-ink);
  font: inherit;
  font-weight: 900;
  cursor: pointer;
}
.cpc-button.primary { border-color: var(--cpc-brand); background: var(--cpc-brand); color: #fff; }
.cpc-button:disabled { cursor: not-allowed; opacity: .55; }

.cpc-list { display: grid; grid-template-columns: repeat(auto-fit, minmax(290px, 1fr)); gap: 11px; min-width: 0; }
.cpc-card {
  display: grid;
  grid-template-columns: 74px minmax(0, 1fr);
  gap: 11px;
  min-width: 0;
  padding: 12px;
  border: 1px solid var(--cpc-line);
  border-radius: 10px;
  background: #fff;
}
.cpc-card.focused { border-color: var(--cpc-blue); box-shadow: 0 0 0 3px #e3effd; }
.cpc-thumb { width: 74px; height: 74px; overflow: hidden; border: 1px solid var(--cpc-line); border-radius: 8px; background: #f6f9f8; }
.cpc-thumb img { display: block; width: 100%; height: 100%; object-fit: contain; background: #fff; }
.cpc-thumb span { display: grid; width: 100%; height: 100%; place-items: center; padding: 7px; color: var(--cpc-muted); text-align: center; font-size: 11px; font-weight: 800; }
.cpc-card-main { display: grid; align-content: start; gap: 7px; min-width: 0; }
.cpc-card-title { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; }
.cpc-card-title h4 { min-width: 0; margin: 0; overflow-wrap: anywhere; font-size: 14px; line-height: 1.35; }
.cpc-meta { display: flex; flex-wrap: wrap; gap: 5px 10px; color: var(--cpc-muted); font-size: 12px; }
.cpc-prices { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; }
.cpc-price { min-width: 0; padding: 7px; border-radius: 7px; background: #f6f9f8; }
.cpc-price span { display: block; color: var(--cpc-muted); font-size: 10px; font-weight: 900; }
.cpc-price strong { display: block; margin-top: 2px; overflow-wrap: anywhere; font-size: 12px; }
.cpc-card-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 7px; }
.cpc-audit { min-width: 0; border-top: 1px solid var(--cpc-line); padding-top: 7px; }
.cpc-audit summary { width: fit-content; cursor: pointer; color: var(--cpc-blue); font-size: 12px; font-weight: 900; }
.cpc-audit-list { display: grid; gap: 5px; margin: 8px 0 0; padding: 0; list-style: none; color: var(--cpc-muted); font-size: 11px; }
.cpc-audit-list li { overflow-wrap: anywhere; }
.cpc-empty { grid-column: 1 / -1; padding: 22px 12px; border: 1px dashed var(--cpc-line); border-radius: 9px; color: var(--cpc-muted); text-align: center; }

.cpc-dialog {
  width: min(680px, calc(100vw - 24px));
  max-height: calc(100vh - 24px);
  overflow: hidden;
  border: 0;
  border-radius: 14px;
  padding: 0;
  color: var(--cpc-ink);
  box-shadow: 0 24px 70px rgba(13, 29, 34, .28);
}
.cpc-dialog::backdrop { background: rgba(13, 29, 34, .64); }
.cpc-dialog form {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  width: 100%;
  height: min(760px, calc(100vh - 24px));
  height: min(760px, calc(100dvh - 24px));
  max-height: calc(100vh - 24px);
  max-height: calc(100dvh - 24px);
  overflow: hidden;
  background: #fff;
}
.cpc-dialog header,
.cpc-dialog footer { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 14px 16px; }
.cpc-dialog header { position: relative; z-index: 2; border-bottom: 1px solid var(--cpc-line); background: #fff; }
.cpc-dialog footer {
  position: sticky;
  z-index: 3;
  bottom: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  border-top: 1px solid var(--cpc-line);
  background: #fff;
  box-shadow: 0 -8px 20px rgba(13, 29, 34, .07);
}
.cpc-dialog h2 { margin: 0; font-size: 20px; }
.cpc-dialog-body {
  display: grid;
  gap: 13px;
  min-width: 0;
  min-height: 0;
  padding: 16px;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
}
.cpc-dialog-action-state {
  min-width: 0;
  margin: 0;
  color: var(--cpc-muted);
  font-size: 12px;
  line-height: 1.4;
  overflow-wrap: anywhere;
}
.cpc-dialog-action-state[data-state="ready"] { color: #096341; }
.cpc-dialog-action-state[data-state="blocked"] { color: #7b510d; }
.cpc-dialog-action-state[data-state="uncertain"] { color: #a92e2a; }
.cpc-dialog-actions { display: flex; align-items: center; justify-content: flex-end; gap: 9px; }
.cpc-dialog-product { display: flex; gap: 10px; align-items: center; min-width: 0; }
.cpc-dialog-product strong { display: block; overflow-wrap: anywhere; }
.cpc-dialog-product span { display: block; margin-top: 3px; color: var(--cpc-muted); font-size: 12px; }
.cpc-last-cost {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-width: 0;
  padding: 11px 12px;
  border: 1px solid var(--cpc-line);
  border-radius: 9px;
  background: #f7f9fa;
}
.cpc-last-cost.available { border-color: #a9dbc8; background: #eaf9f2; }
.cpc-last-cost.unavailable { border-color: #edd48e; background: #fff8de; }
.cpc-last-cost-heading { display: grid; gap: 3px; min-width: 0; }
.cpc-last-cost-heading span { color: var(--cpc-muted); font-size: 12px; font-weight: 900; }
.cpc-last-cost-heading strong { overflow-wrap: anywhere; color: #096341; font-size: 18px; font-variant-numeric: tabular-nums; }
.cpc-last-cost.unavailable .cpc-last-cost-heading span { color: #7b510d; }
.cpc-last-cost p {
  max-width: 330px;
  margin: 0;
  color: var(--cpc-muted);
  text-align: right;
  font-size: 12px;
  line-height: 1.4;
  overflow-wrap: anywhere;
}
.cpc-card .cpc-last-cost { flex-direction: column; align-items: stretch; gap: 6px; }
.cpc-card .cpc-last-cost p { max-width: none; text-align: left; }
.cpc-price-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.cpc-confirm {
  display: grid;
  gap: 10px;
  padding: 12px;
  border: 1px solid #edd48e;
  border-radius: 9px;
  background: #fff8de;
}
.cpc-confirm-check { display: flex !important; align-items: flex-start; gap: 8px; color: #60430e !important; line-height: 1.4; }
.cpc-confirm-check input { width: auto; min-height: auto; margin-top: 3px; }
.cpc-dialog-busy { pointer-events: none; }
.cpc-dialog-busy form { opacity: .76; }

@media (max-width: 720px) {
  .cpc-head { flex-direction: column; }
  .cpc-gates { justify-content: flex-start; }
  .cpc-toolbar { grid-template-columns: minmax(0, 1fr); }
  .cpc-price-grid { grid-template-columns: minmax(0, 1fr); }
}

@media (max-width: 430px) {
  .catalog-price-control { margin-top: 14px; padding-top: 13px; }
  .cpc-list { grid-template-columns: minmax(0, 1fr); }
  .cpc-card { grid-template-columns: 58px minmax(0, 1fr); padding: 10px; }
  .cpc-thumb { width: 58px; height: 58px; }
  .cpc-card-title { flex-direction: column; }
  .cpc-prices { grid-template-columns: minmax(0, 1fr); }
  .cpc-last-cost { flex-direction: column; align-items: stretch; }
  .cpc-last-cost p { max-width: none; text-align: left; }
  .cpc-button { width: 100%; }
  .cpc-dialog { width: calc(100vw - 12px); max-height: calc(100dvh - 12px); }
  .cpc-dialog form { height: calc(100dvh - 12px); max-height: calc(100dvh - 12px); }
  .cpc-dialog header { padding: 11px 12px; }
  .cpc-dialog h2 { font-size: 17px; }
  .cpc-dialog-body { padding: 12px; }
  .cpc-dialog footer { grid-template-columns: minmax(0, 1fr); gap: 8px; padding: 10px 12px; }
  .cpc-dialog-actions { display: grid; grid-template-columns: minmax(0, .72fr) minmax(0, 1.28fr); width: 100%; }
  .cpc-dialog footer button { width: 100%; }
}
