:root {
  --bg: #f1f5f7;
  --panel: rgba(255, 255, 255, 0.74);
  --panel-strong: rgba(255, 255, 255, 0.9);
  --ink: #172026;
  --muted: #65737b;
  --line: rgba(216, 224, 228, 0.86);
  --accent: #2f6f8f;
  --accent-strong: #245f7c;
  --accent-soft: rgba(231, 243, 247, 0.9);
  --warn-soft: rgba(255, 243, 216, 0.86);
  --blue-soft: rgba(229, 240, 255, 0.86);
  --danger: #b23b3b;
  --danger-soft: rgba(255, 231, 231, 0.9);
  --shadow: 0 22px 60px rgba(23, 32, 38, 0.1);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.66), rgba(241, 245, 247, 0.92)),
    var(--bg);
  color: var(--ink);
}

body.auth-pending {
  overflow: hidden;
}

body.auth-pending .app-shell {
  display: none;
}

body:not(.auth-pending) .auth-screen {
  display: none;
}

.auth-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 28px;
}

.auth-card {
  width: min(360px, 100%);
  display: grid;
  gap: 18px;
  padding: 26px;
  background: rgba(255, 255, 255, 0.72);
  border: 1px solid rgba(160, 178, 181, 0.34);
  border-radius: 8px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.auth-card .primary-btn {
  justify-content: center;
}

.auth-error {
  margin: 0;
  color: #9f2d2d;
  font-weight: 700;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 20;
  pointer-events: none;
  opacity: 0;
  background: rgba(241, 245, 247, 0.16);
  backdrop-filter: blur(0);
  transition:
    opacity 0.32s ease,
    backdrop-filter 0.32s ease;
}

body.modal-blur::before {
  opacity: 1;
  backdrop-filter: blur(5px);
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  display: grid;
  grid-template-columns: 228px minmax(0, 1fr);
  min-height: 100vh;
  gap: 0;
}

.sidebar {
  position: sticky;
  top: 0;
  isolation: isolate;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  gap: 24px;
  height: 100vh;
  padding: 22px;
  background: #1f2933;
  color: #f6fafc;
}

.sidebar::before,
.sidebar::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.sidebar::before {
  z-index: -2;
  background:
    radial-gradient(circle at 18% 14%, rgba(52, 127, 159, 0.34), transparent 34%),
    radial-gradient(circle at 86% 22%, rgba(47, 122, 115, 0.28), transparent 32%),
    radial-gradient(circle at 60% 82%, rgba(63, 95, 116, 0.3), transparent 36%),
    radial-gradient(circle at 8% 92%, rgba(87, 116, 126, 0.22), transparent 34%),
    linear-gradient(160deg, #1f2933 0%, #24313d 54%, #1c3037 100%);
}

.sidebar::after {
  z-index: -1;
  background:
    linear-gradient(180deg, rgba(31, 41, 51, 0.4), rgba(31, 41, 51, 0.7)),
    rgba(255, 255, 255, 0.03);
}

.sidebar > * {
  position: relative;
  z-index: 1;
}

.sidebar-note span {
  color: #c3d1d8;
}

.nav-list {
  display: grid;
  gap: 8px;
}

.sidebar-actions {
  margin-top: auto;
  display: grid;
  gap: 8px;
}

.sidebar-logout,
.nav-item {
  width: 100%;
  min-height: 42px;
  padding: 9px 12px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.07);
  color: #d7e3e9;
  font-weight: 600;
  text-align: center;
  transition:
    background 0.15s ease,
    color 0.15s ease,
    border-color 0.15s ease;
}

.sidebar-logout:hover,
.nav-item:hover,
.nav-item.active {
  background: rgba(52, 127, 159, 0.2);
  border-color: rgba(231, 243, 247, 0.28);
  color: #ffffff;
}

.nav-item {
  display: block;
}

.sidebar-note {
  margin-top: auto;
  display: grid;
  gap: 8px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 8px;
  padding: 14px;
  background: rgba(255, 255, 255, 0.06);
}

.main {
  min-width: 0;
  height: 100vh;
  padding: 38px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.topbar,
.toolbar,
.section-heading,
.modal-header,
.modal-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.topbar {
  flex: 0 0 auto;
}

.modal-header > div {
  min-width: 0;
  flex: 1 1 auto;
  max-width: none;
}

.modal-subtitle {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 0.92rem;
  line-height: 1.45;
}

.modal-header {
  align-items: flex-start;
}

.modal-header-actions {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 8px;
}

.modal-header .icon-btn {
  flex: 0 0 auto;
}

.details-panel > .modal-header {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: start;
}

.details-panel > .modal-header > div {
  min-width: 0;
}

.details-panel .modal-header-actions {
  min-width: max-content;
}

#detailsTitle {
  max-width: 100%;
  overflow-wrap: anywhere;
  word-break: break-word;
  min-width: 0;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
h3 {
  margin: 0;
  line-height: 1.15;
}

h1 {
  font-size: 34px;
}

h2 {
  font-size: 25px;
}

h3 {
  font-size: 17px;
}

.primary-btn,
.secondary-btn,
.ghost-btn,
.icon-btn,
.danger-btn,
.segment {
  min-height: 40px;
  border-radius: 8px;
  border: 1px solid transparent;
  padding: 0 14px;
  font-weight: 700;
}

.primary-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--accent);
  color: #ffffff;
}

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

.secondary-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border-color: var(--line);
  background: rgba(255, 255, 255, 0.62);
  color: var(--accent);
  text-decoration: none;
}

.ghost-btn,
.icon-btn {
  border-color: var(--line);
  background: rgba(255, 255, 255, 0.36);
  color: var(--ink);
}

.danger-btn {
  border-color: rgba(178, 59, 59, 0.18);
  background: var(--danger-soft);
  color: var(--danger);
}

.icon-btn {
  width: 40px;
  padding: 0;
  font-size: 24px;
}

.stats-row {
  flex: 0 0 auto;
  display: flex;
  align-items: flex-end;
  gap: 18px;
  margin: 12px 0 22px;
}

.stat {
  position: relative;
  isolation: isolate;
  display: flex;
  align-items: flex-end;
  flex: 0 0 214px;
  width: 214px;
  min-height: 150px;
  overflow: visible;
  border-radius: 8px;
  padding: 22px 24px;
  background: transparent;
}

.stat span {
  position: absolute;
  left: 24px;
  bottom: -2px;
  z-index: 2;
  color: var(--ink);
  font-size: 15px;
  font-weight: 800;
  line-height: 1.15;
  white-space: nowrap;
}

.stat strong {
  position: absolute;
  right: -6px;
  bottom: -4px;
  z-index: 1;
  color: rgba(47, 111, 143, 0.16);
  font-size: 124px;
  font-weight: 900;
  line-height: 0.9;
  pointer-events: none;
  user-select: none;
}

.toolbar {
  flex: 0 0 auto;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

#projectToolbar {
  justify-content: flex-start;
  flex-wrap: nowrap;
}

#projectToolbar .segmented,
#projectToolbar #statusFilter {
  flex: 0 0 204px;
  width: 204px;
}

#projectToolbar .segmented {
  display: none;
}

#projectToolbar .segment {
  flex: 1 1 50%;
  padding: 0 10px;
  white-space: nowrap;
}

#projectToolbar .search-field {
  flex: 0 1 620px;
  width: 620px;
  max-width: 620px;
}

#projectToolbar .project-toolbar-add {
  flex: 0 0 auto;
  margin-left: auto;
  justify-content: center;
  white-space: nowrap;
}

@media (min-width: 861px) {
  #openCreateModal {
    display: none;
  }
}

.search-field {
  display: flex;
  align-items: center;
  flex: 1 1 320px;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 12px;
  background: var(--panel);
  backdrop-filter: blur(18px);
}

.search-field input {
  width: 100%;
  border: 0;
  outline: 0;
  background: transparent;
  padding: 0 10px;
}

select,
input {
  width: 100%;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  min-height: 42px;
  padding: 0 12px;
  background: rgba(255, 255, 255, 0.72);
  color: var(--ink);
}

