/* конкурсные закупки: сводка, этапы, таблица, окно обеспечения */
#tendersModal .modal { max-width: 1500px; width: 97vw; max-height: 92%; overflow-y: auto; }
#tendersModal [hidden] { display: none !important; }
#tendersModal .kvz-kpis, #tendersModal .kvz-tabs, #tendersModal .kvz-subtabs, #tendersModal .kvz-toolbar { flex: 0 0 auto; }
body:not(.can-kvz) #kvzDeduct, body:not(.can-kvz) #tendersModal .kvz-actions { display: none !important; }

/* карточки показателей */
.kvz-kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 10px; margin: 0 0 12px; }
.kvz-kpi { display: flex; flex-direction: column; gap: 4px; min-width: 0; padding: 10px 14px; border: 1px solid var(--ui-border); border-radius: var(--ui-radius-lg); background: var(--ui-surface); box-shadow: var(--ui-shadow-xs); }
.kvz-kpi.is-win { border-top: 3px solid var(--ui-success); }
.kvz-kpi.is-lose { border-top: 3px solid var(--ui-danger); }
.kvz-kpi-label { color: var(--ui-text-muted); font-size: 12px; font-weight: 600; }
.kvz-kpi-value { color: var(--ui-text); font-size: clamp(20px, 2vw, 26px); font-weight: 720; letter-spacing: -0.02em; line-height: 1.15; font-variant-numeric: tabular-nums; }
.kvz-kpi-value small { color: var(--ui-text-secondary); font-size: 13px; font-weight: 500; letter-spacing: 0; }
.kvz-kpi-meta { color: var(--ui-text-secondary); font-size: 12px; }
.kvz-kpi-meta b { font-variant-numeric: tabular-nums; }
.kvz-kpi.is-win .kvz-kpi-meta b { color: var(--ui-success); }
.kvz-kpi.is-lose .kvz-kpi-meta b { color: var(--ui-danger); }
.kvz-kpi-bar { height: 6px; overflow: hidden; border-radius: 3px; background: var(--ui-border); }
.kvz-kpi-bar span { display: block; width: 0; height: 100%; border-radius: inherit; transition: width .4s ease; }
.kvz-kpi.is-win .kvz-kpi-bar span { background: var(--ui-success); }
.kvz-kpi.is-lose .kvz-kpi-bar span { background: var(--ui-danger); }
#kvzDeduct .kvz-deduct-value { field-sizing: content; min-width: 3ch; max-width: 100%; height: auto; min-height: 0; margin-left: -5px; padding: 0 4px; border: 1px dashed transparent; border-radius: var(--ui-radius-sm); background: transparent; box-shadow: none; color: var(--ui-danger); font: inherit; letter-spacing: inherit; cursor: text; }
#kvzDeduct .kvz-deduct-value:hover { border-color: var(--ui-border-strong); }
#kvzDeduct .kvz-deduct-value:focus { border-style: solid; border-color: var(--ui-primary); background: var(--ui-surface); outline: none; box-shadow: 0 0 0 3px var(--ui-primary-soft); }

