@import url("https://fonts.googleapis.com/css2?family=Montserrat:wght@400;500;600;700&display=swap");

:root {
  --bg: #ffffff;
  --surface: #ffffff;
  --surface-2: #f8f9fa;
  --border: #dee2e6;
  --input-border: #ced4da;
  --form-input-border: rgba(43, 130, 93, 0.55);
  --text: #212529;
  --muted: #6c757d;
  --placeholder: #adb5bd;
  --accent: #2b825d;
  --accent-hover: #1d5940;
  --primary-yellow: #facb10;
  --success: #2b825d;
  --warning: #fd7e14;
  --danger: #dc3545;
  --header-bg: #ffffff;
  --header-text: #212529;
  --header-muted: #6c757d;
  --radius: 12px;
  --shadow: 0 4px 20px rgba(7, 24, 17, 0.08);
  --chat-panel-height: min(800px, calc(100vh - 180px));
  font-family: "Montserrat", "Segoe UI", system-ui, -apple-system, sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

.site-header {
  position: -webkit-sticky;
  position: sticky;
  top: 0;
  z-index: 50;
  background: var(--header-bg);
  color: var(--header-text);
  box-shadow: 0 1px 8px rgba(0, 0, 0, 0.06);
}

.site-header__top {
  border-bottom: 1px solid var(--border);
}

.site-header__inner {
  max-width: 1320px;
  margin: 0 auto;
  padding: 16px 20px;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 16px;
}

.site-header__logo {
  flex: 0 0 auto;
}

.site-header__logo img {
  display: block;
  width: min(290px, 52vw);
  height: auto;
  max-height: 50px;
  object-fit: contain;
}

.site-header__actions {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.site-header__user {
  text-align: right;
  font-size: 0.85rem;
}

.site-header__user-login {
  display: block;
  font-weight: 700;
  color: var(--header-text);
}

.site-header__user-role {
  color: var(--header-muted);
  font-size: 0.78rem;
}

.site-header .stat-pill {
  background: var(--surface-2);
  border-color: var(--border);
  color: var(--header-muted);
}

.site-header .stat-pill strong {
  color: var(--header-text);
}

.site-header .btn--secondary {
  background: #fff;
  border-color: var(--border);
  color: var(--text);
}

.site-header .btn--secondary:hover {
  background: var(--surface-2);
  border-color: var(--accent);
  color: var(--accent);
}

.top-nav {
  max-width: 1320px;
  margin: 0 auto;
  padding: 0 12px 12px;
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  background: var(--header-bg);
  border-bottom: 1px solid var(--border);
}

.top-nav .tabs__btn {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 999px;
}

.top-nav .tabs__btn:hover {
  background: var(--surface-2);
  border-color: var(--accent);
  color: var(--accent);
}

.top-nav .tabs__btn--active {
  background: var(--primary-yellow);
  border-color: var(--primary-yellow);
  color: #2f2604;
  font-weight: 600;
}

.layout {
  max-width: 1320px;
  margin: 0 auto;
  padding: 24px 20px 48px;
}

.header {
  display: none;
}

.header__brand {
  display: flex;
  gap: 16px;
  align-items: center;
}

.header__logo {
  width: 52px;
  height: 52px;
  border-radius: 14px;
  background: linear-gradient(135deg, var(--accent), #1d5940);
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 1.1rem;
}

.header h1 {
  margin: 0;
  font-size: 1.45rem;
  font-weight: 600;
}

.header__subtitle {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.header__stats {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
}

.header__actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
}

.header__user {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 2px;
  font-size: 0.85rem;
}

.header__user-login {
  font-weight: 600;
}

.header__user-role {
  color: var(--muted);
  font-size: 0.78rem;
}

.stat-pill {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 0.82rem;
  color: var(--muted);
  white-space: nowrap;
  flex: 0 0 auto;
}

.stat-pill--sites {
  display: inline-flex;
  align-items: center;
  gap: 0.35em;
  width: fit-content;
  max-width: 100%;
}

.stat-pill--sites.has-tooltip {
  position: relative;
  cursor: help;
}

.stat-pill__num {
  color: var(--text);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.stat-tooltip {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  z-index: 200;
  min-width: 220px;
  max-width: min(320px, 90vw);
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface);
  box-shadow: var(--shadow);
  color: var(--text);
  font-size: 0.78rem;
  line-height: 1.4;
  text-align: left;
  white-space: normal;
  opacity: 0;
  visibility: hidden;
  transform: translateY(-4px);
  transition: opacity 0.15s ease, transform 0.15s ease, visibility 0.15s;
  pointer-events: none;
}

.stat-pill--sites.has-tooltip:hover .stat-tooltip,
.stat-pill--sites.has-tooltip:focus .stat-tooltip,
.stat-pill--sites.has-tooltip:focus-within .stat-tooltip {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.stat-tooltip__title {
  font-weight: 600;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.stat-tooltip__empty {
  color: var(--muted);
}

.stat-tooltip__row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  padding: 3px 0;
}

.stat-tooltip__row span {
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
}

.stat-tooltip__row strong {
  color: var(--text);
  font-variant-numeric: tabular-nums;
  flex-shrink: 0;
}

.stat-pill strong {
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

.tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 0;
  flex-wrap: wrap;
}

.tabs__btn {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--muted);
  padding: 10px 18px;
  border-radius: 999px;
  cursor: pointer;
  font-size: 0.92rem;
  transition: 0.15s;
}

.tabs__btn:hover { color: var(--text); border-color: var(--accent); }

.tabs__btn--active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.panel { display: none; }
.panel--active { display: block; }

.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  margin-bottom: 20px;
  align-items: stretch;
}

#panel-prices > .grid-2 {
  grid-template-columns: 2fr 3fr; /* 40% / 60% */
}

#panel-kp > .card {
  margin-bottom: 20px;
}

#panel-kp > .card > .muted,
#panel-kp .kp-workspace__col-head > .muted {
  margin-bottom: 0;
}

.kp-workspace__grid {
  display: grid;
  grid-template-columns: minmax(0, 5fr) minmax(0, 5fr) minmax(0, 5fr);
  grid-template-areas:
    "head-u . head-l"
    "upload mid head-l"
    "tasks markup logistics";
  column-gap: 20px;
  row-gap: 4px;
  align-items: start;
  --kp-control-label-offset: calc(1.2em + 6px);
}

.kp-workspace__col-head--upload {
  grid-area: head-u;
  width: 100%;
  text-align: left;
}

.kp-workspace__col-head--logistics {
  grid-area: head-l;
  width: 100%;
  text-align: left;
  align-self: start;
}

.kp-workspace__col-head h2 {
  margin: 0;
  font-size: 1.1rem;
  text-align: left;
}

.kp-workspace__col-head--upload h2 {
  margin-bottom: 4px;
}

.kp-workspace__col-head--logistics h2 {
  margin-bottom: 8px;
}

.kp-workspace__col-head--logistics > .muted {
  margin: 0;
  text-align: left;
}

.kp-workspace__mid {
  grid-area: mid;
  display: flex;
  flex-direction: row;
  justify-content: center;
  align-items: flex-start;
  align-self: start;
  justify-self: stretch;
  width: 100%;
  min-width: 0;
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

.kp-workspace__mid .checkbox {
  display: inline-flex;
  width: max-content;
  max-width: 100%;
  justify-content: center;
  align-items: center;
  margin: 0;
  text-align: left;
}

.kp-workspace__grid > .upload-zone {
  grid-area: upload;
  width: 100%;
  margin-bottom: 0;
  min-height: 0;
  height: auto;
  box-sizing: border-box;
  padding: 5px 12px;
  gap: 1px;
}

.kp-workspace__grid > .upload-zone .upload-zone__icon {
  font-size: 0.85rem;
}

.kp-workspace__grid > .upload-zone .upload-zone__formats {
  font-size: 0.75rem;
  line-height: 1.2;
}

.kp-workspace__grid > .upload-zone .upload-zone__name {
  font-size: 0.8rem;
  min-height: 1em;
}

.upload-zone__formats {
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.3;
}

.kp-workspace__controls--tasks,
.kp-workspace__controls--markup,
.kp-workspace__controls--logistics {
  margin-top: 0;
}

.kp-workspace__controls--tasks {
  grid-area: tasks;
  width: 100%;
  min-width: 0;
}

.kp-workspace__controls--markup {
  grid-area: markup;
  width: 100%;
  min-width: 0;
}

.kp-workspace__controls--logistics {
  grid-area: logistics;
  display: flex;
  flex-direction: row;
  flex-wrap: nowrap;
  align-items: flex-end;
  justify-content: center;
  gap: 10px;
  min-width: 0;
  width: 100%;
}

.kp-workspace__field-label {
  display: block;
  font-size: 0.92rem;
  line-height: 1.2;
  color: var(--muted);
  white-space: nowrap;
  margin-bottom: 6px;
  min-height: 1.2em;
  text-align: center;
}

.kp-workspace__controls--tasks .actions--tasks {
  display: grid;
  grid-template-columns: 1fr 1fr;
  align-items: stretch;
  width: 100%;
  margin-top: 0;
  gap: 10px;
}

.kp-workspace__controls--tasks .actions--tasks .btn {
  min-width: 0;
  width: 100%;
  height: 36px;
  padding: 0 14px;
  justify-content: center;
  white-space: nowrap;
  box-sizing: border-box;
}

.kp-workspace__controls--markup.markup-bar {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  width: 100%;
  margin-top: calc(-1 * var(--kp-control-label-offset));
  gap: 0;
}

.kp-workspace__controls--markup .markup-bar__row {
  display: flex;
  flex-direction: row;
  flex-wrap: nowrap;
  align-items: center;
  justify-content: center;
  gap: 10px;
}

.kp-workspace__controls--markup .markup-bar__row .input--compact {
  height: 36px;
  padding: 0 6px;
  box-sizing: border-box;
}

@media (max-width: 980px) {
  .kp-workspace__grid {
    grid-template-columns: 1fr;
    grid-template-areas:
      "head-u"
      "upload"
      "tasks"
      "mid"
      "markup"
      "head-l"
      "logistics";
    row-gap: 12px;
  }
}

@media (max-width: 860px) {
  .grid-2 { grid-template-columns: 1fr; }
}

#panel-competitors > .card:not(:last-child) {
  margin-bottom: 20px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px;
  box-shadow: var(--shadow);
  min-width: 0;
  overflow: hidden;
}