.segmented {
  display: flex;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: var(--panel);
  backdrop-filter: blur(18px);
}

.segment {
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--muted);
}

.segment.active {
  background: var(--accent-soft);
  color: var(--accent-strong);
}

.table-wrap {
  overflow: auto;
  min-height: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.table-wrap.compact {
  box-shadow: none;
}

.project-area,
.manager-section {
  flex: 1 1 auto;
  min-height: 0;
}

.project-area,
.manager-section,
.directory-panel {
  display: flex;
  flex-direction: column;
}

.project-area > .table-wrap,
#cardView,
.empty-state,
.manager-section > .table-wrap,
.directory-panel > .table-wrap {
  flex: 1 1 auto;
  min-height: 0;
}

#cardView,
.empty-state {
  overflow: auto;
}

.manager-section .manager-header {
  flex: 0 0 auto;
}

table {
  width: 100%;
  min-width: 760px;
  border-collapse: collapse;
  table-layout: fixed;
}

th,
td {
  padding: 16px 18px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: middle;
  overflow-wrap: anywhere;
}

th {
  position: sticky;
  top: 0;
  z-index: 2;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
  background: rgba(255, 255, 255, 0.45);
}

#tableView th,
#materialsSection th,
#companiesSection th,
#peopleSection th,
#directoriesSection th {
  background: rgba(248, 251, 252, 0.86);
  backdrop-filter: blur(14px) saturate(1.08);
  -webkit-backdrop-filter: blur(14px) saturate(1.08);
  box-shadow: 0 1px 0 var(--line), 0 8px 18px rgba(23, 32, 38, 0.04);
}

tbody tr {
  transition: background 0.15s ease;
}

tbody tr:hover {
  background: rgba(231, 243, 247, 0.62);
}

tbody tr.clickable {
  cursor: pointer;
}

.project-row-meta {
  display: none;
}

.status {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 28px;
  border-radius: 999px;
  padding: 0 10px;
  background: var(--blue-soft);
  color: #254f82;
  font-size: 13px;
  font-weight: 800;
  line-height: 1;
  white-space: nowrap;
  min-width: 96px;
}

#tableView th:nth-child(1),
#tableView td:nth-child(1) {
  width: 24%;
}

#tableView th:nth-child(2),
#tableView td:nth-child(2),
#tableView th:nth-child(3),
#tableView td:nth-child(3),
#tableView th:nth-child(4),
#tableView td:nth-child(4) {
  width: 15%;
}

#tableView th:nth-child(5),
#tableView td:nth-child(5) {
  width: 14%;
}

#tableView th:nth-child(6),
#tableView td:nth-child(6) {
  width: 150px;
  text-align: center;
}

#tableView th:nth-child(7),
#tableView td:nth-child(7) {
  width: 130px;
  text-align: center;
}

#companiesSection th:nth-child(1),
#companiesSection td:nth-child(1) {
  width: 30%;
}

#companiesSection th:nth-child(2),
#companiesSection td:nth-child(2) {
  width: 12%;
}

#companiesSection th:nth-child(3),
#companiesSection td:nth-child(3) {
  width: 14%;
}

#companiesSection th:nth-child(4),
#companiesSection td:nth-child(4) {
  width: 16%;
}

#companiesSection th:nth-child(5),
#companiesSection td:nth-child(5) {
  width: 20%;
}

#companiesSection th:nth-child(6),
#companiesSection td:nth-child(6) {
  width: 92px;
  text-align: right;
}

#companiesSection .row-actions {
  justify-content: flex-end;
}

#peopleSection th:nth-child(1),
#peopleSection td:nth-child(1) {
  width: 28%;
}

#peopleSection th:nth-child(2),
#peopleSection td:nth-child(2),
#peopleSection th:nth-child(3),
#peopleSection td:nth-child(3) {
  width: 18%;
}

#peopleSection th:nth-child(4),
#peopleSection td:nth-child(4) {
  width: 28%;
}

#peopleSection th:nth-child(5),
#peopleSection td:nth-child(5) {
  width: 92px;
  text-align: right;
}

#peopleSection .row-actions {
  justify-content: flex-end;
}

#usersSection th:nth-child(5),
#usersSection td:nth-child(5) {
  width: 92px;
  text-align: right;
}

#usersSection .row-actions {
  justify-content: flex-end;
}

#materialsSection th:last-child,
#materialsSection td:last-child,
#directoriesSection th:last-child,
#directoriesSection td:last-child {
  width: 92px;
  text-align: right;
}

#materialsSection .row-actions,
#directoriesSection .row-actions {
  justify-content: flex-end;
}

#materialsSection th:nth-child(1),
#materialsSection td:nth-child(1) {
  width: 38%;
}

#materialsSection th:nth-child(2),
#materialsSection td:nth-child(2) {
  width: 18%;
}

#materialsSection th:nth-child(3),
#materialsSection td:nth-child(3) {
  width: 12%;
}

#materialsSection th:nth-child(4),
#materialsSection td:nth-child(4) {
  width: 26%;
}

.status[data-status="в работе"] {
  background: var(--accent-soft);
  color: var(--accent-strong);
}

.status[data-status="ожидание"] {
  border-color: rgba(245, 158, 11, 0.24);
  background: rgba(245, 158, 11, 0.12);
  color: #b45309;
}

.status[data-status="поставка"] {
  background: var(--warn-soft);
  color: #7a5600;
}

.status[data-status="планирование"] {
  background: #e9ecef;
  color: #495057;
}

.status[data-status="не состоялся"] {
  border-color: rgba(220, 53, 69, 0.22);
  background: rgba(220, 53, 69, 0.1);
  color: #b02a37;
}

.status[data-status="наблюдаем"] {
  background: rgba(47, 116, 146, 0.12);
  color: var(--accent-strong);
}

.status[data-status="есть победитель"] {
  background: rgba(33, 150, 83, 0.12);
  color: #1f6f43;
}

.status[data-status="договор"],
.status[data-status="завершен"] {
  background: rgba(15, 118, 110, 0.12);
  color: #0f766e;
}

.status[data-status="отменен"] {
  border-color: rgba(220, 53, 69, 0.22);
  background: rgba(220, 53, 69, 0.1);
  color: #b02a37;
}

.cards-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  align-content: start;
  align-items: start;
  gap: 16px;
  padding-right: 4px;
}

.project-card {
  display: grid;
  align-content: start;
  justify-items: start;
  gap: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 18px;
  background: var(--panel);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
  text-align: left;
  min-height: 0;
  height: 228px;
  overflow: hidden;
}

.project-card strong,
.manager-header strong {
  font-size: 18px;
}

.project-card .status {
  justify-self: start;
  align-self: start;
  min-width: 112px;
  min-height: 28px;
  padding: 0 12px;
}

.project-card strong {
  position: relative;
  display: -webkit-box;
  min-height: 2.5em;
  max-height: 2.5em;
  overflow: hidden;
  line-height: 1.25;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  line-clamp: 2;
}

.project-card strong::after {
  content: "";
  position: absolute;
  right: 0;
  bottom: 0;
  width: 42%;
  height: 1.25em;
  background: linear-gradient(90deg, rgba(248, 251, 252, 0), rgba(248, 251, 252, 0.96) 70%);
  pointer-events: none;
}

.card-meta {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.35;
}

.card-meta span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.empty-state {
  display: grid;
  place-items: center;
  gap: 8px;
  min-height: 240px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  background: var(--panel);
  backdrop-filter: blur(18px);
  color: var(--muted);
}

.empty-state strong {
  color: var(--ink);
}

.hidden {
  display: none !important;
}

.modal {
  width: min(920px, calc(100vw - 28px));
  max-height: calc(100vh - 28px);
  border: 0;
  border-radius: 8px;
  padding: 0;
  background: transparent;
  opacity: 0;
  transform: translateY(8px) scale(0.985);
  transition:
    opacity 0.22s ease,
    transform 0.22s ease,
    overlay 0.22s ease allow-discrete,
    display 0.22s ease allow-discrete;
}

.small-modal {
  width: min(620px, calc(100vw - 28px));
}

