:root {
  --bg: #f4f6fc;
  --bg-card: #ffffff;
  --bg-soft: #e8edf8;
  --bg-hover: #f0f4ff;
  --navy: #1a2b6d;
  --navy-soft: #2d4494;
  --fuchsia: #c2189a;
  --fuchsia-soft: #e879f9;
  --fuchsia-muted: #f5d0fe;
  --accent: #3d5fcc;
  --accent-soft: #5b7ee8;
  --text: #1c2340;
  --muted: #5c668a;
  --border: #c5cee8;
  --ok: #2a9d6a;
  --warn: #c47d12;
  --danger: #c44;
  --radius: 12px;
  --font: "Segoe UI", system-ui, sans-serif;
  --page-pad: 1.25rem;
  --page-max: 100%;
  /* базовый масштаб ≈ браузерный zoom 75% при 100% */
  --ui-scale: 0.75;
  --ui-scale-effective: var(--ui-scale);
}

html {
  font-size: calc(16px * var(--ui-scale-effective));
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: 1rem;
  background: linear-gradient(165deg, #eef2fb 0%, #f8f9fd 45%, #edf1fa 100%);
  color: var(--text);
  min-height: 100vh;
}

header {
  padding: 1.1rem var(--page-pad);
  border-bottom: 2px solid var(--fuchsia-soft);
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 1rem;
  background: linear-gradient(90deg, var(--navy) 0%, var(--navy-soft) 70%, #3a5299 100%);
  color: #fff;
}

.brand h1 {
  margin: 0;
  font-size: 1.1rem;
  font-weight: 600;
  line-height: 1.35;
  max-width: none;
}

.expert-line {
  margin: 0.35rem 0 0;
  font-size: 0.95rem;
  color: rgba(255, 255, 255, 0.85);
}

.tabs {
  display: flex;
  gap: 0.5rem;
  flex-shrink: 0;
}

.tab {
  padding: 0.5rem 1rem;
  border: 1px solid rgba(255, 255, 255, 0.35);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  color: rgba(255, 255, 255, 0.9);
  cursor: pointer;
  font-size: 0.9rem;
}

.tab.active {
  background: var(--fuchsia);
  border-color: var(--fuchsia-soft);
  color: #fff;
  font-weight: 600;
}

.tab.hidden {
  display: none;
}

.tab:disabled {
  cursor: default;
  opacity: 0.85;
}

.hint {
  margin: 1rem 0 0;
  padding: 0.85rem 1rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-left: 4px solid var(--fuchsia);
  border-radius: var(--radius);
  font-size: 0.95rem;
  line-height: 1.45;
  color: var(--muted);
}
.hint p {
  margin: 0 0 0.55rem;
}
.hint p:last-child {
  margin-bottom: 0;
}
.hint .hint-h {
  font-weight: 700;
  color: var(--text);
  margin: 0.9rem 0 0.4rem;
}
.hint .hint-h:first-child {
  margin-top: 0;
}
.hint .hint-list {
  margin: 0.2rem 0 0.55rem;
  padding-left: 1.25rem;
}
.hint .hint-list li {
  margin: 0.15rem 0;
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  padding: 1rem 0;
  align-items: flex-end;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  font-size: 0.8rem;
  color: var(--muted);
}

.field span:first-child {
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  font-size: 0.72rem;
}

select, button, input, textarea {
  font: inherit;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text);
  padding: 0.45rem 0.75rem;
}

.expert-name {
  font-size: 1rem;
  font-weight: 600;
  color: var(--navy);
  padding: 0.45rem 0;
}

.hidden { display: none !important; }

.page-shell {
  width: 100%;
  max-width: var(--page-max);
  margin: 0 auto;
  padding: 0 var(--page-pad) 2rem;
}

main {
  padding: 0;
  max-width: none;
  margin: 0;
}

.table-wrap {
  overflow-x: auto;
  overflow-y: visible;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-card);
  box-shadow: 0 2px 12px rgba(26, 43, 109, 0.06);
}