.card h2 {
  margin: 0 0 8px;
  font-size: 1.1rem;
}

.card__head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.card__head h2 { margin: 0; }

.card__head-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.btn--disabled,
.btn.btn--disabled,
a.btn.btn--disabled {
  opacity: 0.45;
  pointer-events: none;
  cursor: not-allowed;
}

.col-select {
  width: 52px;
  text-align: center;
}

.col-order {
  width: 48px;
  text-align: center;
  color: var(--muted);
  font-weight: 600;
}

.kp-select-cell {
  text-align: center;
  vertical-align: top;
}

.kp-select-cell__stack {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  gap: 6px;
}

.tz-row__order-cell {
  text-align: center;
  vertical-align: top;
  padding-left: 4px;
  padding-right: 4px;
}

.tz-row__drag-handle {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1px;
  width: 1.85rem;
  min-height: 2.85rem;
  padding: 4px 0;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  color: var(--muted);
  font-size: 0.65rem;
  line-height: 1;
  cursor: grab;
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
}

.tz-row__drag-handle:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.tz-row__drag-handle--active {
  cursor: grabbing;
  border-color: var(--accent);
  color: var(--accent);
  background: rgba(37, 99, 235, 0.08);
}

.tz-row__drag-handle span {
  display: block;
  pointer-events: none;
}

body.kp-item-dragging {
  cursor: grabbing !important;
  user-select: none !important;
  -webkit-user-select: none !important;
}

body.kp-item-dragging * {
  cursor: grabbing !important;
}

.tz-row--dragging,
.tz-row--dragging + .tz-detail {
  opacity: 0.35;
}

.tz-row--drop-before > td {
  box-shadow: inset 0 3px 0 0 var(--accent);
}

.tz-row--drop-after > td {
  box-shadow: inset 0 -3px 0 0 var(--accent);
}

.tz-row-drag-ghost {
  position: fixed;
  z-index: 10000;
  pointer-events: none;
  margin: 0;
  opacity: 0.92;
  box-shadow: 0 10px 28px rgba(15, 23, 42, 0.22);
  background: var(--surface, #fff);
  border-radius: 6px;
  overflow: hidden;
}

.tz-row-drag-ghost .data-table {
  margin: 0;
  width: 100%;
}

.tz-row__delete-btn {
  flex: 0 0 auto;
  width: 1.6rem;
  height: 1.35rem;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 5px;
  background: var(--surface);
  color: #b42318;
  font-size: 0.95rem;
  line-height: 1;
  cursor: pointer;
}

.tz-row__delete-btn:hover {
  border-color: #b42318;
  background: rgba(180, 35, 24, 0.08);
}

.kp-select-cell input[type="checkbox"],
.kp-kit-select-cell input[type="checkbox"],
.kp-web-select-cell input[type="checkbox"],
.kp-local-select-cell input[type="checkbox"],
.kp-local-include,
.kp-custom-select-cell input[type="checkbox"],
.lookup-kp-select,
#selectAllKpItems {
  width: 18px;
  height: 18px;
  min-width: 18px;
  min-height: 18px;
  margin: 0;
  cursor: pointer;
  accent-color: var(--accent);
}

.lookup-clarify-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 12px;
}

.lookup-clarify-btn {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  width: 100%;
  text-align: left;
  white-space: normal;
  height: auto;
  padding: 10px 12px;
}

.lookup-clarify-btn__label {
  font-weight: 600;
}

.lookup-clarify-btn__hint {
  font-size: 0.85rem;
  color: var(--muted);
  font-weight: 400;
}

.chat-msg--assistant .lookup-clarify-btn:disabled {
  opacity: 0.55;
  cursor: default;
}

.kp-saved-selection {
  margin-bottom: 16px;
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: rgba(43, 130, 93, 0.06);
}

.kp-saved-selection__head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px 16px;
  margin-bottom: 12px;
}

.kp-saved-selection__head h3 {
  margin: 0;
  font-size: 1rem;
}

.kp-saved-selection__table td,
.kp-saved-selection__table th {
  font-size: 0.9rem;
}

.compare-block__market-estimate {
  margin-bottom: 12px;
  font-size: 0.92rem;
  line-height: 1.45;
}

.compare-block__market-estimate a {
  color: var(--accent);
  text-decoration: underline;
}

.kp-variant-block {
  margin-bottom: 12px;
}

.kp-variant-line {
  display: inline;
  margin: 0;
  padding: 0;
  border: none;
  background: none;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
  line-height: 1.6;
}

.kp-variant-line:hover {
  color: var(--accent);
}

.kp-variant-line--selected {
  color: var(--text);
}

.kp-variant-line--selected strong {
  color: var(--accent);
}

.kp-web-price-input,
.kp-local-price-input,
.kp-kit-price-input,
.kp-kit-qty-input {
  width: 100%;
  min-width: 72px;
  max-width: 120px;
  padding: 6px 8px;
  border: 1px solid var(--input-border);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  text-align: right;
}

.kp-web-price-input:focus,
.kp-local-price-input:focus,
.kp-kit-price-input:focus,
.kp-kit-qty-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(43, 130, 93, 0.15);
}

.kp-web-kp-price {
  white-space: nowrap;
}

.compare-block__kit-note {
  margin: 0 0 10px;
  font-size: 0.88rem;
}

.kp-kit-select-cell,
.kp-web-select-cell {
  width: 48px;
  text-align: center;
  vertical-align: middle;
}

.kp-kit-row--excluded td,
.kp-web-row--excluded td,
.kp-local-row--excluded td {
  opacity: 0.45;
}

.kp-kit-match-row--excluded td {
  opacity: 0.45;
}

.kp-local-select-cell,
.kp-web-select-cell {
  width: 3.5rem;
  text-align: center;
  vertical-align: middle;
}

.kp-custom-row--excluded td {
  opacity: 0.45;
}

.kp-custom-price-input,
.kp-custom-qty-input {
  width: 100%;
  max-width: 8.5rem;
  padding: 0.35rem 0.5rem;
  border: 1px solid var(--input-border);
  border-radius: 6px;
  font: inherit;
}

.tz-row__qty-input,
.tz-row__price-input,
.tz-row__margin-input,
.tz-card__qty-input,
.tz-card__price-input,
.tz-card__margin-input {
  width: 100%;
  max-width: 7rem;
  padding: 0.35rem 0.5rem;
  border: 1px solid var(--input-border);
  border-radius: 6px;
  font: inherit;
}

.tz-position-card {
  margin-bottom: 1rem;
  padding: 0.85rem 1rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
}

.tz-position-card__grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(9.5rem, 1fr));
  gap: 12px 16px;
  margin-top: 0.75rem;
}

.tz-position-card__field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}

.tz-position-card__field--readonly strong {
  font-size: 1rem;
}

.tz-position-card__label {
  font-size: 0.78rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.tz-position-card__unit {
  font-size: 0.82rem;
}

.tz-card__qty-stepper {
  display: flex;
  align-items: center;
  gap: 6px;
  width: 100%;
  max-width: 11rem;
}

.tz-card__qty-stepper .tz-card__qty-input {
  flex: 1 1 auto;
  min-width: 0;
  max-width: none;
  text-align: center;
}

.tz-card__qty-btn {
  flex: 0 0 auto;
  width: 2rem;
  height: 2rem;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface-2);
  color: var(--text);
  font: inherit;
  font-size: 1.1rem;
  line-height: 1;
  cursor: pointer;
}

.tz-card__qty-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.compare-table--custom {
  margin-top: 0.75rem;
}

.kp-web-select-cell,
.kp-local-select-cell,
.kp-kit-select-cell {
  width: 4.5rem;
  vertical-align: top;
}

.kp-select-with-photo {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.35rem;
  min-width: 3.25rem;
}

.kp-select-with-photo .lookup-result__photo-btn {
  padding: 0;
  border: 1px solid #d7dde7;
  border-radius: 6px;
  background: #fff;
  overflow: hidden;
  cursor: zoom-in;
  line-height: 0;
}

.kp-select-with-photo .lookup-result__photo-btn:hover {
  border-color: #8fa0b8;
  box-shadow: 0 0 0 2px rgba(70, 110, 170, 0.15);
}

.kp-select-photo {
  display: block;
  width: 44px;
  height: 44px;
  object-fit: cover;
}