.modal[open] {
  opacity: 1;
  transform: translateY(0) scale(1);
}

.modal::backdrop {
  background: rgba(23, 32, 38, 0);
  backdrop-filter: blur(0);
  transition:
    background 0.3s ease,
    backdrop-filter 0.3s ease;
}

.modal[open]::backdrop {
  background: rgba(23, 32, 38, 0.18);
  backdrop-filter: blur(6px);
}

@starting-style {
  .modal[open] {
    opacity: 0;
    transform: translateY(8px) scale(0.985);
  }

  .modal[open]::backdrop {
    background: rgba(23, 32, 38, 0);
    backdrop-filter: blur(0);
  }
}

.modal-panel {
  display: grid;
  gap: 26px;
  max-height: calc(100vh - 28px);
  overflow-y: auto;
  overflow-x: hidden;
  border-radius: 8px;
  padding: 28px;
  border: 1px solid rgba(255, 255, 255, 0.62);
  background: rgba(255, 255, 255, 0.58);
  box-shadow: 0 30px 90px rgba(20, 36, 38, 0.22);
  backdrop-filter: blur(28px) saturate(1.08);
}

.small-modal .modal-panel {
  gap: 22px;
  padding-top: 22px;
}

#createModal .modal-panel {
  padding-top: 22px;
}

#createModal .modal-actions {
  justify-content: flex-end;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
  min-width: 0;
}

.form-grid.single {
  grid-template-columns: 1fr;
}

.project-form-grid .wide-field {
  grid-column: 1 / -1;
}

label {
  display: grid;
  gap: 7px;
  min-width: 0;
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
}

label input,
label select {
  color: var(--ink);
  font-weight: 500;
}

.form-section {
  display: grid;
  gap: 12px;
}

.material-lines {
  display: grid;
  gap: 12px;
}

.material-line {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) 130px 90px 42px;
  gap: 12px;
  align-items: end;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: rgba(255, 255, 255, 0.42);
}

.unit-pill {
  display: grid;
  min-height: 42px;
  place-items: center;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  font-weight: 800;
}

.compact-unit {
  min-height: 28px;
}

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

.project-meta-row,
.project-status-row {
  display: grid;
  grid-column: 1 / -1;
  gap: 12px;
}

.project-meta-row {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.project-status-row {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.project-status-row .detail-item {
  grid-column: 1;
}

.prozorro-header {
  align-items: center;
  gap: 16px;
}

.manager-header.prozorro-toolbar {
  align-items: flex-end;
  justify-content: space-between;
  gap: 18px 28px;
  margin-bottom: -2px;
  flex-wrap: wrap;
}

.manager-header.prozorro-toolbar .prozorro-tabs {
  flex: 0 0 auto;
  width: max-content;
  max-width: 100%;
  margin: 18px 0 8px;
}

.prozorro-toolbar-actions {
  display: flex;
  align-items: flex-end;
  gap: 6px;
  flex: 1 1 auto;
  flex-direction: column;
  margin: 18px 0 8px;
}

.prozorro-action-row {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  flex-wrap: wrap;
  width: 100%;
}

.prozorro-auto-line {
  justify-content: flex-end;
  margin-top: 2px;
}

.prozorro-action-row .secondary-btn {
  white-space: nowrap;
}

.prozorro-action-row .primary-btn,
.prozorro-action-row .secondary-btn {
  min-height: 40px;
}

.prozorro-action-row .compact-action-btn {
  width: 44px;
  min-width: 44px;
  padding: 0;
  justify-content: center;
  font-size: 18px;
}

.prozorro-action-row .ai-action-btn {
  font-size: 14px;
  font-weight: 900;
  letter-spacing: 0;
}

.prozorro-status {
  color: var(--muted);
  font-size: 0.92rem;
  line-height: 1.35;
  margin-top: 8px;
  text-align: right;
}

.prozorro-analysis {
  display: grid;
  flex: 1 1 auto;
  gap: 14px;
  align-content: start;
  min-height: 0;
  height: 100%;
  width: 100%;
}

.prozorro-analysis-controls {
  display: grid;
  grid-template-columns: repeat(4, minmax(150px, 1fr)) auto;
  gap: 10px;
}

.prozorro-analysis-controls select,
.prozorro-analysis-controls button {
  min-height: 40px;
  height: 40px;
  max-height: 40px;
}

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

.prozorro-analysis-summary article {
  display: flex;
  align-items: baseline;
  gap: 8px;
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.7);
}

.prozorro-analysis-summary strong {
  color: var(--accent-dark);
  font-size: 24px;
}

.prozorro-analysis-summary span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.prozorro-analysis-dashboard {
  display: grid;
  grid-template-columns: minmax(0, 1.65fr) minmax(320px, 0.85fr);
  gap: 14px;
  min-height: 420px;
}

.prozorro-analysis-map-card {
  min-height: 420px;
}

.prozorro-analysis-charts {
  display: grid;
  grid-template-rows:
    minmax(96px, var(--prozorro-object-chart-weight, 1fr))
    minmax(96px, var(--prozorro-work-chart-weight, 1fr));
  gap: 14px;
  min-height: 0;
}

.prozorro-analysis-chart,
.prozorro-analysis-results {
  min-height: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.72);
  box-shadow: var(--shadow);
}

.prozorro-analysis-chart {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  padding: 12px;
}

.prozorro-analysis-chart h3 {
  margin: 0 0 8px;
  font-size: 15px;
}

.prozorro-bars {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-height: 0;
  overflow: auto;
}

.prozorro-bar {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  width: 100%;
  padding: 6px 8px 8px;
  overflow: hidden;
  border: 0;
  border-radius: 5px;
  background: transparent;
  color: var(--text);
  text-align: left;
  cursor: pointer;
  flex: 0 0 auto;
  min-height: 34px;
}

.prozorro-bar:hover { background: rgba(216, 237, 242, 0.5); }
.prozorro-bar-label, .prozorro-bar-value { position: relative; z-index: 1; font-size: 12px; font-weight: 800; }
.prozorro-bar-value { color: var(--accent-dark); }
.prozorro-bar i {
  position: absolute;
  bottom: 2px;
  left: 8px;
  width: var(--bar-width);
  height: 3px;
  border-radius: 2px;
  background: var(--accent);
}

.prozorro-analysis-results {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  grid-column: 1 / -1;
  min-height: 260px;
}

.prozorro-analysis-tenders {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  max-height: 390px;
  padding: 12px;
  overflow: auto;
}

.prozorro-analysis-tender-card {
  display: grid;
  gap: 7px;
  align-content: start;
  min-width: 0;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.76);
}

.prozorro-analysis-tender-card h4 { margin: 0; font-size: 14px; line-height: 1.3; }
.prozorro-analysis-tender-card > span,
.prozorro-analysis-tender-card > small { color: var(--muted); font-size: 12px; font-weight: 700; }
.prozorro-analysis-tender-card .row-actions { align-self: end; justify-content: flex-start; margin-top: 3px; }

@media (max-width: 1200px) {
  .prozorro-analysis-controls { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .prozorro-analysis-summary { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .prozorro-analysis-dashboard { grid-template-columns: minmax(0, 1.35fr) minmax(280px, 0.8fr); }
  .prozorro-analysis-tenders { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 860px) {
  .prozorro-analysis-dashboard { grid-template-columns: 1fr; }
  .prozorro-analysis-charts { grid-template-columns: 1fr 1fr; grid-template-rows: none; }
  .prozorro-analysis-map-card { min-height: 330px; }
}

@media (min-width: 1800px) {
  .prozorro-analysis-dashboard {
    grid-template-columns: minmax(0, 1.45fr) minmax(280px, 0.65fr) minmax(360px, 1fr);
    height: calc(100vh - 302px);
    min-height: 560px;
    margin-bottom: 16px;
  }

  .prozorro-analysis-map-card,
  .prozorro-analysis-charts,
  .prozorro-analysis-results {
    height: 100%;
    min-height: 0;
  }

  .prozorro-analysis-results {
    grid-column: auto;
  }

  .prozorro-analysis-tenders {
    grid-template-columns: minmax(0, 1fr);
    align-content: start;
    max-height: none;
    height: 100%;
  }
}

.toggle-line {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--text);
  font-size: 0.92rem;
  white-space: nowrap;
}

.toggle-line input {
  width: 18px;
  height: 18px;
  accent-color: var(--accent);
}

.prozorro-project-section {
  margin-top: 18px;
}

#prozorroSection {
  min-height: 0;
}

#prozorroSection .prozorro-tab-panel:not(.hidden) {
  display: flex;
  flex: 1 1 auto;
  min-height: 0;
  flex-direction: column;
}

