:root {
  --bg: #ffffff;
  --ink: #0a0a0c;
  --muted: #8b8b95;
  --faint: #b6b6bf;
  --line: #ececef;
  --soft: #f6f6f8;
  --hover: #fafafb;
  --accent: #ff4d00;
  --gold: #a07708;
  --radius: 12px;
  font-size: 15px;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-feature-settings: "cv11";
  background: var(--bg);
  color: var(--ink);
  letter-spacing: -0.01em;
  -webkit-font-smoothing: antialiased;
}

/* ---------- Header ---------- */
header {
  display: flex; align-items: center; gap: 36px;
  padding: 18px 36px;
  border-bottom: 1px solid var(--line);
  position: sticky; top: 0; background: rgba(255,255,255,.86);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  z-index: 10;
}
.brand-block { display: flex; align-items: center; gap: 18px; }
.brand {
  font-weight: 800; font-size: 1.1rem; letter-spacing: .12em;
}
.brand sup { color: var(--accent); font-size: .55em; letter-spacing: 0; }
.partners { display: flex; align-items: center; gap: 14px; padding-left: 18px; border-left: 1px solid var(--line); }
.partners-label { font-size: .7rem; color: var(--muted); }
.partner-logo { height: 18px; width: auto; display: block; }
.partner-lockup { height: 22px; }
@media (max-width: 980px) { .partners-label { display: none; } }
@media (max-width: 680px) { .partners { display: none; } }
nav { display: flex; gap: 26px; flex: 1; }
nav button {
  border: none; background: none; padding: 4px 0;
  font: inherit; font-size: .93rem; font-weight: 500;
  color: var(--muted); cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: color .15s;
}
nav button.active { color: var(--ink); border-bottom-color: var(--ink); }
nav button:not(.active):hover { color: var(--ink); }
.header-right { display: flex; gap: 8px; align-items: center; }