.kp-select-photo--empty {
  width: 44px;
  height: 44px;
  border-radius: 6px;
  background:
    linear-gradient(45deg, #edf1f6 25%, transparent 25%),
    linear-gradient(-45deg, #edf1f6 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #edf1f6 75%),
    linear-gradient(-45deg, transparent 75%, #edf1f6 75%);
  background-size: 10px 10px;
  background-position: 0 0, 0 5px, 5px -5px, -5px 0;
  border: 1px dashed #d0d7e2;
}

.kp-web-description,
.kp-quote-description {
  margin-top: 0;
  font-size: 12px;
  line-height: 1.35;
  white-space: pre-wrap;
  max-width: 28rem;
}

.kp-quote-description .kp-quote-para {
  margin: 0 0 0.45em;
  white-space: normal;
}

.kp-quote-description .kp-quote-para:last-child {
  margin-bottom: 0;
}

.kp-quote-description .kp-quote-line {
  display: inline;
}

.kp-quote-spec--matched {
  color: #1b7a3d;
}

.kp-quote-spec--missing {
  color: #b42318;
}

.kp-quote-spec__mark {
  font-weight: 700;
  margin-right: 0.15rem;
}

.kp-kit-compare-item--extra {
  color: #5b6472;
}

.kp-quote-card-meta {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  max-width: 28rem;
}

.kp-quote-block__label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.01em;
  color: #5b6472;
  margin-bottom: 0.15rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  align-items: center;
}

.kp-quote-spec-list,
.kp-quote-kit-list {
  margin: 0;
  padding-left: 1rem;
  font-size: 12px;
  line-height: 1.35;
}

.kp-quote-spec__param {
  color: #3f4754;
  font-weight: 550;
}

.kp-quote-block__more {
  margin-top: 0.15rem;
  font-size: 11px;
}

.kp-quote-char-match {
  margin-top: 0;
  margin-bottom: 0.35rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  align-items: center;
}

/* Единый бейдж %: вверху справа ячейки */
.kp-cell-with-pct {
  position: relative;
  padding-right: 3.4rem;
  min-width: 0;
}

.kp-cell-with-pct__badge {
  position: absolute;
  top: 0;
  right: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
  justify-content: flex-end;
  align-items: flex-start;
  max-width: 4.5rem;
  z-index: 1;
}

.kp-cell-with-pct__body {
  min-width: 0;
}

.kp-quote-block--requested-specs {
  background: color-mix(in srgb, var(--accent) 6%, var(--surface-2));
  border-radius: 8px;
  padding: 0.45rem 0.55rem;
  margin-bottom: 0.5rem;
}

.kp-desc-col {
  min-width: 14rem;
  max-width: 30rem;
  vertical-align: top;
}

.compare-table--kit-compose {
  margin-bottom: 12px;
}

.compare-table--kit-compose th,
.compare-table--kit-compose td {
  font-size: 0.85rem;
}

.kp-kit-sum-cell {
  text-align: right;
  white-space: nowrap;
}

.kp-kit-line-total {
  display: inline-block;
  min-width: 4.5rem;
  text-align: right;
}

.kp-kit-row--expandable .kp-kit-name-cell {
  cursor: pointer;
}

.kp-kit-row--expandable .kp-kit-name-cell:hover {
  color: var(--accent);
}

.kp-kit-row--open,
.kp-kit-row--expandable:has(+ .kp-kit-detail:not(.hidden)) {
  background: rgba(124, 108, 240, 0.06);
}

.kp-kit-row__hint {
  margin-left: 4px;
  font-size: 0.72rem;
  color: var(--muted);
  transition: transform 0.15s ease;
}

.kp-kit-row--open .kp-kit-row__hint {
  transform: rotate(180deg);
}

.kp-kit-detail > td {
  padding: 0 8px 10px 20px;
  background: rgba(124, 108, 240, 0.03);
  border-bottom: 1px solid var(--border);
}

.kp-kit-detail__scroll {
  overflow-x: auto;
  padding: 8px 0 4px;
}

.kp-kit-detail__empty {
  margin: 8px 0;
  font-size: 0.85rem;
}

.compare-table--kit-matches {
  margin: 0;
}

.compare-table--kit-matches th,
.compare-table--kit-matches td {
  font-size: 0.82rem;
}

.compare-row--kit-total td,
.compare-row--web-total td {
  border-top: 1px solid var(--border);
  padding-top: 10px;
}

.muted { color: var(--muted); font-size: 0.9rem; margin: 0 0 16px; }

.upload-zone {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  border: 2px dashed var(--accent);
  border-radius: var(--radius);
  padding: 14px 20px;
  min-height: 0;
  cursor: pointer;
  text-align: center;
  transition: 0.15s;
  margin-bottom: 12px;
  background: rgba(43, 130, 93, 0.08);
}

.upload-zone:hover,
.upload-zone--drag {
  border-color: var(--border);
  background: transparent;
}

.upload-zone__icon { font-size: 1.25rem; line-height: 1; }

.upload-zone__name {
  color: var(--accent);
  font-size: 0.88rem;
  min-height: 1.2em;
}

.checkbox input[type="checkbox"] {
  width: 18px;
  height: 18px;
  min-width: 18px;
  min-height: 18px;
  margin: 0;
  cursor: pointer;
  accent-color: var(--accent);
}

.checkbox {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-bottom: 16px;
  font-size: 0.9rem;
  cursor: pointer;
}

.markup-bar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-top: 14px;
}

.markup-bar__label {
  font-size: 0.92rem;
  color: var(--muted);
  white-space: nowrap;
}

.actions {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 10px;
}

.actions--tasks {
  flex-direction: column;
  align-items: stretch;
}

.actions--tasks .btn {
  width: 100%;
  justify-content: center;
}

.logistics-days-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.logistics-days-stepper {
  flex: 0 0 auto;
}

.logistics-form {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 16px 20px;
  margin-top: 12px;
}

.kp-workspace__controls--logistics.logistics-form {
  display: flex;
  flex-direction: row;
  flex-wrap: nowrap;
  align-items: flex-end;
  justify-content: center;
  gap: 10px;
  margin-top: calc(-1 * var(--kp-control-label-offset));
}

.logistics-form__field {
  display: grid;
  gap: 6px;
}

.logistics-form__field--compact {
  max-width: 220px;
}

.kp-workspace__controls--logistics .logistics-form__field {
  display: grid;
  grid-template-rows: auto auto;
  align-items: start;
  justify-items: start;
  gap: 6px;
  flex: 0 0 auto;
  min-width: 0;
}

.kp-workspace__controls--logistics .logistics-form__field--compact {
  max-width: none;
  width: auto;
}

.kp-workspace__controls--logistics .logistics-form__label {
  white-space: nowrap;
  text-align: left;
  margin: 0;
  line-height: 1.2;
  min-height: 1.2em;
}

.kp-workspace__controls--logistics .logistics-days-stepper {
  height: 36px;
}

.kp-workspace__controls--logistics .logistics-days-stepper .tz-row__qty-btn {
  width: 2rem;
  height: 36px;
}

.kp-workspace__controls--logistics .logistics-days-stepper .tz-row__qty-input {
  height: 36px;
  width: 3.2rem;
  box-sizing: border-box;
  padding: 0 6px;
}

.kp-workspace__controls--logistics .logistics-form__field--compact .input {
  width: 10ch;
  min-width: 10ch;
  max-width: 10ch;
  height: 36px;
  padding: 0 6px;
  box-sizing: border-box;
}

.logistics-form__actions {
  margin-left: auto;
  display: flex;
  align-items: flex-end;
}

.kp-workspace__controls--logistics .logistics-form__actions {
  margin-left: 0;
  width: auto;
  flex: 0 0 auto;
  display: grid;
  grid-template-rows: auto auto;
  gap: 6px;
  align-content: end;
  justify-items: stretch;
}

.kp-workspace__controls--logistics .logistics-form__label--spacer {
  display: block;
  line-height: 1.2;
  min-height: 1.2em;
  visibility: hidden;
}

.logistics-form__apply-btn {
  width: auto;
  min-width: 0;
  max-width: none;
  height: 36px;
  padding: 0 12px;
  justify-content: center;
  font-size: 0.92rem;
  box-sizing: border-box;
}

.logistics-form__label {
  font-size: 0.92rem;
  color: var(--muted);
}

@media (max-width: 640px) {
  .kp-workspace__controls--logistics {
    flex-wrap: wrap;
  }

  .logistics-form__actions {
    margin-left: 0;
    width: 100%;
    justify-content: flex-end;
  }

  .kp-workspace__controls--logistics .logistics-form__field--compact {
    max-width: none;
    flex: 1 1 auto;
  }

  .kp-workspace__controls--logistics .logistics-form__field--compact .input {
    width: 100%;
    min-width: 0;
    max-width: none;
  }

  .kp-workspace__controls--logistics .logistics-form__actions {
    width: auto;
  }
}

.logistics-stub {
  position: relative;
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  padding: 18px 16px;
  background: rgba(43, 130, 93, 0.04);
}

.logistics-stub__badge {
  display: inline-block;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--accent);
  background: rgba(43, 130, 93, 0.12);
  border-radius: 999px;
  padding: 4px 10px;
  margin-bottom: 12px;
}

.logistics-stub__list {
  margin: 0 0 12px;
  padding-left: 1.2rem;
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.5;
}

.logistics-stub__note {
  margin: 0;
  font-size: 0.82rem;
  color: var(--muted);
}

.process-summary-card h2 {
  margin: 0 0 12px;
}

.process-summary-card .results-summary {
  margin-bottom: 0;
}

.process-summary-note {
  margin: 12px 0 0;
}

.results-summary {
  margin-bottom: 16px;
}

.results-summary .summary-metrics {
  margin-bottom: 0;
}


.input--compact {
  width: 13.5ch;
  min-width: 13.5ch;
  max-width: 13.5ch;
  padding: 8px 4px;
  text-align: center;
}

.btn {
  border: none;
  border-radius: 8px;
  padding: 10px 18px;
  font-size: 0.92rem;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  transition: 0.15s;
}

.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn--primary {
  background: var(--accent);
  color: #fff;
}

.btn--primary:hover:not(:disabled) { background: var(--accent-hover); }

.btn--secondary {
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border);
}

.btn--secondary:hover { border-color: var(--accent); }

.btn--danger {
  background: transparent;
  color: var(--danger);
  border: 1px solid var(--danger);
  padding: 6px 12px;
  font-size: 0.82rem;
}

.btn--small {
  padding: 6px 12px;
  font-size: 0.82rem;
}

.input {
  width: 100%;
  background: var(--surface-2);
  border: 1px solid var(--input-border);
  border-radius: 8px;
  padding: 10px 14px;
  color: var(--text);
  font-size: 0.92rem;
}

.input:focus {
  outline: none;
  border-color: var(--accent);
}

.input::placeholder {
  color: var(--placeholder);
  opacity: 1;
}

.input[readonly] {
  color: var(--text);
  cursor: default;
  background: var(--surface);
}

#userEditForm .field-label {
  margin: 0;
  font-size: 0.82rem;
  color: var(--muted);
}

#userEditForm .field-label.hidden {
  display: none;
}

/* Фон как у зоны загрузки ТЗ — поля на странице «База товаров» */
#panel-product-base .input {
  background: rgba(43, 130, 93, 0.08);
}

/* Окантовка как у кнопок задачи (accent) — чаты, сайты, прайсы, каталоги */
.chat-compose .input,
#competitorUrl,
#userEditForm .input,
.upload-blocks .input:not([type="file"]) {
  border: 1px solid var(--form-input-border);
  transition: border-color 0.15s, box-shadow 0.15s;
}

.chat-compose .input:hover:not(:disabled):not(:focus),
#competitorUrl:hover:not(:disabled):not(:focus),
#userEditForm .input:hover:not(:disabled):not(:focus),
.upload-blocks .input:not([type="file"]):hover:not(:disabled):not(:focus) {
  border-color: var(--accent);
}