#prozorroExistingPanel .table-wrap {
  flex: 1 1 auto;
  min-height: 0;
}

#prozorroExistingPanel table {
  width: 100%;
  table-layout: fixed;
}

#prozorroExistingPanel th,
#prozorroExistingPanel td {
  overflow-wrap: normal;
  word-break: normal;
}

#prozorroExistingPanel th:nth-child(1),
#prozorroExistingPanel td:nth-child(1) {
  width: 28%;
}

#prozorroExistingPanel th:nth-child(2),
#prozorroExistingPanel td:nth-child(2) {
  width: auto;
}

#prozorroExistingPanel th:nth-child(3),
#prozorroExistingPanel td:nth-child(3) {
  width: 28%;
}

#prozorroExistingPanel th:nth-child(4),
#prozorroExistingPanel td:nth-child(4) {
  width: 310px;
  text-align: right;
}

#prozorroExistingPanel .row-actions {
  justify-content: flex-end;
}

#prozorroExistingPanel .prozorro-tender-actions,
#prozorroWatchPanel .prozorro-tender-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  align-items: stretch;
  justify-content: stretch;
  gap: 6px;
  width: 292px;
  margin-left: auto;
}

#prozorroExistingPanel .prozorro-tender-actions .secondary-btn,
#prozorroWatchPanel .prozorro-tender-actions .secondary-btn {
  width: 100%;
  min-width: 0;
  justify-content: center;
  white-space: nowrap;
}

#prozorroExistingPanel .prozorro-open-action,
#prozorroWatchPanel .prozorro-open-action {
  grid-column: 1 / -1;
}

#prozorroExistingPanel .prozorro-track-action,
#prozorroWatchPanel .prozorro-track-action {
  grid-column: 1;
}

#prozorroExistingPanel .prozorro-hide-action,
#prozorroWatchPanel .prozorro-hide-action {
  grid-column: 2;
}

.prozorro-project-list {
  display: grid;
  gap: 10px;
}

.prozorro-match-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.72);
}

.prozorro-match-card > div:first-child {
  display: grid;
  gap: 3px;
  min-width: 0;
}

.prozorro-match-card span,
.prozorro-match-card small {
  color: var(--muted);
}

.prozorro-match-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
}

.prozorro-match-buttons {
  display: grid;
  grid-template-columns: 1fr;
  gap: 6px;
  min-width: 150px;
}

.prozorro-match-buttons .secondary-btn {
  min-height: 38px;
  padding: 8px 12px;
  text-align: center;
  text-decoration: none;
}

.prozorro-match-buttons .secondary-btn.danger {
  color: var(--danger);
}

.watch-profiles-grid {
  display: grid;
  gap: 12px;
}

.watch-profiles-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  align-items: start;
  gap: 12px;
}

.watch-profile-card {
  display: grid;
  gap: 10px;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.72);
}

.compact-profile-card {
  grid-template-rows: auto auto auto;
  min-height: 230px;
}

.common-exclude-card {
  background: rgba(232, 244, 249, 0.78);
}

.watch-profile-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.watch-profile-card label:not(.toggle-line) {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 6px;
  min-height: 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.watch-profile-card textarea {
  width: 100%;
  height: 100%;
  min-height: 92px;
  resize: none;
  overflow-x: hidden;
  overflow-y: auto;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px;
  font: inherit;
  color: var(--text);
  background: rgba(255, 255, 255, 0.9);
}

.prozorro-profiles-modal {
  width: min(1580px, calc(100vw - 28px));
}

.prozorro-profiles-modal .modal-panel {
  gap: 16px;
}

.prozorro-profiles-modal .watch-profiles-grid {
  max-height: min(640px, calc(100vh - 150px));
  overflow-y: auto;
  padding-right: 2px;
}

.watch-profiles-save {
  justify-self: end;
  width: min(320px, 100%);
}

.details-form-stack {
  display: grid;
  gap: 14px;
  max-width: 560px;
}

.status-editor {
  max-width: 280px;
}

.detail-item {
  display: grid;
  gap: 5px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: rgba(255, 255, 255, 0.42);
}

.detail-item span {
  color: var(--muted);
  font-size: 13px;
}

.relation-detail {
  align-content: start;
}

.relation-section {
  margin-top: 14px;
}

.inline-add-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
}

.inline-add-row.compact {
  margin-top: 8px;
}

.inline-add-row.compact select,
.inline-add-row.compact button {
  min-height: 34px;
  font-size: 13px;
}

.relation-picker {
  margin-top: 8px;
}

.project-relation-picker select {
  width: 100%;
  min-height: 40px;
}

.relation-add-btn {
  display: inline-grid;
  width: 28px;
  min-width: 28px;
  height: 28px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.56);
  color: var(--accent);
  font-size: 19px;
  font-weight: 800;
  line-height: 1;
  padding: 0 0 2px;
}

.relation-add-btn:hover {
  border-color: rgba(36, 123, 160, 0.34);
  background: rgba(231, 243, 247, 0.86);
}

.ticket-list {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  min-height: 28px;
}

.ticket-list.compact {
  gap: 5px;
}

.project-person-tickets {
  margin-top: 4px;
}

.ticket {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  max-width: 100%;
  min-height: 28px;
  border: 1px solid rgba(216, 224, 228, 0.9);
  border-radius: 999px;
  padding: 4px 8px;
  background: rgba(231, 243, 247, 0.62);
  color: var(--ink);
  font-size: 12px;
  line-height: 1.15;
}

.ticket span {
  display: grid;
  min-width: 0;
  color: inherit;
  font-size: inherit;
}

.ticket strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ticket small {
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
}

.ticket-remove {
  display: inline-grid;
  width: 20px;
  min-width: 20px;
  height: 20px;
  place-items: center;
  border: 0;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.58);
  color: var(--danger);
  font-size: 15px;
  font-weight: 800;
  line-height: 1;
  padding: 0;
}

.ticket-remove:hover {
  background: rgba(255, 230, 230, 0.84);
}

.table-note {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.file-list {
  display: flex;
  align-items: center;
  flex: 1 1 auto;
  min-width: 0;
  gap: 8px;
}

.discussion-link-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.discussion-actions-row {
  justify-content: flex-start;
}

.discussion-actions {
  gap: 8px;
}

.discussion-link-row.editing {
  align-items: stretch;
  width: min(520px, 100%);
}

.discussion-link,
.discussion-link-empty {
  min-width: 0;
  overflow-wrap: anywhere;
}

.discussion-link {
  color: var(--ink);
  text-decoration: underline;
  text-underline-offset: 3px;
}

.discussion-link:hover {
  color: var(--accent);
}

.discussion-link-empty {
  color: var(--muted);
}

.discussion-link-input {
  flex: 1 1 auto;
}

.telegram-action {
  color: var(--accent-strong);
  text-decoration: none;
}

.telegram-action svg {
  width: 20px;
  height: 20px;
}

.manager-section {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.manager-header.analytics-toolbar {
  align-items: flex-start;
  justify-content: flex-start;
  margin-bottom: -2px;
}

.manager-header.analytics-toolbar .directory-tabs {
  flex: 0 0 auto;
  align-self: flex-start;
  width: max-content;
  max-width: 100%;
  margin: 18px 0 8px;
}

.analytics-tabs .segment {
  flex: 0 0 auto;
}

.analytics-tabs {
  overflow-x: auto;
}

.analytics-tab-panel {
  flex: 1 1 auto;
  min-width: 0;
  min-height: 0;
}

.analytics-tab-panel:not(.hidden) {
  display: flex;
  flex-direction: column;
}

.manager-header.analytics-controls {
  align-items: center;
  justify-content: flex-start;
  gap: 12px;
  margin-bottom: 4px;
}

.analytics-controls .manager-search {
  flex: 0 1 420px;
  max-width: 420px;
  margin-right: 0;
}

.analytics-controls select {
  flex: 0 1 420px;
  width: auto;
  max-width: 420px;
}

.analytics-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
  min-height: 0;
}

.analytics-panel {
  display: flex;
  min-width: 0;
  min-height: 0;
  flex-direction: column;
  gap: 12px;
}

.analytics-panel.wide {
  grid-column: 1 / -1;
}

#analyticsRegionsPanel .analytics-panel {
  flex: 1 1 auto;
  height: clamp(520px, calc(100vh - 220px), 900px);
  min-height: 0;
}