/* ---------- Controls ---------- */
select, input[type="text"], input[type="number"], input[type="url"], textarea {
  font: inherit; font-size: .92rem;
  padding: 9px 12px;
  border: 1px solid var(--line); border-radius: 10px;
  background: #fff; color: var(--ink);
  outline: none; transition: border-color .15s, box-shadow .15s;
}
select:hover, input:hover, textarea:hover { border-color: #d8d8de; }
select:focus, input:focus, textarea:focus {
  border-color: var(--ink);
  box-shadow: 0 0 0 3px rgba(10,10,12,.06);
}
select {
  appearance: none; -webkit-appearance: none;
  background: var(--soft) url("data:image/svg+xml;charset=utf8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath d='M1 1l4 4 4-4' fill='none' stroke='%238b8b95' stroke-width='1.5' stroke-linecap='round'/%3E%3C/svg%3E") no-repeat right 12px center;
  border-color: transparent;
  padding-right: 32px; cursor: pointer;
}
select:hover { background-color: #efeff2; }

button.primary {
  font: inherit; font-size: .92rem; font-weight: 600;
  background: var(--ink); color: #fff;
  border: none; padding: 10px 20px; border-radius: 10px;
  cursor: pointer; transition: transform .1s, background .15s;
}
button.primary:hover { background: #000; }
button.primary:active { transform: scale(.98); }
button.primary:disabled { opacity: .35; cursor: default; }
button.ghost {
  font: inherit; font-size: .92rem; font-weight: 500;
  background: none; border: 1px solid var(--line);
  padding: 9px 16px; border-radius: 10px;
  cursor: pointer; color: var(--ink); transition: border-color .15s, background .15s;
}
button.ghost:hover { border-color: var(--ink); }
button.danger {
  color: var(--faint); border: none; background: none; cursor: pointer;
  font-size: .95rem; padding: 4px 8px; border-radius: 6px;
  transition: color .15s, background .15s;
}
button.danger:hover { color: #c0392b; background: #fdf1ef; }

/* ---------- Layout ---------- */
main { max-width: 1000px; margin: 0 auto; padding: 48px 36px 100px; }
.rating-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; margin-bottom: 30px; flex-wrap: wrap; }
.rating-head h1 { margin-bottom: 6px; }
.download-btn { text-decoration: none; white-space: nowrap; display: inline-block; }
h1 { font-size: 1.7rem; font-weight: 750; letter-spacing: -0.025em; margin-bottom: 6px; }
.sub { color: var(--muted); font-size: .95rem; margin-bottom: 36px; }

/* ---------- Tables ---------- */
table { width: 100%; border-collapse: collapse; }
th {
  text-align: left; font-size: .68rem; text-transform: uppercase; letter-spacing: .1em;
  color: var(--faint); padding: 0 14px 12px; border-bottom: 1px solid var(--line);
  font-weight: 600;
}
td { padding: 15px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; font-size: .95rem; }
tbody tr:last-child td { border-bottom: none; }
tr.clickable { cursor: pointer; }
tr.clickable:hover td { background: var(--hover); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.rank { color: var(--faint); font-variant-numeric: tabular-nums; width: 44px; font-size: .88rem; }
.final-score { font-weight: 750; font-size: 1.08rem; letter-spacing: -0.02em; }
.bonus-chip {
  display: inline-block; font-size: .75rem; font-weight: 650; color: var(--gold);
  background: #faf6e8; border-radius: 999px; padding: 3px 10px;
  font-variant-numeric: tabular-nums;
}
.breakdown { background: var(--soft); }
.breakdown > td { padding: 8px 14px 20px; border-bottom: 1px solid var(--line); }
.breakdown table { font-size: .87rem; }
.breakdown tr.fest-subhead td { background: #eceef1; padding-top: 8px; padding-bottom: 8px; }
.breakdown tr.award-row td:first-child { border-left: 2px solid var(--line); }
.breakdown th { padding: 10px 10px 8px; border: none; }
.breakdown td { border: none; padding: 5px 10px; }

/* ---------- Badges ---------- */
.award-badge {
  display: inline-block; font-size: .7rem; font-weight: 650;
  text-transform: uppercase; letter-spacing: .05em;
  padding: 4px 11px; border-radius: 999px; white-space: nowrap;
}
.award-shortlist { background: #f1f2f5; color: #6b7280; }
.award-bronze { background: #f6ece1; color: #966130; }
.award-silver { background: #eef0f4; color: #64748b; }
.award-gold { background: #faf1d4; color: #a07708; }
.award-best { background: #e8f1fc; color: #1e60ad; }
.award-grandprix { background: var(--ink); color: #fff; }

/* ---------- Festivals ---------- */
.fest-layout { display: grid; grid-template-columns: 270px 1fr; gap: 32px; align-items: start; }
.fest-list { display: flex; flex-direction: column; gap: 4px; position: sticky; top: 92px; }
.fest-item {
  text-align: left; font: inherit; border: none; background: none;
  border-radius: 10px; padding: 11px 14px; cursor: pointer;
  display: flex; justify-content: space-between; align-items: center; gap: 8px;
  transition: background .15s;
}
.fest-item.active { background: var(--ink); color: #fff; }
.fest-item.active .fest-level { color: rgba(255,255,255,.55); }
.fest-item.active .fest-mult { color: #fff; }
.fest-item:not(.active):hover { background: var(--soft); }
.fest-name-wrap { display: flex; align-items: center; gap: 9px; }
.vrk-dot { width: 9px; height: 9px; border-radius: 50%; flex: 0 0 9px; display: inline-block; }
.dot-green { background: #2e9e4f; }
.dot-gray { background: #cfcfd6; }
.dot-none { background: transparent; box-shadow: inset 0 0 0 1px #e2e2e8; }
.fest-item.active .dot-gray { background: #8a8a92; }
.fest-item.active .dot-none { box-shadow: inset 0 0 0 1px rgba(255,255,255,.35); }
.fest-name { font-weight: 550; font-size: .93rem; }
.fest-level { font-size: .72rem; color: var(--muted); display: block; margin-top: 1px; }
.fest-mult { font-weight: 700; font-variant-numeric: tabular-nums; color: var(--muted); font-size: .9rem; }

.panel { border: 1px solid var(--line); border-radius: 16px; padding: 24px; margin-bottom: 18px; }
.panel h3 { font-size: .95rem; font-weight: 650; letter-spacing: -0.01em; margin-bottom: 16px; }
.form-row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.form-row input[type="text"] { flex: 1; min-width: 170px; }
.fest-note { color: var(--muted); font-size: .84rem; margin-top: 6px; }

/* ---------- Modal ---------- */
.modal {
  position: fixed; inset: 0; background: rgba(10,10,12,.4);
  backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px);
  display: flex; align-items: center; justify-content: center; z-index: 50; padding: 20px;
}
.modal.hidden { display: none; }
.modal-box {
  background: #fff; border-radius: 20px; padding: 30px;
  width: 100%; max-width: 860px; max-height: 90vh; overflow-y: auto;
  box-shadow: 0 24px 80px rgba(10,10,12,.18);
}
.modal-box h2 { font-size: 1.15rem; font-weight: 700; letter-spacing: -0.02em; margin-bottom: 4px; }
.modal-box .sub { margin-bottom: 20px; }
.drop-zone {
  border: 1.5px dashed #d8d8de; border-radius: 14px; padding: 30px;
  text-align: center; color: var(--muted); font-size: .92rem;
  cursor: pointer; margin-bottom: 12px; transition: border-color .15s, color .15s;
}
.drop-zone:hover { border-color: var(--ink); color: var(--ink); }
.drop-zone.drag { border-color: var(--accent); color: var(--accent); }
.thumbs { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.thumbs img { height: 64px; border-radius: 8px; border: 1px solid var(--line); }
.pdf-chip {
  display: inline-flex; align-items: center; height: 64px; padding: 0 16px;
  border-radius: 8px; border: 1px solid var(--line); background: var(--soft);
  font-size: .85rem; font-weight: 500; color: var(--ink); max-width: 220px;
  overflow: hidden; white-space: nowrap; text-overflow: ellipsis;
}
.import-src { display: flex; flex-direction: column; gap: 10px; margin-bottom: 16px; }
.review-table select, .review-table input { font-size: .85rem; padding: 6px 8px; }
select.uncertain { background-color: #faf1d4; border-color: #e5c76a; }
.uncertain-note { font-size: .74rem; color: var(--gold); margin-top: 4px; }

/* ---------- Звірка ВРК ---------- */
.vrk-pills { display: flex; gap: 6px; margin-bottom: 8px; flex-wrap: wrap; }
.vrk-pill {
  font: inherit; font-size: .9rem; font-weight: 500;
  background: var(--soft); border: none; color: var(--muted);
  padding: 9px 18px; border-radius: 999px; cursor: pointer;
  transition: background .15s, color .15s;
}
.vrk-pill.active { background: var(--ink); color: #fff; }
.vrk-pill:not(.active):hover { background: #efeff2; color: var(--ink); }
.st-chip {
  display: inline-block; font-size: .74rem; font-weight: 650;
  padding: 4px 11px; border-radius: 999px; white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
.st-ok { background: #e7f4e8; color: #2e7d38; }
.st-diff { background: #fdecea; color: #c0392b; }
.st-warn { background: #faf1d4; color: #a07708; }
.st-mute { background: #f1f2f5; color: #8b8b95; }
.spinner {
  display: inline-block; width: 15px; height: 15px;
  border: 2px solid rgba(255,255,255,.3); border-top-color: #fff;
  border-radius: 50%; animation: spin .7s linear infinite;
  vertical-align: -3px; margin-right: 8px;
}
@keyframes spin { to { transform: rotate(360deg); } }

.toast {
  position: fixed; bottom: 28px; left: 50%; transform: translateX(-50%);
  background: var(--ink); color: #fff;
  padding: 12px 24px; border-radius: 999px;
  font-size: .9rem; font-weight: 500; z-index: 100;
  box-shadow: 0 8px 30px rgba(10,10,12,.25);
  transition: opacity .25s, transform .25s;
}
.toast.hidden { opacity: 0; transform: translateX(-50%) translateY(8px); pointer-events: none; }
.toast.error { background: #c0392b; }

/* ---------- Methodology ---------- */
.method h2 { font-size: 1.02rem; font-weight: 700; letter-spacing: -0.015em; margin: 34px 0 10px; }
.method p, .method li { line-height: 1.65; color: #3c3c43; max-width: 700px; font-size: .95rem; }
.method ul { padding-left: 20px; }
.formula {
  font-family: "SF Mono", ui-monospace, Menlo, monospace;
  background: var(--soft); border-radius: 12px;
  padding: 16px 20px; margin: 12px 0; font-size: .88rem;
}
.pill-row { display: flex; gap: 8px; flex-wrap: wrap; margin: 12px 0; }

.empty { color: var(--faint); text-align: center; padding: 48px 0; font-size: .93rem; }

.session-bar {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  background: var(--soft); border-radius: 12px;
  padding: 12px 16px; margin-bottom: 28px; font-size: .9rem;
}
.session-bar button.ghost { padding: 7px 13px; font-size: .86rem; background: #fff; }
button.ghost.danger-btn { color: #c0392b; }
button.ghost.danger-btn:hover { border-color: #c0392b; background: #fdf1ef; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.panel-head button.ghost { padding: 7px 13px; font-size: .84rem; }

@media (max-width: 760px) {
  header { flex-wrap: wrap; gap: 12px 20px; padding: 14px 18px; }
  nav { gap: 18px; }
  main { padding: 28px 18px 70px; }
  h1 { font-size: 1.4rem; }
  .fest-layout { grid-template-columns: 1fr; }
  .fest-list { position: static; flex-direction: row; overflow-x: auto; padding-bottom: 6px; }
  .fest-item { min-width: 185px; border: 1px solid var(--line); }
  .fest-item.active { border-color: var(--ink); }
}

/* ---------- Екран входу ---------- */
.login-screen {
  position: fixed; inset: 0; z-index: 1000;
  display: flex; align-items: center; justify-content: center;
  background: var(--bg);
  padding: 24px;
}
.login-screen.hidden { display: none; }
.login-box {
  display: flex; flex-direction: column; gap: 12px;
  width: 100%; max-width: 320px;
  padding: 34px 30px 30px;
  border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: 0 20px 60px rgba(10,10,12,.07);
  text-align: center;
}
.login-brand { font-size: 1.9rem; font-weight: 800; letter-spacing: -0.03em; }
.login-brand sup { font-size: .5em; font-weight: 600; top: -.7em; }
.login-sub { font-size: .82rem; color: var(--muted); margin-bottom: 12px; }
.login-box input {
  width: 100%; text-align: left; font-size: .95rem;
  padding: 11px 13px; border: 1px solid var(--line); border-radius: 10px;
  background: #fff; color: var(--ink); outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.login-box input:focus { border-color: var(--ink); box-shadow: 0 0 0 3px rgba(10,10,12,.06); }
.login-box button.primary { width: 100%; margin-top: 4px; padding: 12px; }
.login-err { font-size: .82rem; color: #c0392b; min-height: 1em; }

/* ---------- Бейдж ролі ---------- */
.role-badge {
  font-size: .72rem; font-weight: 600; letter-spacing: .02em;
  text-transform: uppercase; color: var(--muted);
  padding: 3px 9px; border: 1px solid var(--line); border-radius: 999px;
}
.role-badge:empty { display: none; }

/* ---------- Агенції: довідник ---------- */
.ag-toolbar { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; margin: 18px 0 6px; }
.ag-search { flex: 1; min-width: 220px; }
.seg-group { display: inline-flex; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.seg { font: inherit; font-size: .84rem; padding: 8px 14px; background: #fff; border: none; border-right: 1px solid var(--line); cursor: pointer; color: var(--muted); }
.seg:last-child { border-right: none; }
.seg:hover { background: var(--hover); color: var(--ink); }
.seg.active { background: var(--ink); color: #fff; }
.ag-valid-toggle { display: inline-flex; align-items: center; gap: 7px; font-size: .84rem; color: var(--muted); cursor: pointer; }
.ag-valid-toggle input { width: 15px; height: 15px; accent-color: var(--ink); }
.ag-actions { display: flex; flex-direction: column; gap: 10px; margin: 8px 0 14px; }
.ag-add-inp { min-width: 240px; }
.ag-copy-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.ag-copy-label { font-size: .84rem; color: var(--muted); }

.ag-list { display: flex; flex-direction: column; gap: 8px; }
.ag-card { border: 1px solid var(--line); border-radius: var(--radius); background: #fff; transition: border-color .15s, box-shadow .15s; }
.ag-card:hover { border-color: #d8d8de; }
.ag-card.is-open { border-color: var(--ink); box-shadow: 0 6px 24px rgba(10,10,12,.06); }
.ag-card.is-excluded { background: var(--soft); }
.ag-head { display: flex; align-items: center; gap: 16px; padding: 13px 16px; cursor: pointer; }
.ag-rank { flex: none; width: 46px; font-weight: 700; font-size: .95rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.ag-main { flex: 1; min-width: 0; }
.ag-name-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.ag-name { font-weight: 600; font-size: 1rem; }
.ag-badges { display: inline-flex; gap: 6px; flex-wrap: wrap; }
.status-badge { font-size: .68rem; font-weight: 600; text-transform: uppercase; letter-spacing: .02em; padding: 2px 8px; border-radius: 999px; }
.status-badge.valid { background: #e9f6ec; color: #1a7f37; }
.status-badge.excluded { background: #fbeaea; color: #b3261e; }
.type-badge { font-size: .68rem; font-weight: 600; padding: 2px 8px; border-radius: 999px; background: var(--soft); color: var(--muted); border: 1px solid var(--line); }
.alias-row { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin-top: 5px; }
.alias-label { font-size: .72rem; color: var(--faint); }
.alias-chip { font-size: .74rem; padding: 1px 8px; border-radius: 6px; background: var(--soft); color: var(--muted); border: 1px solid var(--line); }
.ag-metrics { flex: none; display: flex; align-items: center; gap: 22px; }
.ag-metric { text-align: right; line-height: 1.1; }
.ag-metric .m-val { display: block; font-weight: 700; font-size: .95rem; font-variant-numeric: tabular-nums; }
.ag-metric .m-lab { font-size: .68rem; color: var(--faint); text-transform: uppercase; letter-spacing: .03em; }
.ag-caret { color: var(--faint); font-size: .7rem; }

.ag-detail { padding: 4px 16px 18px; border-top: 1px solid var(--line); }
.ag-id-box { display: flex; gap: 14px; flex-wrap: wrap; padding: 14px 0; border-bottom: 1px dashed var(--line); margin-bottom: 14px; }
.ag-id-box .ag-field { flex: 1; min-width: 200px; }
.field-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 18px; }
.ag-field { display: flex; flex-direction: column; gap: 5px; }
.ag-field.full { grid-column: 1 / -1; }
.ag-flabel { font-size: .74rem; font-weight: 600; color: var(--muted); }
.ag-field input, .ag-field textarea, .ag-field select { width: 100%; }
.ag-detail.readonly .ag-fval { font-size: .9rem; white-space: pre-wrap; line-height: 1.5; }
.ag-detail.readonly .ag-field { padding: 8px 0; border-bottom: 1px solid var(--line); }
.ag-save-row { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-top: 18px; }
.empty-note { padding: 24px; text-align: center; color: var(--faint); font-size: .9rem; }
@media (max-width: 640px) {
  .field-grid { grid-template-columns: 1fr; }
  .ag-metrics { gap: 14px; }
  .ag-head { flex-wrap: wrap; }
}

/* ---------- Огляд імпорту: панель керування ---------- */
.review-toolbar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin: 6px 0 12px; }
.review-toolbar .review-count { margin-left: auto; font-size: .85rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.review-table tr.row-flagged td { background: #fdf6ec; }
.review-table tr.row-off td { opacity: .5; }
.review-table tr.row-off .fest-note { color: #b3822a; }

.season-cell { white-space: nowrap; }

/* ---------- Каскад: поглинуті відзнаки ---------- */
.award-row.absorbed td { opacity: .5; }
.absorbed-tag { font-size: .68rem; color: var(--muted); margin-left: 8px; padding: 1px 7px; border: 1px solid var(--line); border-radius: 999px; text-transform: uppercase; letter-spacing: .02em; }

/* ---------- Редактор індексу престижності / N_eff ---------- */
.idx-wrap > summary { cursor: pointer; font-size: .9rem; font-weight: 600; color: var(--ink); padding: 6px 0; }
.idx-editor { padding: 12px 0 4px; }
.idx-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; }
.idx-field { display: flex; flex-direction: column; gap: 5px; }
.idx-field span { font-size: .74rem; font-weight: 600; color: var(--muted); }
.idx-field input { width: 100%; }
.idx-summary { margin-top: 14px; padding: 12px 14px; background: var(--soft); border-radius: 10px; font-size: .9rem; }
.idx-mult { font-weight: 800; font-size: 1.05rem; }
.idx-neff { margin-top: 12px; }
.idx-neff > summary { cursor: pointer; font-size: .84rem; color: var(--accent); }
.idx-neff textarea { width: 100%; }

/* ---------- Ручне об'єднання проєктів ---------- */
.merge-bar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin: 4px 0 12px; }
.merge-bar .merge-hint { margin-right: auto; }
.merge-bar .merge-btn:disabled { opacity: .4; cursor: default; }
.proj-chip { margin-left: 6px; font-size: .8rem; }
tr.band-a td { background: #f3f6fb; }
tr.band-b td { background: #fbf3ee; }
.proj-count { margin-left: 8px; font-size: .72rem; color: var(--muted); background: #fff; border: 1px solid var(--line); border-radius: 999px; padding: 1px 8px; white-space: nowrap; }

/* ---------- Кнопка синтезованого рейтингу (активний стан) ---------- */
.session-bar button.btn-synth { background: #e6f4fb; border-color: #a9d6ee; color: #0a5a8a; font-weight: 600; }
.session-bar button.btn-synth:hover { border-color: #0a5a8a; background: #d8edf9; }

/* ---------- Синтез: award probability ---------- */
.prob-tag { font-size: .72rem; font-weight: 600; padding: 2px 9px; border-radius: 999px; background: #e6f4fb; color: #0a6ba8; border: 1px solid #a9d6ee; }