.chat-compose .input:focus,
#competitorUrl:focus,
#userEditForm .input:focus,
.upload-blocks .input:not([type="file"]):focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(43, 130, 93, 0.15);
}

.form-stack { display: flex; flex-direction: column; gap: 12px; }

.input--textarea {
  min-height: 72px;
  resize: vertical;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 0.85rem;
  line-height: 1.45;
}

.upload-blocks {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.upload-block {
  padding: 16px 0;
  border-top: 1px solid var(--border);
}

.upload-block:first-of-type {
  border-top: none;
  padding-top: 8px;
}

.upload-block__title {
  margin: 0 0 8px;
  font-size: 1rem;
  font-weight: 600;
}

.upload-block__hint {
  margin: 0 0 10px;
  font-size: 0.85rem;
}

.form-stack + .upload-block__hint {
  margin-top: 16px;
}

.data-sources-section {
  margin-bottom: 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.02);
  overflow: hidden;
}

.data-sources-section:last-child {
  margin-bottom: 0;
}

.data-sources-section__title {
  margin: 0;
  padding: 12px 14px;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  cursor: pointer;
  list-style: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  user-select: none;
}

.data-sources-section__title::-webkit-details-marker {
  display: none;
}

.data-sources-section__label::before {
  content: "▸";
  display: inline-block;
  margin-right: 8px;
  transition: transform 0.15s ease;
}

.data-sources-section[open] .data-sources-section__label::before {
  transform: rotate(90deg);
}

.data-sources-section__meta {
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-muted);
  text-transform: none;
  letter-spacing: 0;
  padding: 2px 8px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.06);
}

.data-sources-section__body {
  padding: 0 14px 14px;
}

.data-sources-section__body > .table-wrap {
  max-height: 1000px;
  overflow: auto;
}

.data-sources-section__empty {
  margin: 0;
  padding: 0 0 2px;
}

.actions--wrap {
  flex-wrap: wrap;
}

.competitor-analysis {
  margin-top: 16px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.02);
  font-size: 0.9rem;
  line-height: 1.5;
}

.competitor-index-panel {
  margin-top: 16px;
  border: 1px solid #2a3544;
  border-radius: 10px;
  overflow: hidden;
  background: #0d1117;
}

.competitor-index-status {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  background: #161b22;
  color: #79c0ff;
  font-size: 0.88rem;
  font-weight: 500;
  border-bottom: 1px solid #30363d;
}

.competitor-index-status::before {
  content: "";
  flex-shrink: 0;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #79c0ff;
  animation: competitor-index-pulse 1.2s ease-in-out infinite;
}

.competitor-index-status--done {
  color: #3fb950;
}

.competitor-index-status--done::before {
  background: #3fb950;
  animation: none;
}

.competitor-index-status--error {
  color: #f85149;
}

.competitor-index-status--error::before {
  background: #f85149;
  animation: none;
}

@keyframes competitor-index-pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.45; transform: scale(0.85); }
}

.competitor-index-log {
  margin: 0;
  padding: 12px 14px;
  max-height: 280px;
  overflow-y: auto;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  font-size: 0.78rem;
  line-height: 1.55;
  color: #c9d1d9;
  white-space: pre-wrap;
  word-break: break-word;
}

.competitor-index-log__line--error { color: #f85149; }
.competitor-index-log__line--success { color: #3fb950; }
.competitor-index-log__line--info { color: #c9d1d9; }

.competitor-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 0.75rem;
  background: rgba(255, 255, 255, 0.08);
}

.competitor-badge--custom {
  background: rgba(56, 189, 248, 0.15);
  color: #7dd3fc;
}

.competitors-list-scroll {
  max-height: calc(2.5rem + 10 * 3.25rem);
  overflow-y: auto;
  padding-right: 4px;
  margin-right: -4px;
}

.competitor-sites-list {
  display: flex;
  flex-direction: column;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface-2);
}

.product-base-sites-list.competitor-sites-list {
  gap: 18px;
  border: none;
  background: transparent;
  border-radius: 0;
}

.competitor-site-item {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
}

.competitor-site-item:last-child {
  border-bottom: 0;
}

.product-base-site.competitor-site-item {
  border-bottom: none;
  border-radius: var(--radius, 10px);
  padding: 12px 14px;
}

.product-base-site--with-prices,
.product-base-site--without-prices {
  background: rgba(43, 130, 93, 0.08);
  border: 1px dashed var(--accent);
}

.competitor-site-item__main {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
}

.competitor-site-item__body {
  min-width: 0;
  flex: 1;
}

.competitor-site-item__title {
  font-weight: 500;
  margin-bottom: 4px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.product-base-count {
  display: inline-flex;
  align-items: center;
  font-size: 0.82em;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 999px;
  white-space: nowrap;
}

.product-base-count--ready {
  color: #0f5132;
  background: #d1e7dd;
}

.product-base-count--empty {
  color: #664d03;
  background: #fff3cd;
}

#productBaseSitesSummary {
  margin-bottom: 12px;
}

.competitor-site-item__domain a {
  color: var(--accent);
  text-decoration: underline;
}

.competitor-site-item__domain {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 8px 12px;
}

.product-base-site__updated {
  font-size: 0.88em;
  white-space: nowrap;
}

.competitor-site-item__search {
  margin-top: 4px;
  word-break: break-word;
}

.competitor-site-item__actions {
  flex-shrink: 0;
  display: inline-flex;
  align-items: flex-start;
  gap: 8px;
}

.product-base-site__stats {
  margin-top: 4px;
  font-size: 0.9em;
}

.product-base-site__prices {
  margin-left: 0;
  padding: 0;
  border-radius: 0;
  background: transparent;
  border: none;
}

.product-base-price-cards {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.product-base-price-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 6px 0;
  border-bottom: 1px solid var(--border);
}

.product-base-price-row:last-child {
  border-bottom: 0;
}

.product-base-price-card.product-base-price-row {
  padding: 10px 12px;
  border: 1px dashed var(--accent);
  border-radius: 8px;
  border-bottom: 1px dashed var(--accent);
  background: rgba(43, 130, 93, 0.08);
}

.product-base-price-row__title {
  font-weight: 500;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.product-base-price-row__meta {
  font-size: 0.85em;
  margin-top: 2px;
}

.product-base-price-empty {
  margin: 0;
  font-size: 0.9em;
}

.product-base-site__index {
  margin: 0;
}

.price-actions--icons {
  gap: 2px;
  flex-wrap: nowrap;
}

.price-actions--icons .btn--icon {
  min-width: 32px;
  padding: 4px 8px;
}

.checkbox-row {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  user-select: none;
}

.form-row-inline {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}

.form-row-inline .input {
  flex: 1;
  min-width: 180px;
}

.form-stack--compact {
  gap: 10px;
}

.collapsible-card__head {
  margin-bottom: 0;
}

.collapsible-card:not(.is-collapsed) .collapsible-card__head {
  margin-bottom: 16px;
}

.collapsible-card__toggle {
  display: inline-flex;
  align-items: flex-start;
  gap: 10px;
  margin: 0;
  padding: 0;
  border: none;
  background: transparent;
  color: inherit;
  cursor: pointer;
  text-align: left;
  font: inherit;
  max-width: 100%;
}

.collapsible-card__toggle h2 {
  margin: 0;
  line-height: 1.35;
}

.collapsible-card__toggle:hover h2 {
  color: var(--accent);
}

.collapsible-card__chevron {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: 1.1em;
  margin-top: 0.35em;
  color: var(--muted);
  font-size: 0.75rem;
  line-height: 1;
  transition: transform 0.15s ease;
}

.collapsible-card:not(.is-collapsed) .collapsible-card__chevron {
  transform: rotate(90deg);
}

.collapsible-card__body {
  max-height: 1000px;
  overflow-x: hidden;
  overflow-y: auto;
}

.collapsible-card.is-collapsed .collapsible-card__body {
  display: none;
}

.product-base-sites {
  max-height: none;
  overflow: visible;
}

.product-base-stock-card .data-sources-section__body {
  padding-top: 0;
}

.product-base-stock-card .product-base-price-cards {
  margin-top: 8px;
}

.upload-blocks.collapsible-card .upload-block:last-child {
  margin-bottom: 0;
}

.competitor-site-type-btn {
  min-width: 108px;
  justify-content: center;
}

.competitor-site-type-btn--draft {
  box-shadow: inset 0 0 0 1px var(--accent);
}

.competitor-site-menu {
  z-index: 40;
}

.competitors-list-scroll .data-sources-section:last-child {
  margin-bottom: 0;
}

.competitor-chat-card {
  margin-top: 16px;
  display: flex;
  flex-direction: column;
  height: var(--chat-panel-height);
  padding: 0;
  overflow: hidden;
  min-width: 0;
}

.competitor-chat-messages {
  overflow-x: hidden;
  min-width: 0;
}

.competitor-chat-hints {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
}

.competitor-result-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.competitor-result-item {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.02);
  min-width: 0;
  overflow: hidden;
}

.competitor-result-item__body {
  flex: 1 1 auto;
  min-width: 0;
}

.competitor-result-item__aside {
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.competitor-result-item__photo {
  flex: 0 0 auto;
}

.competitor-result-item__kp-select {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  font-size: 0.78rem;
  color: var(--muted);
  cursor: pointer;
  user-select: none;
  text-align: center;
}

.competitor-result-item__kp-select input {
  width: 16px;
  height: 16px;
  margin: 0;
  cursor: pointer;
}

.competitor-result-item__kp-select-label {
  line-height: 1.2;
}

.competitor-result-item__image {
  width: 72px;
  height: 72px;
  object-fit: contain;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.04);
}

.competitor-result-item__head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  flex-wrap: wrap;
  gap: 8px 12px;
  margin-bottom: 6px;
}