#analyticsMaterialsPanel .analytics-panel,
#analyticsEntityPanel .analytics-panel {
  flex: 1 1 auto;
  height: clamp(520px, calc(100vh - 220px), 900px);
  min-height: 0;
}

.analytics-panel .table-wrap {
  flex: 1 1 auto;
  min-height: 0;
}

.analytics-materials-wrap {
  max-height: none;
}

.analytics-material-layout,
.analytics-entity-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(280px, 340px);
  align-items: stretch;
  gap: 16px;
  flex: 1 1 auto;
  min-width: 0;
  min-height: 0;
}

.analytics-material-row {
  cursor: pointer;
  transition: background 140ms ease, box-shadow 140ms ease;
}

.analytics-entity-row {
  cursor: pointer;
  transition: background 140ms ease, box-shadow 140ms ease;
}

.analytics-entity-row:hover,
.analytics-entity-row:focus-visible {
  background: rgba(237, 248, 252, 0.78);
  outline: none;
}

.analytics-entity-row.active {
  background: rgba(216, 237, 242, 0.9);
  box-shadow: inset 3px 0 0 var(--accent);
}

.analytics-material-row:hover,
.analytics-material-row:focus-visible {
  background: rgba(237, 248, 252, 0.78);
  outline: none;
}

.analytics-material-row.active {
  background: rgba(216, 237, 242, 0.9);
  box-shadow: inset 3px 0 0 var(--accent);
}

.analytics-entity-wrap {
  max-height: none;
}

@media (min-width: 1800px) {
  .analytics-material-layout,
  .analytics-entity-layout {
    grid-template-columns: minmax(0, 1fr) clamp(440px, 24vw, 600px);
  }
}

.analytics-region-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(280px, 340px);
  align-items: stretch;
  gap: 16px;
  flex: 1 1 auto;
  min-width: 0;
  min-height: 0;
}

.analytics-map-card {
  position: relative;
  display: flex;
  align-items: center;
  flex: 1 1 auto;
  min-width: 0;
  min-height: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.72);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.analytics-regions-map {
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 0;
  width: 100%;
  height: 100%;
  padding: 0;
}

.analytics-regions-map svg,
.analytics-map-svg {
  display: block;
  width: 100%;
  height: 100%;
  max-height: 100%;
  object-fit: contain;
}

.analytics-map-loading {
  display: grid;
  min-height: 280px;
  place-items: center;
  color: var(--muted);
  font-weight: 800;
}

.analytics-map-region {
  cursor: pointer;
  pointer-events: visiblePainted;
  stroke: rgba(61, 119, 141, 0.54);
  stroke-linejoin: round;
  stroke-width: 1.15;
  vector-effect: non-scaling-stroke;
  transition: opacity 140ms ease, stroke 140ms ease;
}

.analytics-map-region:hover {
  stroke: rgba(31, 95, 126, 0.72);
}

.analytics-map-region.active {
  opacity: 0.9;
  stroke: rgba(31, 95, 126, 0.7);
}

.analytics-map-region-fill {
  stroke: none !important;
  pointer-events: none;
}

.analytics-map-labels {
  pointer-events: none;
}

.analytics-region-projects {
  display: flex;
  min-width: 0;
  min-height: 0;
  height: 100%;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.72);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.region-projects-header {
  display: grid;
  gap: 4px;
  padding: 14px 16px 12px;
  border-bottom: 1px solid var(--line);
  background: rgba(245, 250, 252, 0.86);
}

.region-projects-header small {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.region-projects-header strong {
  color: var(--text);
  font-size: 18px;
  line-height: 1.15;
}

.region-projects-list {
  display: grid;
  gap: 10px;
  min-height: 0;
  padding: 12px;
  overflow: auto;
}

.region-project-card {
  display: grid;
  gap: 7px;
  width: 100%;
  min-width: 0;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.72);
  color: var(--text);
  text-align: left;
  cursor: pointer;
}

.region-project-card:hover {
  border-color: rgba(47, 117, 150, 0.38);
  background: rgba(237, 248, 252, 0.78);
}

.region-project-card .status {
  justify-self: start;
}

.region-project-card strong,
.region-project-card span,
.region-project-card small {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

.region-project-card strong {
  font-size: 14px;
  line-height: 1.25;
}

.region-project-card > span:not(.status),
.region-project-card small {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.region-projects-empty {
  display: grid;
  gap: 8px;
  align-content: center;
  min-height: 180px;
  padding: 18px;
  color: var(--muted);
  text-align: center;
}

.region-projects-empty strong {
  color: var(--text);
  font-size: 18px;
}

.region-projects-empty.compact {
  min-height: 120px;
}

.analytics-map-count {
  pointer-events: none;
  text-anchor: middle;
  fill: var(--ink);
}

.analytics-map-count {
  font-size: 22px;
  font-weight: 900;
}

.analytics-map-count.light {
  fill: #f8fcfd;
}

.analytics-panel table {
  min-width: 0;
  table-layout: fixed;
}

.analytics-panel.wide table {
  min-width: 0;
}

.analytics-panel th,
.analytics-panel td {
  padding: 7px 10px;
  font-size: 13px;
  line-height: 1.18;
}

.analytics-panel th {
  background: rgba(248, 251, 252, 0.92);
  backdrop-filter: blur(14px) saturate(1.08);
  -webkit-backdrop-filter: blur(14px) saturate(1.08);
  box-shadow: 0 1px 0 var(--line), 0 8px 18px rgba(23, 32, 38, 0.04);
}

.analytics-panel th:first-child,
.analytics-panel td:first-child {
  width: auto;
}

.analytics-panel th:not(:first-child),
.analytics-panel td:not(:first-child) {
  width: 112px;
  text-align: center;
}

.analytics-panel td:first-child strong {
  display: block;
  max-width: 100%;
  overflow-wrap: anywhere;
}

.analytics-panel h3 {
  font-size: 15px;
}

.analytics-panel .table-note {
  margin-top: 2px;
}

#prozorroWatchPanel:not(.hidden) {
  display: flex;
  flex: 1 1 auto;
  min-height: 0;
  flex-direction: column;
}

#prozorroWatchPanel .analytics-panel {
  flex: 1 1 auto;
  gap: 4px;
  height: auto;
  min-height: 0;
}

#prozorroWatchPanel .prozorro-watch-results-wrap {
  flex: 1 1 auto;
  min-height: 0;
  max-height: none;
  overflow-y: auto;
  overflow-x: hidden;
}

#prozorroWatchPanel table {
  width: 100%;
  table-layout: fixed;
}

#prozorroWatchPanel th,
#prozorroWatchPanel td {
  text-align: left;
}

#prozorroWatchPanel th:first-child,
#prozorroWatchPanel td:first-child {
  width: auto;
}

#prozorroWatchPanel th:nth-child(2),
#prozorroWatchPanel td:nth-child(2) {
  width: 28%;
}

#prozorroWatchPanel th:nth-child(3),
#prozorroWatchPanel td:nth-child(3) {
  width: 130px;
  text-align: center;
}

#prozorroWatchPanel th:nth-child(4),
#prozorroWatchPanel td:nth-child(4) {
  width: 310px;
  text-align: right;
}

