/* =========================================================================
 * Tenders. The catalog is a canonical data list; the procurement page is a
 * record page. This file owns only the column track, the facts inside a row
 * and the parts of the AI reading.
 * ========================================================================= */

/*
 * Закупівля | Стан | Бюджет | Замовник для нас | дія.
 * The subject and the buyer are what the list is scanned for, so they take
 * the width; the state of the buyer for sales — new, in CRM, already a
 * client — stands last, right before the action that follows from it.
 */
.tenders-list .fs-datalist__head,
.tenders-list .fs-datalist__row {
  grid-template-columns:
    minmax(0, 3fr)
    minmax(150px, 1fr)
    minmax(120px, 0.8fr)
    minmax(132px, 0.8fr)
    52px;
  gap: var(--fs-space-3);
}

.tenders-list .fs-datalist__row {
  align-items: start;
  padding-top: 12px;
  padding-bottom: 12px;
}

.tender-cell {
  display: grid;
  gap: 4px;
  align-content: start;
  min-width: 0;
}

.tender-cell--number {
  justify-items: end;
  text-align: right;
}

/* On desktop the column title already names the value. */
.tender-cell__label {
  display: none;
}

.tender-title {
  color: var(--fs-color-text);
  font-weight: 600;
  line-height: 1.35;
  overflow-wrap: anywhere;
  text-decoration: none;
}

a.tender-title:hover {
  color: var(--fs-color-primary-text);
  text-decoration: underline;
}

.tender-buyer {
  display: flex;
  align-items: flex-start;
  gap: 6px;
  min-width: 0;
  color: var(--fs-color-text-secondary);
  font-size: var(--fs-text-sm);
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.tender-glyph {
  display: inline-block;
  width: 14px;
  height: 14px;
  flex: 0 0 14px;
  margin-top: 1px;
  background: var(--fs-color-text-muted);
  mask: var(--tender-glyph) center / 14px 14px no-repeat;
  -webkit-mask: var(--tender-glyph) center / 14px 14px no-repeat;
}

.tender-summary-line {
  color: var(--fs-color-text-secondary);
  font-size: var(--fs-text-xs);
  line-height: 1.45;
}

.tender-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 6px;
  margin-top: 2px;
}

/* A preferred region is a fact worth seeing first, said as a primary badge rather than a colour of its own. */
.tender-region {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: var(--fs-color-text-secondary);
  font-size: var(--fs-text-xs);
}

.tender-small {
  color: var(--fs-color-text-secondary);
  font-size: var(--fs-text-xs);
  line-height: 1.4;
  font-variant-numeric: tabular-nums;
}

.tender-small[data-state="soon"] {
  color: var(--fs-color-warning-text);
  font-weight: 600;
}

/* A contractor row lists its latest won works under the name: title as a link, buyer and sum beneath. */
.contractor-wins {
  display: grid;
  gap: 6px;
  margin: 4px 0 0;
  padding: 0;
  list-style: none;
}

.contractor-wins li {
  display: grid;
  gap: 1px;
  min-width: 0;
  font-size: var(--fs-text-xs);
  line-height: 1.4;
  overflow-wrap: anywhere;
}

.contractor-wins .tender-link {
  font-size: var(--fs-text-xs);
  white-space: normal;
}

.contractors-list .fs-datalist__row-actions form {
  display: contents;
}

/* ---------------------------------------------------------------- record page */

.tender-reading {
  display: grid;
  gap: var(--fs-space-3);
  padding: 12px 14px 14px;
  background: var(--fs-color-selected-subtle);
  border: 1px solid var(--fs-color-primary-line);
  border-radius: var(--fs-radius-control);
}

.tender-reading__head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--fs-space-2);
}

.tender-reading__label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--fs-color-primary-text);
  font-size: var(--fs-text-xs);
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}


.tender-reading__summary {
  font-size: var(--fs-text-md);
  font-weight: 500;
  line-height: 1.55;
}

.tender-reading__part {
  display: grid;
  gap: 4px;
}