.competitor-result-item__title {
  flex: 1 1 140px;
  min-width: 0;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.competitor-result-item__name {
  overflow-wrap: anywhere;
  word-break: break-word;
}

.competitor-result-item__price {
  font-weight: 600;
  white-space: nowrap;
  flex-shrink: 0;
}

.lookup-form {
  display: flex;
  gap: 10px;
  margin-bottom: 16px;
}

.lookup-form .input { flex: 1; }

/* ——— Chat lookup ——— */
.chat-layout {
  display: grid;
  grid-template-columns: 260px 1fr;
  gap: 16px;
  height: var(--chat-panel-height);
}

.chat-sidebar {
  display: flex;
  flex-direction: column;
  min-height: 0;
  height: 100%;
  padding: 16px;
}

.chat-sidebar__head {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 12px;
}

.chat-sidebar__head h2 {
  margin: 0;
  font-size: 1rem;
}

.chat-sidebar__actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.chat-history {
  list-style: none;
  margin: 0;
  padding: 0;
  overflow-y: auto;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.chat-history__empty {
  padding: 12px 4px;
  font-size: 0.88rem;
}

.chat-history__item {
  width: 100%;
  text-align: left;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
  color: var(--text);
  cursor: pointer;
  transition: 0.15s;
}

.chat-history__item:hover,
.chat-history__item:focus-visible,
.chat-history__item--active {
  border-color: var(--accent);
  background: rgba(43, 130, 93, 0.1);
}

.chat-history__item:hover,
.chat-history__item:focus-visible {
  position: relative;
  z-index: 1;
}

.chat-history__text {
  display: block;
  font-size: 0.88rem;
  line-height: 1.35;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chat-history__item:hover .chat-history__text,
.chat-history__item:focus-visible .chat-history__text {
  white-space: normal;
  overflow: visible;
  text-overflow: unset;
  word-break: break-word;
}

.chat-history__meta {
  display: block;
  margin-top: 4px;
  font-size: 0.72rem;
  color: var(--muted);
}

.chat-main {
  display: flex;
  flex-direction: column;
  min-height: 0;
  height: 100%;
  padding: 0;
  overflow: hidden;
}

.chat-header {
  padding: 18px 20px 12px;
  border-bottom: 1px solid var(--border);
}

.chat-header h2 {
  margin: 0 0 6px;
  font-size: 1.1rem;
}

.chat-header .muted {
  margin: 0;
}

.chat-messages {
  flex: 1 1 auto;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 16px 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-height: 0;
  min-width: 0;
}

.chat-welcome {
  align-self: center;
  max-width: 520px;
  text-align: center;
  color: var(--muted);
  font-size: 0.92rem;
  padding: 24px 12px;
}

.chat-msg {
  display: flex;
  flex-direction: column;
  min-width: 0;
  max-width: 100%;
}

.chat-msg--user {
  align-self: flex-end;
  align-items: flex-end;
  max-width: min(100%, 820px);
  width: auto;
}

.chat-msg--assistant,
.chat-msg--error {
  align-self: flex-start;
  align-items: flex-start;
  width: 100%;
  max-width: 100%;
}

.chat-msg__bubble {
  border-radius: 14px;
  padding: 12px 14px;
  line-height: 1.5;
  font-size: 0.92rem;
  max-width: 100%;
  min-width: 0;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.chat-msg__bubble--multiline {
  white-space: pre-wrap;
}

.chat-msg--user .chat-msg__bubble {
  background: var(--accent);
  color: #fff;
  border-bottom-right-radius: 4px;
}

.chat-msg--assistant .chat-msg__bubble {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-bottom-left-radius: 4px;
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
}

.chat-msg--error .chat-msg__bubble {
  background: rgba(220, 53, 69, 0.1);
  border: 1px solid rgba(220, 53, 69, 0.35);
  color: #b02a37;
}

.chat-msg__time {
  margin-top: 4px;
  font-size: 0.72rem;
  color: var(--muted);
}

.chat-msg__typing {
  display: inline-flex;
  gap: 4px;
  padding: 4px 0;
}

.chat-msg__typing span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--muted);
  animation: chatTyping 1.2s infinite ease-in-out;
}

.chat-msg__typing span:nth-child(2) { animation-delay: 0.15s; }
.chat-msg__typing span:nth-child(3) { animation-delay: 0.3s; }

.chat-msg__progress-log {
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid color-mix(in srgb, var(--border) 80%, transparent);
  font-size: 12px;
  line-height: 1.45;
  color: var(--muted);
  max-height: 140px;
  overflow-y: auto;
}

.chat-msg__progress-log:empty {
  display: none;
}

@keyframes chatTyping {
  0%, 80%, 100% { opacity: 0.35; transform: translateY(0); }
  40% { opacity: 1; transform: translateY(-3px); }
}

.chat-compose {
  display: flex;
  gap: 10px;
  padding: 14px 20px 18px;
  border-top: 1px solid var(--border);
  align-items: flex-end;
}

.chat-compose__input {
  flex: 1;
  resize: none;
  min-height: 44px;
  max-height: 140px;
}

.chat-compose__send {
  flex-shrink: 0;
  min-height: 44px;
}

.chat-msg--highlight .chat-msg__bubble {
  box-shadow: 0 0 0 2px rgba(43, 130, 93, 0.55);
}

.kp-chat-messages .chat-msg__bubble.chat-result {
  max-width: 100%;
  padding: 12px;
  margin-top: 8px;
  overflow-x: hidden;
}

.kp-chat-messages {
  margin-top: 12px;
  overflow-x: hidden;
  min-width: 0;
}

#kpChatCard {
  display: flex;
  flex-direction: column;
  height: var(--chat-panel-height);
  padding: 0;
  overflow: hidden;
}

.kp-assistant-layout {
  align-items: stretch;
}

.kp-history-sidebar {
  gap: 0;
  padding: 12px;
  max-height: 800px;
  height: var(--chat-panel-height);
  overflow-y: auto;
}

.kp-history-pane {
  display: flex;
  flex-direction: column;
  min-height: 0;
  flex: 1 1 50%;
  padding-bottom: 10px;
  margin-bottom: 10px;
  border-bottom: 1px solid var(--border);
}

.kp-history-pane:last-child {
  margin-bottom: 0;
  padding-bottom: 0;
  border-bottom: none;
}

.kp-history-pane .chat-sidebar__head {
  margin-bottom: 8px;
}

.kp-history-pane .chat-sidebar__head h2 {
  font-size: 0.92rem;
}

.kp-history-pane .chat-history {
  flex: 1;
  min-height: 0;
  max-height: none;
  overflow-y: auto;
}

.kp-history-pane .chat-history__item--active {
  border-color: var(--accent);
  background: rgba(43, 130, 93, 0.1);
}

.chat-history__row {
  display: flex;
  align-items: stretch;
  gap: 4px;
}

.chat-history__row .chat-history__item {
  flex: 1;
  min-width: 0;
}

.chat-history__delete {
  flex-shrink: 0;
  align-self: center;
}

#kpChatCard .chat-header,
#kpChatCard .kp-chat-hints,
#kpChatCard .chat-compose,
.chat-main .chat-header,
.chat-main .lookup-chat-hints,
.chat-main .chat-compose,
.competitor-chat-card .chat-header,
.competitor-chat-card .competitor-chat-hints,
.competitor-chat-card .chat-compose {
  flex-shrink: 0;
}

#kpChatCard .kp-chat-hints {
  padding: 0 20px 8px;
  margin-top: 0;
}

#kpChatCard .chat-compose {
  align-items: flex-end;
  border-top: none;
  border-bottom: 1px solid var(--border);
  padding: 0 20px 12px;
  --kp-compose-control-height: 44px;
}

#kpChatCard .chat-compose__input {
  min-height: var(--kp-compose-control-height);
  max-height: 140px;
  height: var(--kp-compose-control-height);
  box-sizing: border-box;
  padding: 10px 14px;
  line-height: 1.35;
  overflow-y: auto;
  resize: none;
  field-sizing: content;
  background: rgba(43, 130, 93, 0.08);
}

#kpChatCard .chat-compose__send {
  min-height: var(--kp-compose-control-height);
  height: var(--kp-compose-control-height);
  box-sizing: border-box;
  padding-top: 0;
  padding-bottom: 0;
}

.chat-main .lookup-chat-hints,
.competitor-chat-card .competitor-chat-hints {
  padding: 0 20px 12px;
  margin-top: 0;
}