#prozorroWatchPanel .row-actions {
  justify-content: flex-end;
}

#prozorroTrackedPanel .table-wrap {
  flex: 1 1 auto;
  min-height: 0;
  overflow-x: hidden;
}

#prozorroTrackedPanel table {
  width: 100%;
  table-layout: fixed;
}

#prozorroTrackedPanel th,
#prozorroTrackedPanel td {
  overflow-wrap: break-word;
  word-break: normal;
}

#prozorroTrackedPanel th:nth-child(1),
#prozorroTrackedPanel td:nth-child(1) {
  width: auto;
}

#prozorroTrackedPanel th:nth-child(2),
#prozorroTrackedPanel td:nth-child(2),
#prozorroTrackedPanel th:nth-child(3),
#prozorroTrackedPanel td:nth-child(3) {
  width: 20%;
  text-align: left;
}

#prozorroTrackedPanel th:nth-child(4),
#prozorroTrackedPanel td:nth-child(4) {
  width: 150px;
  text-align: center;
}

#prozorroTrackedPanel th:nth-child(5),
#prozorroTrackedPanel td:nth-child(5) {
  width: 168px;
  text-align: right;
}

#prozorroTrackedPanel .row-actions {
  align-items: stretch;
  flex-direction: column;
  justify-content: center;
  gap: 6px;
  width: 150px;
  margin-left: auto;
}

#prozorroTrackedPanel .row-actions .secondary-btn {
  width: 100%;
  min-width: 0;
  justify-content: center;
  white-space: nowrap;
}

#prozorroWatchStatus {
  margin-top: 2px;
  padding-right: 2px;
}

.tender-title-line {
  display: flex;
  align-items: center;
  flex-wrap: nowrap;
  gap: 6px;
}

.tender-title-line strong {
  flex: 0 0 auto;
  white-space: nowrap;
}

.new-tender-badge,
.tender-type-badge,
.tender-value-badge,
.ai-review-badge {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  min-height: 20px;
  padding: 0 7px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
  vertical-align: middle;
}

.new-tender-badge {
  background: rgba(47, 116, 146, 0.12);
  color: var(--accent-strong);
}

.tender-type-badge {
  background: rgba(104, 118, 128, 0.12);
  color: var(--muted);
}

.tender-value-badge {
  background: rgba(33, 150, 83, 0.12);
  color: #1f6f43;
}

.ai-review-badge {
  background: #eef5f8;
  color: #1f5f7d;
}

.ai-review-relevant {
  background: #e7f4ee;
  color: #226146;
}

.ai-review-maybe {
  background: #f7f1dc;
  color: #6d5b1d;
}

.ai-review-irrelevant {
  background: #f5e8e8;
  color: #7a3d3d;
}

.ai-review-pending,
.ai-review-processing {
  background: #eef1f3;
  color: #53646d;
}

.ai-review-failed {
  background: #f5e8e8;
  color: #7a3d3d;
}

.ai-review-note {
  color: #5f6e76;
}

.ai-object-type {
  color: #4f6069;
  font-weight: 800;
}

.ai-work-type {
  color: #4f6069;
  font-weight: 700;
}

.ai-telegram-status {
  color: #6b7880;
  font-weight: 700;
}

.ai-telegram-sent {
  color: #226146;
}

.ai-telegram-pending,
.ai-telegram-sending {
  color: #1f5f7d;
}

.ai-telegram-failed,
.ai-review-error {
  color: #8a3f3f;
}

.ai-review-evidence {
  flex-basis: 100%;
  color: #7a858b;
}

.ai-review-line {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 4px;
  font-size: 12px;
}

#materialsSection,
#companiesSection,
#peopleSection {
  margin-top: 18px;
}

.directory-tabs {
  width: fit-content;
  margin-top: 18px;
  margin-bottom: 8px;
}

.directory-toolbar {
  margin-top: 18px;
}

.directory-toolbar .directory-tabs {
  margin: 0 auto 0 0;
}

.directory-panel {
  display: flex;
  flex: 1 1 auto;
  min-height: 0;
  flex-direction: column;
  gap: 12px;
}

#materialsSection th,
#materialsSection td,
#companiesSection th,
#companiesSection td,
#peopleSection th,
#peopleSection td,
#directoriesSection th,
#directoriesSection td {
  padding: 5px 10px;
  font-size: 14px;
  line-height: 1.25;
}

#materialsSection .slim,
#companiesSection .slim,
#peopleSection .slim,
#directoriesSection .slim {
  min-height: 28px;
  font-size: 13px;
}

.row-actions {
  display: flex;
  align-items: center;
  flex-wrap: nowrap;
  gap: 6px;
}

.icon-action {
  display: inline-grid;
  width: 40px;
  min-width: 40px;
  height: 40px;
  min-height: 40px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.48);
  color: var(--accent-strong);
  font-size: 16px;
  font-weight: 800;
  line-height: 1;
  padding: 0;
}

.icon-action:hover {
  border-color: rgba(47, 111, 143, 0.42);
  background: rgba(231, 243, 247, 0.78);
}

.danger-action {
  color: var(--danger);
}

.checkbox-list {
  display: grid;
  gap: 8px;
  max-height: 180px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  background: rgba(255, 255, 255, 0.42);
}

.checkbox-item {
  display: flex;
  grid-template-columns: none;
  align-items: center;
  gap: 8px;
  color: var(--ink);
  font-weight: 600;
}

.checkbox-item input {
  width: 16px;
  min-width: 16px;
  min-height: 16px;
}

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

.editable-materials-wrap table {
  min-width: 620px;
}

.editable-materials-table th,
.editable-materials-table td {
  padding: 5px 8px;
  font-size: 14px;
  line-height: 1.25;
}

.editable-materials-table select,
.editable-materials-table input {
  width: 100%;
  min-height: 30px;
  padding: 0 9px;
}

.material-picker {
  min-width: 0;
}

.material-picker input[type="search"] {
  min-width: 0;
}

.material-picker input[type="search"]::-webkit-search-cancel-button {
  cursor: pointer;
}

.editable-materials-table .icon-btn {
  width: 30px;
  min-height: 30px;
  font-size: 20px;
}

.editable-materials-table th:nth-child(1),
.editable-materials-table td:nth-child(1) {
  width: 66%;
}

.editable-materials-table th:nth-child(2),
.editable-materials-table td:nth-child(2) {
  width: 16%;
}

.editable-materials-table th:nth-child(3),
.editable-materials-table td:nth-child(3) {
  width: 64px;
  max-width: 64px;
  text-align: center;
}

.editable-materials-table th:nth-child(4),
.editable-materials-table td:nth-child(4) {
  width: 44px;
  text-align: right;
}

.section-actions {
  display: flex;
  justify-content: flex-end;
}

.details-panel > .modal-actions {
  justify-content: space-between;
  align-items: center;
  padding-top: 0;
}

.details-panel > .modal-actions .danger-btn {
  flex: 0 0 auto;
}

.manager-header {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 16px;
}

.manager-search {
  flex: 1 1 420px;
  max-width: 620px;
  margin-right: auto;
}

.slim {
  min-height: 34px;
  padding: 0 10px;
  font-size: 13px;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.48;
}

@media (min-width: 1680px) {
  .cards-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}