.read-only { background: #f8f9fd; color: var(--muted); }

.ro-comment {
  white-space: pre-wrap;
  font-size: inherit;
  line-height: 1.35;
  max-height: 7em;
  overflow: auto;
}

.section-title {
  font-size: 1.1rem;
  color: var(--navy);
  margin: 1.5rem 0 0.75rem;
}

.team-table th { white-space: normal; }

.grid-table {
  table-layout: fixed;
  width: 100%;
  min-width: 52rem;
  font-size: 1rem;
  border-collapse: collapse;
}

/* доли в сумме 100% — лист эксперта */
.col-num { width: 3%; }
.col-name { width: 14%; }
.col-info { width: 18%; line-height: 1.35; }
.col-score { width: 6%; }
.col-result { width: 10%; }
.col-comment { width: 24%; }
.col-action { width: 8%; text-align: center; vertical-align: middle; }

.col-score input {
  padding: 0.35em 0.3em;
  text-align: center;
}

th.col-num,
td.col-num {
  padding-left: 0.25rem;
  padding-right: 0.25rem;
}

.col-action .btn-link {
  display: inline-block;
  font-size: 0.95em;
  padding: 0.4em 0.55em;
  line-height: 1.2;
  white-space: nowrap;
  max-width: 100%;
  box-sizing: border-box;
}

.grid-table th,
.grid-table td {
  min-width: 0;
  overflow-wrap: anywhere;
  padding: 0.45em 0.55em;
}

.align-center { text-align: center; }

th, td {
  padding: 0.45rem 0.5rem;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
  text-align: left;
}

th {
  background: var(--bg-soft);
  color: var(--navy);
  font-weight: 600;
  position: sticky;
  top: 0;
  z-index: 1;
  text-align: center;
}

tr:hover td { background: var(--bg-hover); }

td input, td select, td textarea {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  font: inherit;
  background: #fff;
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 6px;
  padding: 0.4em 0.5em;
  box-sizing: border-box;
}

td textarea {
  min-height: 3.6em;
  resize: vertical;
}

.info-cell {
  word-break: break-word;
  overflow-wrap: anywhere;
}

td input.score-invalid {
  border-color: var(--danger);
  background: #fff5f5;
}

.name-link {
  color: var(--accent);
  cursor: pointer;
  text-decoration: underline;
  background: none;
  border: none;
  padding: 0;
  font: inherit;
  text-align: left;
}

.team-members {
  margin-top: 0.25rem;
  font-size: 0.78rem;
  color: var(--muted);
  line-height: 1.35;
}

.kind-tag {
  display: inline-block;
  font-size: 0.68rem;
  padding: 0.1rem 0.4rem;
  border-radius: 4px;
  background: var(--bg-soft);
  color: var(--navy-soft);
  margin-top: 0.2rem;
}

.past-thanks {
  margin-top: 0.3rem;
  font-size: 0.76rem;
  line-height: 1.35;
  color: var(--fuchsia);
  font-weight: 500;
}

.btn-link {
  display: inline-block;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: 4px;
  color: inherit;
  text-decoration: none;
  cursor: pointer;
  font-size: 0.82rem;
  white-space: nowrap;
}

.btn-link:hover {
  background: var(--accent-soft);
  color: #fff;
  border-color: var(--accent-soft);
}

.saved-flash {
  color: var(--ok);
  font-size: 0.75rem;
  margin-top: 0.15rem;
}

.score-hint {
  color: var(--danger);
  font-size: 0.72rem;
}

/* Participant page */
.participant-page {
  background: linear-gradient(165deg, #eef2fb 0%, #f8f9fd 45%, #edf1fa 100%);
}

.participant-header {
  padding: 0.85rem var(--page-pad);
  border-bottom: 2px solid var(--fuchsia-soft);
  background: linear-gradient(90deg, var(--navy) 0%, var(--navy-soft) 70%, #3a5299 100%);
  color: #fff;
}

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

.participant-wrap {
  width: 100%;
  padding: 1rem 0 0;
}

.participant-head {
  display: flex;
  gap: 1.25em;
  align-items: flex-start;
  margin-bottom: 1.25em;
  flex-wrap: wrap;
}

.participant-head .photo {
  max-width: min(240px, 35vw);
  max-height: 300px;
  width: auto;
  height: auto;
  object-fit: contain;
  border-radius: 10px;
  border: 2px solid var(--fuchsia-soft);
  flex-shrink: 0;
  background: #fff;
}

.participant-head h1 {
  margin: 0 0 0.35em;
  font-size: 1.35em;
  color: var(--navy);
}

.participant-head .meta {
  color: var(--muted);
  font-size: 0.95em;
  line-height: 1.45;
}

.participant-head .members {
  margin-top: 0.75em;
  font-size: inherit;
}

.participant-head .members ul {
  margin: 0.35em 0 0;
  padding-left: 1.2em;
}

.ach-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: #fff;
  box-shadow: 0 2px 12px rgba(26, 43, 109, 0.06);
}

.ach-table {
  width: 100%;
  min-width: 44rem;
  border-collapse: collapse;
  font-size: 1rem;
  table-layout: fixed;
}

.ach-table th,
.ach-table td {
  padding: 0.45em 0.55em;
  border: 1px solid var(--border);
  vertical-align: top;
  word-break: break-word;
  overflow-wrap: anywhere;
  min-width: 0;
}

.ach-table th {
  background: var(--navy);
  color: #fff;
  font-weight: 500;
  white-space: normal;
  text-align: center;
  line-height: 1.3;
}

.ach-table a {
  color: var(--accent);
  word-break: break-all;
}

.ach-table .col-ach-num { width: 3%; }
.ach-table .col-ach-type { width: 10%; }
.ach-table .col-ach-level { width: 9%; }
.ach-table .col-ach-org { width: 18%; }
.ach-table .col-ach-reason { width: 24%; }
.ach-table .col-ach-year { width: 6%; }
.ach-table .col-ach-city { width: 8%; }
.ach-table .col-ach-proof { width: 14%; }

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

.denied-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 2rem;
}

.denied-box {
  max-width: 28rem;
  padding: 2rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-left: 4px solid var(--fuchsia);
  border-radius: var(--radius);
  box-shadow: 0 2px 12px rgba(26, 43, 109, 0.08);
}

.denied-box h1 {
  margin: 0 0 0.75rem;
  font-size: 1.2rem;
  color: var(--navy);
}

.denied-muted {
  color: var(--muted);
  font-size: 0.9rem;
}

.participant-header-row {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
}

.btn-back {
  display: inline-flex;
  align-items: center;
  padding: 0.4rem 0.75rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.35);
  color: #fff;
  text-decoration: none;
  font-size: 0.9rem;
  white-space: nowrap;
}

.btn-back:hover {
  background: rgba(255, 255, 255, 0.22);
}

.btn-back.hidden {
  display: none;
}

.direction-block + .direction-block {
  margin-top: 1.5rem;
}

.dir-note {
  margin: -0.35rem 0 0.65rem;
  font-size: 0.88em;
  color: var(--fuchsia);
}

@media (max-width: 1100px) {
  .grid-table { min-width: 48rem; }
}

@media (max-width: 768px) {
  .toolbar { flex-direction: column; align-items: stretch; }
  .field select { width: 100%; }
  .ach-table { min-width: 36rem; font-size: 0.95em; }
  .participant-head .photo { max-width: min(200px, 50vw); }
}