.chat-link,
.chat-messages a,
.chat-result a {
  color: var(--accent);
  text-decoration: underline;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.chat-link-wrap {
  margin-top: 4px;
  max-width: 100%;
  overflow: hidden;
}

.chat-result,
.chat-msg__bubble.chat-result {
  max-width: 100%;
  min-width: 0;
  overflow-x: hidden;
}

.chat-result .lookup-result {
  margin-top: 0;
  min-width: 0;
}

.lookup-list {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.lookup-list__item {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--border);
}

.lookup-list__item:last-child {
  border-bottom: 0;
  padding-bottom: 0;
}

.lookup-list__title {
  margin: 0;
  font-size: 1rem;
  font-weight: 600;
}

.chat-result h3,
.chat-result p,
.chat-result .source-block,
.chat-result .match-variant,
.chat-result .competitor-result-item {
  max-width: 100%;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.assistant-mode {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
  margin-top: 8px;
  font-size: 0.9rem;
}

.assistant-mode__label {
  color: var(--text-muted);
}

.assistant-mode__value {
  font-weight: 600;
}

.assistant-mode__sep {
  color: var(--text-muted);
}

.badge--pending {
  background: rgba(148, 163, 184, 0.2);
  color: #94a3b8;
}

.kp-chat-hints {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.kp-chat-hint {
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--muted);
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 0.82rem;
  cursor: pointer;
  transition: 0.15s;
}

.kp-chat-hint:hover:not(:disabled) {
  color: var(--text);
  border-color: var(--accent);
}

.kp-chat-hint--active {
  background: var(--primary-yellow);
  border-color: var(--primary-yellow);
  color: #2f2604;
  font-weight: 600;
}

.kp-chat-hint--active:hover:not(:disabled) {
  background: var(--primary-yellow);
  border-color: var(--primary-yellow);
  color: #2f2604;
}

.lookup-chat-hints {
  margin-bottom: 12px;
}

.kp-chat-hint:disabled,
.chat-compose__input:disabled,
.chat-compose__send:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.kp-chat-actions {
  margin-top: 8px;
  font-size: 0.82rem;
  color: var(--muted);
}

.lookup-result {
  background: var(--surface-2);
  border-radius: var(--radius);
  padding: 18px;
  line-height: 1.6;
  min-width: 0;
  max-width: 100%;
  overflow: hidden;
}

.lookup-result__layout {
  display: grid;
  grid-template-columns: 1fr 220px;
  gap: 20px;
  align-items: start;
}

@media (max-width: 760px) {
  .lookup-result__layout {
    grid-template-columns: 1fr;
  }
}

.lookup-result__photo-btn {
  display: block;
  padding: 0;
  border: none;
  background: none;
  cursor: zoom-in;
  border-radius: var(--radius);
  line-height: 0;
  transition: transform 0.15s, box-shadow 0.15s;
}

.lookup-result__photo-btn:hover {
  transform: scale(1.02);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.35);
}

.lookup-result__photo-btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.lookup-result__photo {
  width: 220px;
  height: 220px;
  border-radius: var(--radius);
  object-fit: cover;
  background: var(--surface);
  border: 1px solid var(--border);
}

.lookup-result__photos {
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: 220px;
}

.lookup-result__photo-stack {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.lookup-result__photo--thumb {
  width: 220px;
  height: 140px;
  object-fit: cover;
}

.lookup-result__photo--empty {
  display: block;
}

.photo-modal {
  position: fixed;
  inset: 0;
  z-index: 110;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.photo-modal__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.78);
  cursor: zoom-out;
}

.photo-modal__dialog {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: center;
}

.photo-modal__image {
  display: block;
  width: auto;
  height: auto;
  max-width: min(660px, 70vw);
  max-height: min(660px, 70vh);
  object-fit: contain;
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.photo-modal__close {
  position: absolute;
  top: -12px;
  right: -12px;
  width: 36px;
  height: 36px;
  border: none;
  border-radius: 50%;
  background: var(--surface-2);
  color: var(--text);
  font-size: 1.4rem;
  line-height: 1;
  cursor: pointer;
  box-shadow: var(--shadow);
  z-index: 2;
}

.photo-modal__close:hover {
  background: var(--accent);
  color: #fff;
}

.source-block {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 14px;
  margin-top: 12px;
  min-width: 0;
  max-width: 100%;
  overflow: hidden;
}

.source-block h4 {
  margin: 0 0 8px;
  font-size: 0.92rem;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.source-block .competitor-result-list {
  margin: 0;
}

.source-block ul {
  margin: 0;
  padding-left: 18px;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.source-block li {
  overflow-wrap: anywhere;
  word-break: break-word;
}

.source-block--warning {
  border-color: rgba(245, 158, 11, 0.45);
  color: var(--warning);
}

.source-block--missing {
  border-color: rgba(239, 68, 68, 0.35);
  color: #fca5a5;
}

.source-block--ai {
  border-color: rgba(124, 108, 240, 0.45);
  background: linear-gradient(180deg, rgba(124, 108, 240, 0.1), var(--surface));
}

.source-block--marketplace {
  border-color: rgba(59, 130, 246, 0.45);
  background: linear-gradient(180deg, rgba(59, 130, 246, 0.08), var(--surface));
}

.source-block--marketplace h4 {
  color: #93c5fd;
}

.source-block--ai a {
  color: #a5b4fc;
  text-decoration: underline;
}

.lookup-result h3 { margin: 0 0 12px; }

.lookup-kv {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 6px 16px;
  margin: 12px 0;
}

.lookup-kv dt { color: var(--muted); }
.lookup-kv dd { margin: 0; }

.empty-state {
  color: var(--muted);
  padding: 24px 0;
  text-align: center;
  font-size: 0.92rem;
}

.tz-row--expandable {
  cursor: default;
}

.tz-row__name {
  cursor: pointer;
}

.tz-row__name:hover {
  color: var(--accent);
}

.tz-row--expandable .tz-row__qty-input,
.tz-row--expandable .tz-row__price-input,
.tz-row--expandable .tz-row__margin-input,
.tz-row--expandable .tz-card__price-input {
  cursor: text;
}

.tz-row--expandable:hover {
  background: transparent;
}

.tz-row--expandable.tz-row--open,
.tz-row--expandable:has(+ .tz-detail:not(.hidden)) {
  background: rgba(124, 108, 240, 0.06);
}

.tz-row__qty-stepper {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  max-width: 100%;
}

.tz-row__qty-stepper .tz-row__qty-input {
  width: 3.2rem;
  min-width: 2.5rem;
  text-align: center;
  padding: 4px 6px;
}

.tz-row__qty-btn {
  flex: 0 0 auto;
  width: 1.75rem;
  height: 1.75rem;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text);
  font-size: 1rem;
  line-height: 1;
  cursor: pointer;
}

.tz-row__qty-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.tz-position-card__grid--price-only {
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
}

.tz-row--open .tz-row__hint {
  transform: rotate(180deg);
  display: inline-block;
}

.tz-row__hint {
  color: var(--muted);
  font-size: 0.75rem;
  margin-left: 4px;
}

.tz-row__custom-hint {
  color: var(--accent);
  font-weight: 500;
}

.tz-custom-inline > td {
  padding: 0 12px 14px;
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
}

.tz-detail > td {
  padding: 0 12px 16px;
  background: var(--surface-2);
}

.tz-detail__scroll {
  width: 100%;
  overflow-x: auto;
}

.tz-detail__scroll .compare-table {
  min-width: 980px;
}

.compare-block {
  padding: 12px 0 4px;
}

.compare-block__primary {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px 14px;
  margin-bottom: 12px;
  font-size: 0.9rem;
  line-height: 1.55;
}

.compare-block__meta {
  margin: 0 0 10px;
  font-size: 0.88rem;
  color: var(--muted);
}

.compare-block__subtitle {
  margin: 14px 0 8px;
  font-size: 0.9rem;
}

.kp-price-compare {
  margin: 0 0 4px;
  line-height: 1.35;
  font-size: 0.86rem;
  color: var(--text-muted, #5b6472);
}

.kp-price-compare__best {
  color: var(--ok, #1a7f37);
  font-weight: 600;
}

.compare-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.82rem;
}

.compare-table th,
.compare-table td {
  border: 1px solid var(--border);
  padding: 6px 8px;
  text-align: left;
  vertical-align: top;
}

.compare-table th {
  background: var(--surface);
  color: var(--muted);
  font-weight: 600;
}

.compare-row--competitor td:first-child {
  color: #c4b5fd;
}

.compare-row--selected td {
  background: rgba(196, 181, 253, 0.12);
}

.compare-table--web {
  margin-bottom: 12px;
}

.compare-row--supplier td {
  background: var(--surface-2);
  color: var(--muted);
  font-size: 0.8rem;
}

.summary-metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.metric {
  background: var(--surface-2);
  border-radius: 10px;
  padding: 14px;
}

.metric__label {
  font-size: 0.78rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.metric__value {
  font-size: 1.35rem;
  font-weight: 600;
  margin-top: 4px;
}

.metric--success .metric__value { color: var(--success); }
.metric--warning .metric__value { color: var(--warning); }
.metric--danger .metric__value { color: var(--danger); }
.metric--accent .metric__value { color: var(--accent); }

.metric__sub {
  display: block;
  margin-top: 4px;
  font-size: 0.95rem;
  font-weight: 500;
  color: var(--muted);
}

.table-wrap { overflow-x: auto; }

#usersTableWrap {
  height: auto;
  max-height: 900px;
  overflow: auto;
}

#panel-history .history-table-wrap {
  min-height: 100px;
  max-height: 1000px;
  height: auto;
  overflow: auto;
}

#panel-history .history-table-wrap.is-empty {
  height: 100px;
  min-height: 100px;
}

#resultsCard > .table-wrap,
.kp-saved-selection .table-wrap {
  height: auto;
  max-height: 1000px;
  overflow: auto;
}

.process-progress {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 0 0 12px;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: color-mix(in srgb, var(--accent) 8%, var(--surface));
  color: var(--text);
  font-size: 0.9rem;
  line-height: 1.4;
}

.process-progress__head {
  display: flex;
  align-items: center;
  gap: 10px;
}

.process-progress__spinner {
  flex-shrink: 0;
  width: 14px;
  height: 14px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

.process-progress__text {
  min-width: 0;
  font-weight: 600;
}

.process-progress__log {
  margin: 0;
  padding: 0;
  list-style: none;
  max-height: 240px;
  overflow: auto;
  display: flex;
  flex-direction: column;
  gap: 4px;
  color: var(--muted);
  font-size: 0.84rem;
}

.process-progress__log li {
  padding-left: 2px;
}

.process-progress__log li::before {
  content: "•";
  margin-right: 8px;
  color: var(--accent);
}

.process-progress__log li.is-current {
  color: var(--text);
  font-weight: 500;
}

.process-progress__log li.is-current::before {
  content: "▸";
}

.kp-kit-row--searching .kp-kit-name-cell::after {
  content: " идёт поиск…";
  margin-left: 0.35rem;
  font-size: 11px;
  font-weight: 500;
  color: var(--accent);
  animation: kp-kit-pulse 1.2s ease-in-out infinite;
}

@keyframes kp-kit-pulse {
  0%,
  100% {
    opacity: 0.4;
  }
  50% {
    opacity: 1;
  }
}

.docs-upload-progress {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 0 0 16px;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: color-mix(in srgb, var(--accent) 8%, var(--surface));
  color: var(--text);
  font-size: 0.9rem;
  line-height: 1.4;
}

.docs-upload-progress__head {
  display: flex;
  align-items: center;
  gap: 10px;
}

.docs-upload-progress__spinner {
  flex-shrink: 0;
  width: 14px;
  height: 14px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

.docs-upload-progress__text {
  min-width: 0;
  font-weight: 600;
}

.docs-upload-progress__log {
  margin: 0;
  padding: 0;
  list-style: none;
  max-height: 160px;
  overflow: auto;
  display: flex;
  flex-direction: column;
  gap: 4px;
  color: var(--muted);
  font-size: 0.84rem;
}

.docs-upload-progress__log li::before {
  content: "•";
  margin-right: 8px;
  color: var(--accent);
}

.docs-upload-progress__log li.is-current {
  color: var(--text);
  font-weight: 500;
}

.stock-refresh-progress {
  margin: 0 0 12px;
}

.stock-refresh-progress:not(.hidden) {
  display: flex;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
}

.data-table th,
.data-table td {
  padding: 10px 12px;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

.data-table th {
  color: var(--muted);
  font-weight: 500;
  font-size: 0.8rem;
}

.rules-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.rules-item {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 14px;
}

.rules-item__head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
}

.rules-item__actions {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-shrink: 0;
}

.rules-item__toggle {
  width: auto;
}

.rules-item__toggle:not(.btn--primary) {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--border);
}

.rules-item__toggle:not(.btn--primary):hover:not(:disabled) {
  border-color: var(--muted);
}

.rules-item__meta {
  display: block;
  color: var(--muted);
  font-size: 0.82rem;
  margin-top: 4px;
}

.rules-item__text {
  margin: 8px 0 4px;
}

.rules-item__edit {
  margin-top: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.rules-item__edit .btn {
  align-self: flex-start;
  width: auto;
}

.rules-exclusion-scroll {
  margin-top: 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-2);
  overflow: hidden;
}

.rules-exclusion-list {
  --exclusion-row-height: 2rem;
  --exclusion-row-gap: 0.5rem;
  list-style: none;
  margin: 0;
  padding: 8px 10px;
  display: flex;
  flex-direction: column;
  gap: var(--exclusion-row-gap);
  max-height: calc(var(--exclusion-row-height) * 10 + var(--exclusion-row-gap) * 9);
  overflow-y: auto;
  overscroll-behavior: contain;
}

.rules-exclusion-empty {
  padding: 4px 2px;
}

.rules-exclusion-item {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: var(--exclusion-row-height);
  flex-shrink: 0;
}

.rules-exclusion-item span:first-child {
  min-width: 0;
  flex: 1 1 auto;
}

.rules-exclusion-item .muted {
  flex: 0 0 auto;
  font-size: 0.82rem;
}

.rules-conflicts {
  margin-top: 12px;
  padding: 10px 12px;
  border-radius: 8px;
  background: rgba(220, 80, 60, 0.08);
  border: 1px solid rgba(220, 80, 60, 0.25);
}

.input--narrow {
  max-width: 140px;
}

.form-stack--inline {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  align-items: center;
}

.badge {
  display: inline-block;
  padding: 3px 8px;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
}

.badge--exact { background: rgba(34, 197, 94, 0.2); color: var(--success); }
.badge--similar { background: rgba(245, 158, 11, 0.2); color: var(--warning); }
.badge--not_found { background: rgba(239, 68, 68, 0.2); color: var(--danger); }

.badge--scenario {
  display: inline-block;
  margin-right: 6px;
  margin-bottom: 2px;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  vertical-align: middle;
  white-space: nowrap;
}

.badge--scenario-a {
  background: rgba(59, 130, 246, 0.18);
  color: #60a5fa;
}

.badge--scenario-b {
  background: rgba(168, 85, 247, 0.18);
  color: #c084fc;
}

.badge--scenario-c {
  background: rgba(20, 184, 166, 0.18);
  color: #2dd4bf;
}

.tz-row__review-mark {
  color: var(--danger, #ef4444);
  font-weight: 700;
  font-size: 1.05rem;
  line-height: 1;
  margin-right: 4px;
  vertical-align: middle;
  cursor: help;
}

.tz-row__name .badge--scenario {
  margin-right: 8px;
}

.spec-compare-block {
  margin: 0 0 16px;
  padding: 12px 14px;
  border: 1px solid rgba(45, 212, 191, 0.22);
  border-radius: 10px;
  background: rgba(20, 184, 166, 0.06);
}

.spec-summary {
  margin: 0 0 10px;
  line-height: 1.45;
}

.spec-compare-block__section + .spec-compare-block__section {
  margin-top: 10px;
}

.spec-compare-block__label {
  display: block;
  margin-bottom: 6px;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.spec-requested,
.spec-diffs {
  margin: 0;
  padding-left: 18px;
}

.spec-requested li,
.spec-diffs li,
.spec-diff {
  margin-bottom: 4px;
  line-height: 1.4;
}

.spec-diff--worse {
  color: #f87171;
}

.spec-diff--missing,
.spec-diff--differs {
  color: #fbbf24;
}

.spec-diff--better {
  color: #4ade80;
}

.spec-diffs-empty {
  margin: 0;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
  margin-bottom: 20px;
}

.price-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.price-list li {
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}

.price-list li:last-child { border-bottom: none; }

.hidden { display: none !important; }

.overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 100;
  gap: 16px;
  color: #fff;
}

.overlay p {
  color: #fff;
  margin: 0;
  line-height: 1.45;
  font-size: 0.95rem;
  white-space: nowrap;
}

.spinner {
  width: 44px;
  height: 44px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

.toast {
  position: fixed;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  background: var(--surface-2);
  border: 1px solid var(--border);
  padding: 14px 20px;
  border-radius: 10px;
  box-shadow: var(--shadow);
  z-index: 101;
  max-width: min(360px, calc(100vw - 32px));
  text-align: center;
}

.toast--error { border-color: var(--danger); }

code {
  background: var(--surface-2);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 0.85em;
}

.price-actions { display: flex; gap: 6px; flex-wrap: wrap; }

.match-count {
  font-size: 0.82rem;
  font-weight: 500;
}

.match-variants {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.match-variant {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
  min-width: 0;
  overflow: hidden;
}

.match-variant__layout {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  min-width: 0;
}

.match-variant__aside {
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.match-variant__body {
  flex: 1 1 auto;
  min-width: 0;
}

.match-variant__kp-select {
  flex-shrink: 0;
}

.match-variant--primary {
  border-color: rgba(43, 130, 93, 0.55);
  background: rgba(43, 130, 93, 0.08);
}

.match-variant__head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}

.match-variant__head strong {
  flex: 1 1 180px;
  min-width: 0;
  line-height: 1.35;
}

.match-variant__score {
  color: var(--muted);
  font-size: 0.82rem;
  white-space: nowrap;
}

/* % совпадения: 60–69 красный, 70–85 жёлтый, 86–100 зелёный */
.match-pct {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 6px;
  font-size: 0.82rem;
  font-weight: 600;
  line-height: 1.35;
  white-space: nowrap;
  vertical-align: baseline;
}

.match-pct--near {
  background: rgba(220, 53, 69, 0.16);
  color: #b42318;
  border: 1px solid rgba(220, 53, 69, 0.35);
}

.match-pct--similar {
  background: rgba(250, 203, 16, 0.28);
  color: #8a6400;
  border: 1px solid rgba(250, 203, 16, 0.55);
}

.match-pct--exact {
  background: rgba(43, 130, 93, 0.16);
  color: var(--success);
  border: 1px solid rgba(43, 130, 93, 0.35);
}

.match-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.match-badge--primary {
  background: rgba(43, 130, 93, 0.2);
  color: #93c5fd;
}

.match-variant__details {
  margin: 0;
  padding-left: 18px;
  color: var(--muted);
  font-size: 0.88rem;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.match-variant__details li {
  margin: 2px 0;
  overflow-wrap: anywhere;
  word-break: break-word;
}

/* ——— Mobile / tablet ——— */
@media (max-width: 768px) {
  .layout {
    padding: 16px max(12px, env(safe-area-inset-right)) max(28px, env(safe-area-inset-bottom))
      max(12px, env(safe-area-inset-left));
  }

  .header {
    flex-direction: column;
    align-items: stretch;
    gap: 14px;
    margin-bottom: 18px;
  }

  .header__brand {
    gap: 12px;
    align-items: flex-start;
  }

  .header__logo {
    width: 44px;
    height: 44px;
    font-size: 1rem;
    flex-shrink: 0;
  }

  .header h1 {
    font-size: 1.12rem;
    line-height: 1.25;
  }

  .header__subtitle {
    font-size: 0.82rem;
    line-height: 1.35;
  }

  .header__stats {
    width: 100%;
    justify-content: flex-start;
  }

  .stat-pill:not(.stat-pill--sites) {
    flex: 1 1 calc(50% - 4px);
    min-width: 0;
    text-align: center;
    padding: 8px 10px;
    font-size: 0.78rem;
  }

  .stat-pill--sites {
    flex: 0 0 auto;
    width: fit-content;
    min-width: unset;
    max-width: 100%;
    text-align: left;
    padding: 8px 12px;
  }

  .tabs {
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    margin: 0 -4px 16px;
    padding: 0 4px 6px;
    gap: 6px;
  }

  .tabs::-webkit-scrollbar {
    display: none;
  }

  .tabs__btn {
    flex-shrink: 0;
    padding: 10px 14px;
    font-size: 0.84rem;
    white-space: nowrap;
  }

  .card {
    padding: 16px;
  }

  .card h2 {
    font-size: 1.02rem;
  }

  .upload-zone {
    padding: 10px 14px;
  }

  .upload-zone__icon {
    font-size: 1.15rem;
  }

  .checkbox {
    align-items: flex-start;
    justify-content: flex-start;
    text-align: left;
    line-height: 1.4;
  }

  .markup-bar {
    flex-wrap: wrap;
    gap: 8px;
  }

  .markup-bar__label {
    width: 100%;
    text-align: center;
  }

  .input--compact {
    flex: 1;
    min-width: 0;
    max-width: none;
    width: auto;
  }

  .markup-bar .btn--secondary {
    flex: 1;
    min-width: 120px;
  }

  .actions .btn,
  .lookup-form .btn,
  .card__head .btn,
  .form-stack .btn {
    width: 100%;
    justify-content: center;
    min-height: 44px;
  }

  .lookup-form {
    flex-direction: column;
  }

  .chat-layout {
    grid-template-columns: 1fr;
    height: var(--chat-panel-height);
  }

  .chat-sidebar {
    max-height: 180px;
  }

  .kp-history-sidebar {
    max-height: min(800px, 42vh);
    height: auto;
  }

  .kp-assistant-layout {
    height: auto;
    max-height: none;
  }

  .kp-assistant-layout #kpChatCard {
    height: min(800px, calc(100vh - 220px));
  }

  .chat-messages {
    padding: 12px 14px;
  }

  .chat-msg--user {
    max-width: 100%;
  }

  .competitor-chat-messages {
    min-height: 0;
  }

  .competitor-result-item__head {
    flex-direction: column;
    align-items: flex-start;
  }

  .competitor-result-item__price {
    white-space: normal;
  }

  .lookup-result {
    padding: 12px;
  }

  .chat-compose {
    flex-direction: column;
    align-items: stretch;
  }

  .chat-compose__send {
    width: 100%;
    justify-content: center;
  }

  .photo-modal__image {
    max-width: min(660px, 90vw);
    max-height: min(660px, 70vh);
  }

  .card__head {
    flex-direction: column;
    align-items: stretch;
  }

  .summary-metrics {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .metric__value {
    font-size: 1.2rem;
  }

  .lookup-result {
    padding: 14px;
  }

  .lookup-result__layout {
    gap: 16px;
  }

  .lookup-result__photos,
  .lookup-result__photo,
  .lookup-result__photo--thumb,
  .lookup-result__photo-btn {
    width: 100%;
    max-width: 100%;
  }

  .lookup-result__photo {
    height: auto;
    aspect-ratio: 1;
  }

  .lookup-result__photo--thumb {
    height: auto;
    aspect-ratio: 16 / 10;
  }

  .lookup-kv {
    grid-template-columns: 1fr;
    gap: 2px 0;
  }

  .lookup-kv dt {
    margin-top: 8px;
  }

  .lookup-kv dt:first-child {
    margin-top: 0;
  }

  .table-wrap {
    margin: 0 -4px;
    padding: 0 4px;
  }

  .data-table {
    font-size: 0.8rem;
  }

  .data-table th,
  .data-table td {
    padding: 8px 8px;
    vertical-align: top;
  }

  #resultsTable {
    min-width: 720px;
  }

  #pricesTable {
    min-width: 520px;
  }

  .price-actions {
    flex-direction: column;
    min-width: 108px;
  }

  .price-actions .btn {
    width: 100%;
    justify-content: center;
    min-height: 38px;
  }

  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
  }

  .stats-grid .metric__value {
    font-size: 1.1rem;
  }

  .toast {
    left: 50%;
    right: auto;
    top: 50%;
    bottom: auto;
    transform: translate(-50%, -50%);
    max-width: calc(100vw - 24px);
  }

  .overlay {
    padding: 20px;
    text-align: center;
  }

  .source-block {
    padding: 10px 12px;
    overflow-wrap: anywhere;
  }

  .source-block ul {
    padding-left: 16px;
  }
}

@media (max-width: 480px) {
  .header h1 {
    font-size: 1rem;
  }

  .stat-pill:not(.stat-pill--sites) {
    flex: 1 1 100%;
  }

  .stats-grid {
    grid-template-columns: 1fr;
  }

  .tabs__btn {
    padding: 9px 12px;
    font-size: 0.78rem;
  }

  .btn {
    font-size: 0.88rem;
  }
}

.login-page {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: #f4f6f5;
}

.login-page__header {
  background: var(--header-bg);
  color: var(--header-text);
  padding: 24px 20px;
  border-bottom: 1px solid var(--border);
  box-shadow: 0 1px 8px rgba(0, 0, 0, 0.06);
}

.login-page__header-inner {
  max-width: 520px;
  margin: 0 auto;
  text-align: center;
}

.login-page__logo {
  display: block;
  width: min(320px, 88vw);
  height: auto;
  max-height: 56px;
  margin: 0 auto;
  object-fit: contain;
}

.login-page__body {
  flex: 1;
  display: grid;
  place-items: center;
  padding: 32px 20px;
}

.login-card {
  width: min(100%, 420px);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 28px;
  box-shadow: var(--shadow);
}

.login-card h1 {
  margin: 0 0 6px;
  font-size: 1.35rem;
  color: var(--accent);
}

.login-card__brand {
  margin-bottom: 20px;
}

.login-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.login-form__field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 0.9rem;
}

.login-form__error {
  color: var(--danger);
  margin: 0;
  font-size: 0.88rem;
}

.login-form__submit {
  width: 100%;
  justify-content: center;
  text-align: center;
}

.chat-header__row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
}

.col-actions {
  width: 48px;
  text-align: right;
}

.user-actions {
  position: relative;
  display: inline-flex;
  justify-content: flex-end;
}

.history-actions {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  justify-content: flex-end;
}

.history-delete-btn {
  color: var(--danger);
  border: none;
  background: transparent;
  font-size: 1.35rem;
  line-height: 1;
  padding: 4px 8px;
  cursor: pointer;
  border-radius: 8px;
}

.history-delete-btn:hover {
  background: rgba(220, 53, 69, 0.12);
}

.btn--icon {
  min-width: 36px;
  padding: 6px 10px;
  font-size: 1.1rem;
  line-height: 1;
}

.user-menu {
  position: absolute;
  top: calc(100% + 4px);
  right: 0;
  min-width: 220px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: var(--shadow);
  z-index: 30;
  overflow: hidden;
}

.user-menu__item {
  display: block;
  width: 100%;
  padding: 10px 14px;
  border: 0;
  background: transparent;
  color: var(--text);
  text-align: left;
  cursor: pointer;
  font: inherit;
}

.user-menu__item:hover {
  background: rgba(43, 130, 93, 0.12);
}

.user-menu__item--danger {
  color: var(--danger);
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 120;
  display: grid;
  place-items: center;
  padding: 20px;
}

.modal__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
}

.modal__dialog {
  position: relative;
  width: min(100%, 480px);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: var(--shadow);
}

.modal__dialog--wide {
  width: min(100%, 720px);
  max-height: min(86vh, 900px);
  overflow: auto;
}

.modal__actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 20px;
}