@media (max-width: 1440px) and (min-width: 861px) {
  .app-shell {
    grid-template-columns: 184px minmax(0, 1fr);
  }

  .sidebar {
    gap: 18px;
    padding: 16px;
  }

  .nav-list {
    flex: 0 0 auto;
  }

  .sidebar-actions {
    flex: 0 0 auto;
    margin-top: auto;
  }

  .nav-item {
    min-height: 40px;
    padding: 8px 10px;
    font-size: 14px;
  }

  .sidebar-logout {
    min-height: 40px;
    padding: 8px 10px;
    font-size: 14px;
  }

  .main {
    padding: 24px;
  }

  h1 {
    font-size: 30px;
  }

  .stats-row {
    gap: 12px;
    margin: 2px 0 18px;
  }

  .stat {
    padding: 16px;
  }

  .toolbar {
    gap: 10px;
    margin-bottom: 14px;
  }

  #projectToolbar .segmented,
  #projectToolbar #statusFilter {
    flex-basis: 196px;
    width: 196px;
    font-size: 14px;
  }

  #projectToolbar .search-field {
    flex-basis: 520px;
    width: 520px;
    max-width: 520px;
    font-size: 14px;
  }

  #projectToolbar .segment {
    padding: 0 8px;
    font-size: 14px;
  }

  #tableView th,
  #tableView td {
    padding: 12px 14px;
    font-size: 14px;
  }

  #tableView th {
    font-size: 12px;
  }

  #tableView th:nth-child(1),
  #tableView td:nth-child(1) {
    width: auto;
  }

  #tableView th:nth-child(2),
  #tableView td:nth-child(2),
  #tableView th:nth-child(3),
  #tableView td:nth-child(3),
  #tableView th:nth-child(4),
  #tableView td:nth-child(4),
  #tableView th:nth-child(5),
  #tableView td:nth-child(5) {
    display: none;
  }

  #tableView th:nth-child(6),
  #tableView td:nth-child(6) {
    width: 120px;
  }

  #tableView th:nth-child(7),
  #tableView td:nth-child(7) {
    width: 104px;
  }

  .project-row-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 4px 14px;
    margin-top: 8px;
    color: var(--muted);
    font-size: 12px;
    font-weight: 600;
    line-height: 1.35;
  }

  #tableView .status {
    min-width: 84px;
    min-height: 24px;
    padding: 0 8px;
    font-size: 12px;
  }

  .cards-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 12px;
  }

  .project-card {
    gap: 12px;
    padding: 16px;
    height: 204px;
  }

  .project-card strong {
    font-size: 16px;
  }

  .project-card .status {
    min-width: 96px;
    min-height: 24px;
    font-size: 12px;
  }

  .card-meta {
    font-size: 13px;
  }

  .analytics-panel th:not(:first-child),
  .analytics-panel td:not(:first-child) {
    width: 96px;
  }

  #prozorroWatchPanel th,
  #prozorroWatchPanel td {
    padding: 10px 12px;
  }

  #prozorroWatchPanel th:first-child,
  #prozorroWatchPanel td:first-child {
    width: auto;
  }

  #prozorroWatchPanel th:nth-child(2),
  #prozorroWatchPanel td:nth-child(2) {
    width: 24%;
  }

  #prozorroWatchPanel th:nth-child(3),
  #prozorroWatchPanel td:nth-child(3) {
    width: 112px;
  }

  #prozorroWatchPanel th:nth-child(4),
  #prozorroWatchPanel td:nth-child(4) {
    width: 168px;
  }

  #prozorroWatchPanel .row-actions {
    align-items: stretch;
    justify-content: center;
    gap: 6px;
  }

  #prozorroWatchPanel .row-actions .secondary-btn {
    width: 100%;
    min-width: 0;
    justify-content: center;
    white-space: nowrap;
  }

  #prozorroWatchPanel .prozorro-tender-actions {
    grid-template-columns: 1fr;
    width: 100%;
  }

  #prozorroWatchPanel .prozorro-open-action,
  #prozorroWatchPanel .prozorro-track-action,
  #prozorroWatchPanel .prozorro-hide-action {
    grid-column: 1;
  }

  #prozorroExistingPanel th,
  #prozorroExistingPanel td {
    padding: 10px 12px;
    font-size: 13px;
    line-height: 1.28;
  }

  #prozorroExistingPanel th {
    font-size: 12px;
  }

  #prozorroExistingPanel th:nth-child(1),
  #prozorroExistingPanel td:nth-child(1) {
    width: 36%;
  }

  #prozorroExistingPanel th:nth-child(2),
  #prozorroExistingPanel td:nth-child(2) {
    width: auto;
  }

  #prozorroExistingPanel th:nth-child(3),
  #prozorroExistingPanel td:nth-child(3) {
    width: 24%;
  }

  #prozorroExistingPanel th:nth-child(4),
  #prozorroExistingPanel td:nth-child(4) {
    width: 168px;
  }

  #prozorroExistingPanel .row-actions {
    align-items: stretch;
    justify-content: center;
    gap: 6px;
  }

  #prozorroExistingPanel .row-actions .secondary-btn {
    width: 100%;
    min-width: 0;
    justify-content: center;
    white-space: nowrap;
  }

  #prozorroExistingPanel .prozorro-tender-actions {
    grid-template-columns: 1fr;
    width: 100%;
  }

  #prozorroExistingPanel .prozorro-open-action,
  #prozorroExistingPanel .prozorro-track-action,
  #prozorroExistingPanel .prozorro-hide-action {
    grid-column: 1;
  }

  #prozorroTrackedPanel th,
  #prozorroTrackedPanel td {
    padding: 10px 12px;
    font-size: 13px;
    line-height: 1.28;
  }

  #prozorroTrackedPanel th {
    font-size: 12px;
  }

  #prozorroTrackedPanel th:nth-child(2),
  #prozorroTrackedPanel td:nth-child(2),
  #prozorroTrackedPanel th:nth-child(3),
  #prozorroTrackedPanel td:nth-child(3) {
    width: 19%;
  }

  #prozorroTrackedPanel th:nth-child(4),
  #prozorroTrackedPanel td:nth-child(4) {
    width: 124px;
  }

  #prozorroTrackedPanel th:nth-child(5),
  #prozorroTrackedPanel td:nth-child(5) {
    width: 156px;
  }

  #prozorroTrackedPanel .row-actions {
    width: 132px;
  }
}