/* этапы процедур */
.kvz-tabs { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin: 0 0 10px; }
.kvz-tab { display: flex; align-items: center; gap: 10px; min-width: 0; min-height: 48px; padding: 6px 12px; border: 1px solid var(--ui-border); border-radius: var(--ui-radius-md); background: var(--ui-surface); color: var(--ui-text-secondary); font: inherit; text-align: left; cursor: pointer; }
.kvz-tab:hover { border-color: #a9c7eb; background: var(--ui-surface-subtle); }
.kvz-tab.on { border-color: var(--ui-primary); background: var(--ui-primary-soft); box-shadow: inset 0 0 0 1px var(--ui-primary); }
.kvz-tab-step { flex: 0 0 48px; color: var(--ui-text-muted); font-family: Georgia, "Times New Roman", serif; font-size: 28px; font-weight: 700; line-height: 1; text-align: center; }
.kvz-tab.on .kvz-tab-step { color: var(--ui-primary); }
.kvz-tab-text { display: flex; flex: 1 1 auto; flex-direction: column; min-width: 0; }
.kvz-tab-title { color: var(--ui-text); font-size: 13px; font-weight: 600; }
.kvz-tab.on .kvz-tab-title { color: var(--ui-primary); }
.kvz-tab-sub { color: var(--ui-text-muted); font-size: 11.5px; }
.kvz-tab-figs { display: flex; flex: 0 0 auto; flex-direction: column; align-items: flex-end; }
.kvz-tab-count { color: var(--ui-text); font-size: 18px; font-weight: 700; font-variant-numeric: tabular-nums; }
.kvz-tab-sum { color: var(--ui-text-muted); font-size: 11.5px; white-space: nowrap; font-variant-numeric: tabular-nums; }

/* итоги по поданным заявкам */
.kvz-subtabs { display: flex; flex-wrap: wrap; gap: 4px; width: fit-content; max-width: 100%; margin: 0 0 12px; padding: 4px; border: 1px solid var(--ui-border); border-radius: var(--ui-radius-md); background: var(--ui-surface-subtle); }
.kvz-subtab { display: inline-flex; align-items: center; gap: 6px; min-height: 30px; padding: 4px 10px; border: 0; border-radius: var(--ui-radius-sm); background: transparent; color: var(--ui-text-secondary); font: inherit; font-size: 12px; font-weight: 600; cursor: pointer; }
.kvz-subtab:hover { color: var(--ui-text); }
.kvz-subtab.on { background: var(--ui-surface); color: var(--ui-primary); box-shadow: 0 0 0 1px var(--ui-border), var(--ui-shadow-xs); }
.kvz-subtab-count { min-width: 20px; padding: 0 6px; border-radius: 999px; background: var(--ui-border); color: var(--ui-text-secondary); font-size: 11px; line-height: 18px; text-align: center; font-variant-numeric: tabular-nums; }
.kvz-subtab.on .kvz-subtab-count { background: var(--ui-primary-soft); color: var(--ui-primary); }
.kvz-dot { flex: 0 0 auto; width: 8px; height: 8px; border-radius: 50%; background: var(--ui-border-strong); }
.kvz-dot[data-tone="win"] { background: var(--ui-success); }
.kvz-dot[data-tone="lose"] { background: var(--ui-danger); }
.kvz-dot[data-tone="info"] { background: var(--ui-primary); }

/* заголовок раздела и действия над таблицей */
.kvz-toolbar { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 12px; margin: 0 0 10px; }
.kvz-toolbar-title { min-width: 0; }
.kvz-toolbar-title h3 { margin: 0; color: var(--ui-text); font-size: 15px; font-weight: 700; }
.kvz-toolbar-meta { display: block; margin-top: 2px; color: var(--ui-text-secondary); font-size: 12px; font-variant-numeric: tabular-nums; }
.kvz-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.kvz-actions .btn-mini, .kvz-actions .btn-meet { display: inline-flex; align-items: center; min-height: 34px; }
.kvz-import-label { cursor: pointer; }

/* таблица */
.kvz-wrap { overflow: auto; border: 1px solid var(--ui-border); border-radius: var(--ui-radius-md); background: var(--ui-surface); }
.kvz-table { border-collapse: separate; border-spacing: 0; table-layout: fixed; font-size: 12px; }
.kvz-table th, .kvz-table td { padding: 6px 8px; border: 0; border-bottom: 1px solid #e9edf2; background: var(--ui-surface); font-size: 12px; text-align: left; vertical-align: top; overflow-wrap: anywhere; }
.kvz-table thead th { position: sticky; top: 0; z-index: 2; border-bottom-color: var(--ui-border); background: var(--ui-surface-subtle); color: var(--ui-text-secondary); font-weight: 600; vertical-align: bottom; }
.kvz-table tbody tr:hover td { background: #f6f9fd; }
.kvz-table th:first-child, .kvz-table td:first-child { position: sticky; left: 0; z-index: 1; box-shadow: inset -1px 0 var(--ui-border); }
.kvz-table thead th:first-child { z-index: 3; }
.kvz-table tbody td:first-child { color: var(--ui-text); font-weight: 600; }
.kvz-table .kvz-num { text-align: right; font-variant-numeric: tabular-nums; }
.kvz-table .kvz-num input { text-align: right; }
.kvz-table tfoot td { position: sticky; bottom: 0; z-index: 2; border-top: 1px solid var(--ui-border); border-bottom: 0; background: var(--ui-surface-subtle); font-weight: 700; }
.kvz-table tfoot td:first-child { left: auto; box-shadow: none; text-align: right; }
.kvz-table td.kvz-empty { position: static; padding: 32px 16px; box-shadow: none; color: var(--ui-text-secondary); font-weight: 400; text-align: center; }

/* поля в ячейках: рамка только при наведении и фокусе */
.kvz-table .kvz-edit { width: 100%; min-width: 0; min-height: 28px; box-sizing: border-box; padding: 4px 6px; border: 1px solid transparent; border-radius: var(--ui-radius-sm); background: transparent; color: inherit; font: inherit; font-size: 12px; }
.kvz-table textarea.kvz-edit { field-sizing: content; resize: vertical; line-height: 1.35; }
.kvz-table .kvz-edit:hover { border-color: var(--ui-border-strong); background: var(--ui-surface); }
.kvz-table .kvz-edit:focus { border-color: var(--ui-primary); background: var(--ui-surface); outline: none; box-shadow: 0 0 0 3px var(--ui-primary-soft); }

/* статус заявки */
.kvz-status { display: inline-flex; align-items: center; min-height: 24px; padding: 2px 10px; border: 1px solid #cfd5de; border-radius: 999px; background: #eef0f3; color: var(--ui-text); font-size: 12px; font-weight: 600; white-space: nowrap; }
.kvz-table select.kvz-status { width: auto; max-width: 100%; padding-right: 22px; border-color: #cfd5de; background: #eef0f3; cursor: pointer; }
.kvz-table select.kvz-status[data-tone=""] { border-style: dashed; background: transparent; color: var(--ui-text-muted); }
.kvz-status[data-tone="work"], .kvz-table select.kvz-status[data-tone="work"] { border-color: #e3c25a; background: var(--ui-warning-soft); color: var(--ui-warning); }
.kvz-status[data-tone="sent"], .kvz-table select.kvz-status[data-tone="sent"] { border-color: #a9c7eb; background: var(--ui-primary-soft); color: var(--ui-primary); }
.kvz-status[data-tone="win"], .kvz-table select.kvz-status[data-tone="win"] { border-color: #8fd0a8; background: var(--ui-success-soft); color: #1e7a44; }
.kvz-status[data-tone="lose"], .kvz-table select.kvz-status[data-tone="lose"] { border-color: #f0c0c0; background: var(--ui-danger-soft); color: var(--ui-danger); }

/* примечания */
.kvz-note-list { display: grid; gap: 4px; margin: 0; padding: 0; list-style: none; }
.kvz-note-list li { display: flex; align-items: flex-start; justify-content: space-between; gap: 6px; color: var(--ui-text); line-height: 1.35; }
.kvz-note-when { margin-right: 6px; color: var(--ui-text-muted); white-space: nowrap; font-variant-numeric: tabular-nums; }
.kvz-note-del { flex: 0 0 auto; padding: 0 4px; border: 0; border-radius: 4px; background: none; color: var(--ui-text-muted); cursor: pointer; }
.kvz-note-del:hover { background: var(--ui-danger-soft); color: var(--ui-danger); }
.kvz-note-add { display: flex; gap: 4px; margin-top: 4px; }
.kvz-note-add input { min-width: 0; min-height: 26px; box-sizing: border-box; padding: 2px 6px; border: 1px solid var(--ui-border); border-radius: var(--ui-radius-sm); background: var(--ui-surface); font: inherit; font-size: 12px; }
.kvz-note-add .kvz-note-date { flex: 0 0 118px; }
.kvz-note-add .kvz-note-text { flex: 1 1 auto; }
.kvz-note-add-btn { flex: 0 0 auto; padding: 2px 10px; }

/* обеспечение в ячейке и удаление строки */
.kvz-secure-cell .kvz-note-list { margin-bottom: 6px; color: var(--ui-text-secondary); }
.kvz-secure-open { min-height: 26px; padding: 2px 10px; border: 1px solid var(--ui-border-strong); border-radius: var(--ui-radius-sm); background: var(--ui-surface); color: var(--ui-primary); font: inherit; font-size: 12px; font-weight: 600; cursor: pointer; }
.kvz-secure-open:hover { border-color: #a9c7eb; background: var(--ui-primary-soft); }
.kvz-table .kvz-del { width: 28px; height: 28px; border: 0; border-radius: var(--ui-radius-sm); background: none; color: var(--ui-text-muted); font-size: 16px; cursor: pointer; opacity: .5; }
.kvz-table tr:hover .kvz-del, .kvz-table .kvz-del:focus-visible { opacity: 1; }
.kvz-table .kvz-del:hover { background: var(--ui-danger-soft); color: var(--ui-danger); }

/* окно общее обеспечение */
#kvzSecureModal .modal { width: 1280px; max-width: 96vw; }
.kvz-sec-hang { margin: 0 0 16px; padding: 10px 14px; border: 1px solid #e3c25a; border-radius: var(--ui-radius-md); background: var(--ui-warning-soft); color: var(--ui-text); font-size: 14px; }
#kvzSecureBody { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 320px), 1fr)); gap: 16px; align-items: start; }
.kvz-sec-block { min-width: 0; overflow-x: auto; padding: 16px; border: 1px solid var(--ui-border); border-radius: var(--ui-radius-md); background: var(--ui-surface-subtle); }
.kvz-sec-title { margin: 0 0 12px; color: var(--ui-text); font-size: 14px; font-weight: 700; }
.kvz-sec-extra { display: flex; flex-direction: column; gap: 10px; margin: 0 0 12px; font-size: 13px; }
.kvz-sec-extra label { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.kvz-sec-extra input[type="date"] { min-height: 32px; padding: 4px 8px; border: 1px solid var(--ui-border-strong); border-radius: var(--ui-radius-sm); background: var(--ui-surface); font: inherit; }
.ks-payfile { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.ks-payfile a { color: var(--ui-primary); overflow-wrap: anywhere; }
.ks-file-up { cursor: pointer; }
.kvz-secure-table { width: 100%; margin: 0 0 12px; border-collapse: collapse; background: var(--ui-surface); font-size: 13px; }
.kvz-secure-table th, .kvz-secure-table td { padding: 6px 8px; border: 0; border-bottom: 1px solid #e9edf2; font-size: 13px; text-align: left; }
.kvz-secure-table th { background: var(--ui-surface-subtle); color: var(--ui-text-secondary); font-size: 12px; font-weight: 600; }
.kvz-secure-table .ks-del, .ks-file-del { border: 0; background: none; color: var(--ui-danger); font-size: 14px; cursor: pointer; }
.kvz-secure-add { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.kvz-secure-add select, .kvz-secure-add input { min-width: 0; min-height: 32px; padding: 5px 8px; border: 1px solid var(--ui-border-strong); border-radius: var(--ui-radius-sm); background: var(--ui-surface); font: inherit; font-size: 13px; }
.kvz-secure-add select { flex: 1 1 100%; }
.kvz-secure-add input { flex: 1 1 120px; }

@media (max-width: 900px) {
  .kvz-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .kvz-tabs, .kvz-subtabs { display: flex; flex-wrap: nowrap; min-width: 0; overflow-x: auto; overscroll-behavior-inline: contain; }
  .kvz-tab { flex: 0 0 min(82vw, 280px); min-height: 44px; }
  .kvz-subtab { flex: 0 0 auto; min-height: 44px; }
  .kvz-toolbar { flex-direction: column; align-items: stretch; }
  .kvz-actions > * { flex: 1 1 auto; justify-content: center; }
  .kvz-table th:first-child, .kvz-table td:first-child { position: static; box-shadow: none; }
}
@media (max-width: 640px) {
  .kvz-kpis { grid-template-columns: minmax(0, 1fr); }
}