.btn-link,
.kp-quote-expand {
  display: inline-block;
  margin-top: 0.35rem;
  padding: 0;
  border: 0;
  background: transparent;
  color: #2b5f9e;
  font: inherit;
  font-size: 12px;
  text-decoration: underline;
  cursor: pointer;
}

.btn-link:hover,
.kp-quote-expand:hover {
  color: #1d4575;
}

.kp-kit-sub-compose {
  margin: 0.35rem 0 1rem;
  padding: 0.65rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--surface) 92%, var(--accent) 8%);
}

.kp-kit-sub-compose .compare-block__subtitle {
  margin: 0 0 0.35rem;
  font-size: 0.95rem;
}

.kp-kit-whole-matches {
  margin-top: 0.75rem;
}

.kp-kit-sub-row--expandable .kp-kit-name-cell {
  cursor: pointer;
}

.compare-table--kit-sub {
  margin-top: 0.35rem;
}

.kp-kit-compare-list {
  margin: 0.25rem 0 0;
  padding-left: 1.1rem;
  font-size: 12px;
  line-height: 1.35;
}

.kp-kit-compare-item--matched {
  color: #1b7a3d;
}

.kp-kit-compare-item--missing {
  color: #b42318;
}

.kp-kit-compare-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
  margin-top: 0.35rem;
}