@media (max-width: 1600px) and (min-width: 861px), (max-height: 900px) and (min-width: 861px) {
  .prozorro-analysis {
    grid-template-rows: auto auto minmax(0, 1fr);
    align-content: stretch;
    padding-bottom: 12px;
  }

  .prozorro-analysis-controls select,
  .prozorro-analysis-controls button {
    min-height: 34px;
    height: 34px;
    max-height: 34px;
    padding-top: 0;
    padding-bottom: 0;
    font-size: 13px;
  }

  .prozorro-analysis-summary article {
    align-items: center;
    min-height: 34px;
    height: 34px;
    padding: 0 10px;
    gap: 6px;
    overflow: hidden;
  }

  .prozorro-analysis-summary strong {
    font-size: 18px;
    line-height: 1;
  }

  .prozorro-analysis-summary span {
    overflow: hidden;
    font-size: 10px;
    line-height: 1.1;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .prozorro-analysis-dashboard {
    grid-template-columns: minmax(0, 1.35fr) minmax(220px, 0.62fr) minmax(300px, 1fr);
    align-self: stretch;
    height: auto;
    min-height: 0;
    margin-bottom: 0;
  }

  .prozorro-analysis-chart {
    padding: 9px;
  }

  .prozorro-analysis-chart h3 {
    margin-bottom: 4px;
    font-size: 13px;
    line-height: 1.15;
  }

  .prozorro-bars {
    gap: 2px;
  }

  .prozorro-bar {
    min-height: 27px;
    padding: 3px 6px 6px;
  }

  .prozorro-bar-label,
  .prozorro-bar-value {
    font-size: 10px;
    line-height: 1.15;
  }

  .prozorro-bar i {
    left: 6px;
    height: 2px;
  }

  .prozorro-analysis-map-card,
  .prozorro-analysis-charts,
  .prozorro-analysis-results {
    height: 100%;
    min-height: 0;
  }

  .prozorro-analysis-results {
    grid-column: auto;
  }

  .prozorro-analysis-tenders {
    grid-template-columns: minmax(0, 1fr);
    align-content: start;
    max-height: none;
    height: 100%;
    padding: 8px;
  }

  .prozorro-analysis-tender-card {
    gap: 4px;
    padding: 10px;
  }

  .prozorro-analysis-tender-card .tender-title-line {
    align-items: baseline;
    flex-wrap: nowrap;
    gap: 6px;
  }

  .prozorro-analysis-tender-card .tender-title-line strong {
    min-width: 0;
    font-size: 12px;
    line-height: 1.2;
  }

  .prozorro-analysis-tender-card .tender-value-badge {
    max-width: calc(100% - 170px);
    min-height: 18px;
    padding: 0 6px;
    overflow: hidden;
    font-size: 12px;
    line-height: 1.1;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .prozorro-analysis-tender-card h4,
  .prozorro-analysis-tender-card > span {
    font-size: 12px;
    line-height: 1.2;
  }

  .prozorro-analysis-tender-card .prozorro-analysis-tender-meta {
    overflow: hidden;
    font-size: 10px;
    line-height: 1.15;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .prozorro-analysis-tender-card .prozorro-analysis-tender-region {
    display: none;
  }

  .prozorro-analysis-tender-card .row-actions {
    gap: 6px;
    margin-top: 2px;
  }

  .prozorro-analysis-tender-card .row-actions .secondary-btn,
  .prozorro-analysis-tender-card .row-actions .primary-btn {
    min-height: 30px;
    padding: 0 8px;
    font-size: 11px;
  }

  .manager-header .segment,
  .manager-header .primary-btn,
  .manager-header .secondary-btn {
    min-height: 34px;
    padding: 0 10px;
    font-size: 13px;
    line-height: 1.15;
  }

  .manager-header .directory-tabs .segment,
  .manager-header .analytics-tabs .segment,
  .manager-header .prozorro-tabs .segment {
    padding: 0 12px;
    white-space: nowrap;
  }

  .prozorro-action-row {
    gap: 8px;
  }

  .prozorro-action-row .primary-btn,
  .prozorro-action-row .secondary-btn {
    min-height: 34px;
    font-size: 13px;
  }

  .prozorro-action-row .compact-action-btn {
    width: 38px;
    min-width: 38px;
    font-size: 15px;
  }

  .row-actions .secondary-btn,
  .row-actions .primary-btn {
    min-height: 34px;
    padding: 0 10px;
    font-size: 13px;
    line-height: 1.15;
    white-space: nowrap;
  }

  .stats-row {
    gap: 12px;
    margin: -4px 0 10px;
  }

  .stat {
    flex-basis: 178px;
    width: 178px;
    min-height: 104px;
    padding: 14px 18px;
  }

  .stat span {
    left: 18px;
    bottom: 0;
    font-size: 13px;
  }

  .stat strong {
    right: 0;
    bottom: -4px;
    font-size: 88px;
  }

  .prozorro-profiles-modal {
    width: min(1480px, calc(100vw - 24px));
  }

  .watch-profiles-row {
    grid-template-columns: minmax(0, 1fr);
  }

  .compact-profile-card {
    min-height: 176px;
  }

  .watch-profile-card textarea {
    min-height: 102px;
  }
}

@media (max-width: 1240px) and (min-width: 861px) {
  #projectToolbar {
    flex-wrap: wrap;
  }

  #projectToolbar .search-field {
    flex: 1 1 100%;
    width: 100%;
    max-width: none;
  }

  .watch-profiles-row {
    min-width: 0;
  }
}

@media (max-height: 980px) and (min-width: 861px) {
  .stats-row {
    margin-top: -8px;
    margin-bottom: 18px;
  }

  #projectToolbar {
    align-items: stretch;
    flex-flow: row nowrap;
    gap: 10px;
  }

  #projectToolbar .segmented {
    display: none;
  }

  #projectToolbar #statusFilter {
    flex: 0 0 196px;
    width: 196px;
  }

  #projectToolbar .search-field {
    flex: 1 1 auto;
    width: auto;
    max-width: none;
  }

  #projectToolbar #statusFilter,
  #projectToolbar .search-field,
  #projectToolbar .project-toolbar-add {
    height: 40px;
    min-height: 40px;
  }

  .manager-section {
    gap: 14px;
  }

  .manager-header.analytics-toolbar .directory-tabs {
    margin: 8px 0 2px;
  }

  #materialsSection,
  #companiesSection,
  #peopleSection,
  .directory-toolbar {
    margin-top: 8px;
  }

  .manager-header.prozorro-toolbar .prozorro-tabs,
  .prozorro-toolbar-actions {
    margin: 8px 0 2px;
  }

  #materialsSection .manager-search,
  #companiesSection .manager-search,
  #peopleSection .manager-search,
  .analytics-controls .manager-search,
  .analytics-controls select {
    height: 40px;
    min-height: 40px;
  }

  #materialsSection .manager-search input,
  #companiesSection .manager-search input,
  #peopleSection .manager-search input,
  .analytics-controls .manager-search input {
    height: 100%;
    min-height: 0;
  }

  .analytics-panel {
    gap: 8px;
  }

  #analyticsRegionsPanel .analytics-panel {
    height: clamp(440px, calc(100vh - 200px), 760px);
  }

  #analyticsMaterialsPanel .analytics-panel,
  #analyticsEntityPanel .analytics-panel {
    height: clamp(440px, calc(100vh - 200px), 760px);
  }
}

@media (max-width: 860px) {
  #projectToolbar .project-toolbar-add {
    display: none;
  }

  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    height: auto;
    gap: 8px;
    padding: 18px;
  }

  .sidebar-note {
    display: none;
  }

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

  .sidebar-actions {
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    margin-top: 0;
  }

  .nav-item {
    justify-content: center;
    padding: 10px 8px;
  }

  .main {
    height: auto;
    min-height: 0;
    overflow: visible;
    padding: 18px;
  }

  .modal {
    width: min(100% - 28px, 920px);
    max-height: calc(100dvh - 28px);
    margin: 14px auto;
  }

  .modal-panel {
    box-sizing: border-box;
    width: 100%;
    max-height: calc(100dvh - 28px);
    overflow-x: hidden;
    padding: 18px;
  }

  .modal-panel > * {
    min-width: 0;
    max-width: 100%;
  }

  .modal-header {
    gap: 10px;
  }

  .modal-header > div {
    max-width: none;
  }

  #detailsTitle {
    font-size: 20px;
    line-height: 1.16;
  }

  .project-area,
  .manager-section {
    flex: 0 1 auto;
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .form-grid,
  .details-grid,
  .project-meta-row,
  .project-status-row,
  .analytics-grid,
  .analytics-material-layout,
  .analytics-entity-layout,
  .analytics-region-layout,
  .manager-header {
    grid-template-columns: 1fr;
  }

  .analytics-map-card,
  .analytics-region-projects {
    height: auto;
    max-height: none;
  }

  .analytics-map-card {
    min-height: 360px;
  }

  #analyticsRegionsPanel .analytics-panel {
    height: auto;
  }

  #analyticsMaterialsPanel .analytics-panel,
  #analyticsEntityPanel .analytics-panel {
    height: auto;
  }

  .stats-row {
    flex-wrap: wrap;
    gap: 8px;
    margin: 4px 0 14px;
  }

  .stat {
    flex: 1 1 calc((100% - 16px) / 3);
    width: auto;
    min-height: 76px;
    padding: 10px 12px;
  }

  .stat span {
    left: 12px;
    bottom: -1px;
    max-width: 78px;
    font-size: 11px;
    line-height: 1.08;
    white-space: normal;
  }

  .stat strong {
    right: 8px;
    bottom: -8px;
    font-size: 58px;
  }

  #projectToolbar {
    align-items: stretch;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 14px;
  }

  #projectToolbar .segmented {
    display: none;
  }

  #projectToolbar #statusFilter,
  #projectToolbar .search-field {
    flex: 0 0 auto;
    width: 100%;
    max-width: none;
  }

  .manager-header {
    align-items: flex-start;
    flex-direction: column;
  }

  .manager-search {
    width: 100%;
    max-width: none;
    margin-right: 0;
  }

  .analytics-controls .manager-search,
  .analytics-controls select {
    flex: 0 0 auto;
    width: 100%;
    max-width: none;
  }

  .material-line {
    grid-template-columns: 1fr;
  }

  h1 {
    font-size: 28px;
  }

  .cards-grid {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  .project-card {
    height: 194px;
    padding: 16px;
  }

  .analytics-panel th:not(:first-child),
  .analytics-panel td:not(:first-child) {
    width: 82px;
  }
}