.tender-reading__title {
  color: var(--fs-color-text-secondary);
  font-size: var(--fs-text-xs);
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.tender-reading__text {
  font-size: var(--fs-text-sm);
  line-height: 1.5;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.tender-items__row {
  grid-template-columns: 32px minmax(0, 1fr);
  font-size: var(--fs-text-sm);
  line-height: 1.45;
}

.tender-items__number {
  color: var(--fs-color-text-muted);
  font-variant-numeric: tabular-nums;
}

.tender-documents__row,
.tender-awards__row,
.tender-related__row {
  grid-template-columns: minmax(0, 1fr) auto;
  font-size: var(--fs-text-sm);
}

.tender-documents__body {
  display: grid;
  gap: 4px;
  min-width: 0;
}

.tender-documents__title {
  font-weight: 600;
  overflow-wrap: anywhere;
}

.tender-documents__summary {
  color: var(--fs-color-text-secondary);
  font-size: var(--fs-text-sm);
  line-height: 1.5;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.tender-link {
  color: var(--fs-color-primary-text);
  font-size: var(--fs-text-sm);
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
}

.tender-link:hover {
  text-decoration: underline;
}

.tender-facts {
  display: grid;
  gap: 10px;
  margin: 0;
}

/*
 * A fact as a field of the product: its glyph and its name on one line, the value under them from the left
 * edge (рішення 2026-10-18). The glyph says what kind of fact it is before the words are read.
 */
.tender-facts div {
  display: grid;
  gap: 3px;
}

.tender-facts dt {
  display: flex;
  align-items: center;
  gap: 7px;
  color: var(--fs-color-text-secondary);
  font-size: var(--fs-text-xs);
  font-weight: 600;
}

.tender-facts dt::before {
  width: 15px;
  height: 15px;
  flex: 0 0 15px;
  background: var(--fs-color-text-secondary);
  mask: var(--tender-fact-icon, none) center / 15px 15px no-repeat;
  -webkit-mask: var(--tender-fact-icon, none) center / 15px 15px no-repeat;
  content: "";
}

.tender-facts dd {
  margin: 0;
  font-size: var(--fs-text-sm);
  font-weight: 500;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.tender-facts dd a {
  color: var(--fs-color-primary-text);
  text-decoration: none;
}

.tender-facts dd a:hover {
  text-decoration: underline;
}

.tender-sources {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.tender-crm {
  display: grid;
  gap: var(--fs-space-2);
  padding-top: var(--fs-space-2);
  border-top: 1px solid var(--fs-color-border-subtle);
}

.tender-crm form {
  display: contents;
}

/* ---------------------------------------------------------------- phone */

@media (max-width: 760px) {
  .tenders-list .fs-datalist__head {
    display: none;
  }

  .tenders-list .fs-datalist__row {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    row-gap: var(--fs-space-3);
  }

  .tenders-list .tender-cell--subject {
    grid-column: 1 / -1;
  }

  .tender-cell--number {
    justify-items: start;
    text-align: left;
  }

  .tender-cell__label {
    display: block;
    color: var(--fs-color-text-secondary);
    font-size: var(--fs-text-xs);
  }

  .tenders-list .fs-datalist__row-actions {
    grid-column: 2;
    justify-content: flex-end;
  }
}

/* ---------------------------------------------------------------- settings page */

/*
 * One form in sections (перероблено 2026-10-20). A section is a decision: a sign on a tinted tile, a name, and —
 * while it is folded — one quiet line that tells its state, so an administrator reads the page like a table of
 * contents and opens only what is to change. What is folded still submits with the form.
 */
.tender-settings__form {
  gap: var(--fs-space-4);
}

/* Whether the saved or the configured conditions apply, said once above the form. */
.tender-settings__state {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  color: var(--fs-color-text-secondary);
  font-size: var(--fs-text-sm);
}

.tender-settings__section {
  border: 1px solid var(--fs-color-border-subtle);
  border-radius: var(--fs-radius-card);
  background: var(--fs-color-surface);
}

.tender-settings__head {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 56px;
  padding: 10px 16px;
  list-style: none;
  cursor: pointer;
}

.tender-settings__head::-webkit-details-marker {
  display: none;
}

@media (hover: hover) {
  .tender-settings__head:hover {
    background: var(--fs-color-surface-hover);
    border-radius: var(--fs-radius-card);
  }
}

.tender-settings__head:focus-visible {
  outline: 0;
  box-shadow: var(--fs-focus-ring);
  border-radius: var(--fs-radius-card);
}

/* The sign of a section: the glyph masked onto a tinted tile, as the head of a dialog carries its sign. */
.tender-settings__icon {
  position: relative;
  flex: 0 0 36px;
  width: 36px;
  height: 36px;
  background: var(--fs-color-primary-subtle);
  border: 1px solid var(--fs-color-primary-line);
  border-radius: var(--fs-radius-md);
}

.tender-settings__icon::after {
  position: absolute;
  inset: 0;
  background: var(--fs-color-primary-text);
  mask: var(--tender-settings-icon) center / 20px 20px no-repeat;
  -webkit-mask: var(--tender-settings-icon) center / 20px 20px no-repeat;
  content: "";
}

.tender-settings__icon--sm {
  flex-basis: 30px;
  width: 30px;
  height: 30px;
}

.tender-settings__icon--sm::after {
  mask-size: 17px 17px;
  -webkit-mask-size: 17px 17px;
}

.tender-settings__title {
  flex: 0 1 auto;
  min-width: 0;
  font-size: var(--fs-text-md);
  font-weight: 600;
}

.tender-settings__meta {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  color: var(--fs-color-text-muted);
  font-size: var(--fs-text-sm);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tender-settings__chevron {
  width: 16px;
  height: 16px;
  flex: 0 0 16px;
  background: var(--fs-color-text-secondary);
  mask: url("/stoneware/icons/chevron.svg") center / 16px 16px no-repeat;
  -webkit-mask: url("/stoneware/icons/chevron.svg") center / 16px 16px no-repeat;
  transform: rotate(-90deg);
  transition: transform 0.14s ease;
}

.tender-settings__section[open] > .tender-settings__head .tender-settings__chevron {
  transform: none;
}

.tender-settings__section[open] > .tender-settings__head {
  border-bottom: 1px solid var(--fs-color-border-subtle);
  border-radius: var(--fs-radius-card) var(--fs-radius-card) 0 0;
}

.tender-settings__body {
  display: grid;
  gap: var(--fs-space-4);
  padding: var(--fs-space-4) 16px;
}

.tender-settings__subhead {
  margin: 0;
}

.tender-settings__number input {
  max-width: 220px;
}

/* The sources: one card each — its sign, name and a line about it, how its last run went, its limit. */
.tender-sources-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: var(--fs-space-3);
}

.tender-source-card {
  display: grid;
  gap: 10px;
  min-width: 0;
  padding: 14px 16px;
  background: var(--fs-color-surface-subtle);
  border: 1px solid var(--fs-color-border-subtle);
  border-radius: var(--fs-radius-card);
}

.tender-source-card__head {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  min-width: 0;
}

.tender-source-card__name {
  display: grid;
  flex: 1 1 auto;
  gap: 2px;
  min-width: 0;
}

.tender-source-card__state {
  display: flex;
  flex: 0 0 auto;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
  max-width: 45%;
}

.tender-source-card__note {
  margin: 0;
  color: var(--fs-color-text-secondary);
  font-size: var(--fs-text-xs);
  line-height: 1.45;
}

.tender-source-card__members {
  display: grid;
  gap: 6px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.tender-source-card__members li {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  font-size: var(--fs-text-xs);
  color: var(--fs-color-text-secondary);
}

.tender-source-card__members strong {
  color: var(--fs-color-text);
}

.tender-source-card__limit input {
  max-width: 160px;
  background: var(--fs-color-surface);
}

/* The product groups: a row is a name, its stems and its branches; the cross at the end takes the row away. */
.tender-groups__row {
  grid-template-columns: minmax(150px, 0.8fr) minmax(0, 1.6fr) minmax(0, 1fr) 28px;
  align-items: start;
}

.tender-groups__cell > span:first-child {
  display: none;
}

.tender-groups__remove {
  display: inline-grid;
  place-items: center;
  width: 28px;
  height: 28px;
  margin-top: 6px;
  padding: 0;
  color: var(--fs-color-text-muted);
  background: transparent;
  border: 0;
  border-radius: 50%;
  cursor: pointer;
}

.tender-groups__remove::before {
  width: 14px;
  height: 14px;
  background: currentcolor;
  mask: url("/stoneware/icons/close.svg") center / contain no-repeat;
  content: "";
}

@media (hover: hover) {
  .tender-groups__remove:hover {
    color: var(--fs-color-danger);
    background: var(--fs-color-surface-hover);
  }
}

.tender-groups__remove:focus-visible {
  outline: 0;
  box-shadow: var(--fs-focus-ring);
}

/* Cleaning: the age, what it takes, the button; the reset below it on its own, set off by a hairline. */
.tender-cleanup {
  display: grid;
  gap: var(--fs-space-3);
}

.tender-cleanup--reset {
  padding-top: var(--fs-space-4);
  border-top: 1px solid var(--fs-color-border-subtle);
}

.tender-cleanup__note {
  margin: 0;
  color: var(--fs-color-text-secondary);
  font-size: var(--fs-text-sm);
  line-height: 1.5;
}

.tender-cleanup .fs-form-actions {
  justify-content: flex-start;
}

/* On a phone a group is a short stack with its own captions; the list head, which named the columns, goes. */
@media (max-width: 760px) {
  .tender-groups__row {
    grid-template-columns: minmax(0, 1fr) 28px;
  }

  .fs-nested-list__head.tender-groups__row {
    display: none;
  }

  .tender-groups__cell {
    grid-column: 1;
  }

  .tender-groups__cell > span:first-child {
    display: block;
  }

  .tender-groups__remove {
    grid-column: 2;
    grid-row: 1;
    margin-top: 0;
  }

  .tender-settings__number input,
  .tender-source-card__limit input {
    max-width: none;
  }

  .tender-settings__meta {
    display: none;
  }

  .tender-source-card__state {
    max-width: none;
  }
}