.kp-kit-compare__side-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

.kp-kit-compare__side-label--ok {
  color: #1b7a3d;
}

.kp-kit-compare__side-label--bad {
  color: #b42318;
}

.kp-kit-compare__note {
  margin-top: 0.4rem;
  font-size: 12px;
  color: var(--muted, #667085);
}

.kp-kit-compare__extra {
  margin-top: 0.35rem;
  font-size: 12px;
}

.kp-source-cell {
  min-width: 7.5rem;
  max-width: 14rem;
}

.kp-source-cell__label {
  font-weight: 600;
  line-height: 1.25;
}

.kp-source-cell__preview {
  margin-top: 0.2rem;
  font-size: 12px;
  line-height: 1.35;
  word-break: break-word;
}

.kp-source-col {
  max-width: 14rem;
  vertical-align: top;
}

.quote-details-modal {
  width: min(96vw, 960px);
  max-height: min(90vh, 980px);
  overflow-x: hidden;
  overflow-y: auto;
  padding: 28px 28px 24px;
  box-sizing: border-box;
}

.quote-details-modal > .photo-modal__close {
  top: 10px;
  right: 10px;
}

.quote-details-modal h3 {
  margin: 0 2.5rem 0.45rem 0;
  padding-right: 0.5rem;
  font-size: calc(1.15rem + 1px);
  line-height: 1.3;
  word-break: break-word;
}

.quote-details-modal #quoteDetailsSubtitle {
  font-size: calc(0.9rem + 1px);
  margin: 0 2.5rem 0.25rem 0;
  word-break: break-word;
}

.quote-details-modal__body {
  margin-top: 0.85rem;
  font-size: calc(0.92rem + 1px);
  line-height: 1.45;
  overflow-x: hidden;
  max-width: 100%;
  word-break: break-word;
  overflow-wrap: anywhere;
}

.quote-details-modal__body .kp-quote-block__label {
  font-size: calc(0.82rem + 1px);
}

.quote-details-modal__body .kp-quote-description,
.quote-details-modal__body .kp-quote-description--full,
.quote-details-modal__body .kp-quote-spec-list,
.quote-details-modal__body .kp-quote-kit-list,
.quote-details-modal__body .kp-kit-compare-list,
.quote-details-modal__body .kp-kit-compare__note,
.quote-details-modal__body .kp-kit-compare__extra,
.quote-details-modal__body a {
  font-size: calc(0.92rem + 1px);
  max-width: 100%;
}

.quote-details-modal__body .kp-quote-card-meta--full,
.quote-details-modal__body .kp-quote-description--full {
  max-width: 100%;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.quote-details-modal .kp-kit-compare-grid {
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  max-width: 100%;
}

.quote-details-modal .modal__actions {
  margin-top: 1.25rem;
}

.quote-details-modal .modal__actions .btn {
  font-size: calc(0.92rem + 1px);
}

@media (max-width: 640px) {
  .quote-details-modal .kp-kit-compare-grid {
    grid-template-columns: 1fr;
  }
}

.kp-quote-card-meta--full {
  max-width: none;
}

.kp-quote-description--full {
  max-width: none;
  white-space: normal;
  max-height: none;
}

.kp-quote-description--full .kp-quote-para {
  margin: 0 0 0.65em;
  line-height: 1.45;
}

.kp-quote-description--full .kp-quote-para:last-child {
  margin-bottom: 0;
}

.credentials-box code {
  font-size: 1rem;
  word-break: break-all;
}

.credentials-box p {
  margin: 8px 0;
}

@media (max-width: 768px) {
  .site-header__inner {
    padding: 12px 16px;
    flex-wrap: wrap;
  }

  .site-header__actions {
    width: 100%;
    margin-left: 0;
    justify-content: flex-end;
  }
}
