:root {
  --bg: #f4f2ee;
  --panel: #ffffff;
  --ink: #1d2327;
  --muted: #646d73;
  --line: #e2ded6;
  --accent: #1f5f4a;      /* хвойный — спортивный туризм */
  --accent-ink: #ffffff;
  --accent-soft: #e5efe9;
  --ok: #2f7d4f;   --ok-bg: #e3f1e8;
  --warn: #9a6400; --warn-bg: #fcf0d4;
  --bad: #b23a2c;  --bad-bg: #f9e1dd;
  --mute-bg: #ecebe8;
  --radius: 8px;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}
* { box-sizing: border-box; }
html { font-size: 15px; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font-family: -apple-system, "Segoe UI", Roboto, "PT Sans", Arial, sans-serif; line-height: 1.45;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.6rem; margin: 0 0 .25rem; letter-spacing: -.01em; }
h2 { font-size: 1.15rem; margin: 0 0 .75rem; }
h3 { font-size: 1rem; margin: 0 0 .5rem; }
.muted { color: var(--muted); }
.small { font-size: .87rem; }
.num { font-variant-numeric: tabular-nums; }

/* --- каркас -------------------------------------------------------------- */
.shell { display: grid; grid-template-columns: 230px minmax(0, 1fr); min-height: 100vh; }
.side { background: #19302a; color: #d9e4de; padding: 1.25rem .9rem; position: sticky; top: 0; height: 100vh; }
.brand { display: flex; gap: .6rem; align-items: center; margin-bottom: 1.5rem; color: #fff; }
.brand svg { flex: none; }
.brand b { display: block; font-size: .98rem; line-height: 1.15; }
.brand span { font-size: .75rem; color: #9fb5ab; }
.nav a { display: flex; justify-content: space-between; align-items: center; padding: .5rem .65rem; border-radius: 6px;
  color: #d9e4de; margin-bottom: 2px; }
.nav a:hover { background: rgba(255,255,255,.07); text-decoration: none; }
.nav a.on { background: rgba(255,255,255,.13); color: #fff; }
.nav .count { background: #e3a33a; color: #19302a; border-radius: 10px; padding: 0 .45rem; font-size: .75rem; font-weight: 700; }
.nav-sep { height: 1px; background: rgba(255,255,255,.1); margin: .8rem 0; }
.side .who { position: absolute; bottom: 1rem; left: .9rem; right: .9rem; font-size: .82rem; color: #9fb5ab; }
.side .who form { display: inline; }
.side .who button { background: none; border: 0; color: #d9e4de; padding: 0; cursor: pointer; font: inherit; text-decoration: underline; }
.main { padding: 1.75rem 2rem 3rem; max-width: 1280px; width: 100%; }
.head { display: flex; justify-content: space-between; align-items: flex-end; gap: 1rem; margin-bottom: 1.25rem; flex-wrap: wrap; }
.head .actions { display: flex; gap: .5rem; flex-wrap: wrap; }

/* --- блоки --------------------------------------------------------------- */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.1rem 1.25rem; margin-bottom: 1.1rem; }
.card > h2:first-child { display: flex; justify-content: space-between; align-items: center; }
.grid { display: grid; gap: 1.1rem; align-items: start; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.stat { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: .9rem 1rem; }
.stat .v { font-size: 1.7rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.stat .l { color: var(--muted); font-size: .85rem; }
.stat.alert .v { color: var(--bad); }
.stat.warn .v { color: var(--warn); }

dl.facts { display: grid; grid-template-columns: max-content 1fr; gap: .3rem 1rem; margin: 0; }
dl.facts dt { color: var(--muted); }
dl.facts dd { margin: 0; }

/* --- таблицы ------------------------------------------------------------- */
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: .5rem .55rem; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: .78rem; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); font-weight: 600; background: #faf9f7; }
tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: #fbfaf8; }
.table-wrap { overflow-x: auto; }
td.r, th.r { text-align: right; }
.points-table td, .points-table th { padding: .3rem .35rem; text-align: center; font-size: .82rem; }
.points-table td:first-child, .points-table th:first-child { text-align: left; }
.points-table td.z { color: #c4c0b8; }
.points-table th.v { writing-mode: vertical-rl; transform: rotate(180deg); height: 11rem; text-transform: none; letter-spacing: 0; font-weight: 500; vertical-align: bottom; }

/* --- метки --------------------------------------------------------------- */
.badge { display: inline-block; padding: .1rem .5rem; border-radius: 99px; font-size: .78rem; font-weight: 600; white-space: nowrap; }
.b-ok { background: var(--ok-bg); color: var(--ok); }
.b-soon { background: var(--warn-bg); color: var(--warn); }
.b-overdue, .b-expired_ys, .b-bad { background: var(--bad-bg); color: var(--bad); }
.b-none, .b-deprived, .b-mute { background: var(--mute-bg); color: var(--muted); }
.b-pending { background: var(--warn-bg); color: var(--warn); }
.b-approved { background: var(--ok-bg); color: var(--ok); }
.b-rejected { background: var(--bad-bg); color: var(--bad); }
.cat { display: inline-block; min-width: 2.3rem; text-align: center; padding: .1rem .4rem; border-radius: 5px; font-weight: 700;
  font-size: .82rem; background: var(--accent-soft); color: var(--accent); }
.cat-VK { background: #1f5f4a; color: #fff; }
.cat-none { background: var(--mute-bg); color: var(--muted); }
.warn-text { color: var(--bad); font-size: .85rem; }

/* --- прогресс ------------------------------------------------------------ */
.progress { margin-bottom: .2rem; }
.bar { height: 8px; background: var(--mute-bg); border-radius: 99px; overflow: hidden; margin: .4rem 0 .8rem; }
.bar > i { display: block; height: 100%; background: var(--accent); }
.bar.done > i { background: var(--ok); }
.checks { list-style: none; padding: 0; margin: 0; }
.checks li { display: grid; grid-template-columns: 1.3rem 1fr auto; gap: .4rem; padding: .28rem 0; border-bottom: 1px dashed var(--line); font-size: .92rem; }
.checks li:last-child { border-bottom: 0; }
.checks .i-ok { color: var(--ok); } .checks .i-no { color: var(--bad); } .checks .i-wait { color: var(--muted); }
.checks .d { color: var(--muted); font-size: .85rem; text-align: right; max-width: 15rem; }
.calc-table { margin-top: .4rem; }
.calc-table td { padding: .3rem .35rem; font-size: .84rem; }
.calc-table tr.skipped td { color: var(--muted); }
.calc-table .why { color: var(--bad); font-size: .8rem; }
.calc-table .i-ok { color: var(--ok); } .calc-table .i-no { color: #c9a29c; }
.callout { border-left: 3px solid var(--accent); background: var(--accent-soft); padding: .6rem .8rem; border-radius: 0 6px 6px 0; font-size: .9rem; margin: .6rem 0; }
.callout.warn { border-color: var(--warn); background: var(--warn-bg); }
.callout.bad { border-color: var(--bad); background: var(--bad-bg); }

/* --- формы --------------------------------------------------------------- */
label { display: block; font-size: .85rem; color: var(--muted); margin-bottom: .2rem; }
input, select, textarea { width: 100%; padding: .48rem .6rem; border: 1px solid #cfcac1; border-radius: 6px; font: inherit; background: #fff; color: var(--ink); }
input:focus, select:focus, textarea:focus { outline: 2px solid #9cc4b2; border-color: var(--accent); }
textarea { min-height: 4.5rem; }
.field { margin-bottom: .8rem; }
.row { display: grid; gap: .8rem; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); }
.inline { display: flex; gap: .5rem; align-items: end; flex-wrap: wrap; }
.inline .field { margin: 0; flex: 1 1 160px; }
.check-inline { display: flex; align-items: center; gap: .4rem; color: var(--ink); font-size: .92rem; }
.check-inline input { width: auto; }
.btn { display: inline-flex; align-items: center; gap: .35rem; padding: .48rem .9rem; border-radius: 6px; border: 1px solid var(--accent);
  background: var(--accent); color: var(--accent-ink); font: inherit; font-weight: 600; cursor: pointer; white-space: nowrap; }
.btn:hover { filter: brightness(1.08); text-decoration: none; }
.btn.ghost { background: #fff; color: var(--accent); }
.btn.danger { background: #fff; color: var(--bad); border-color: #e2b4ad; }
.btn.sm { padding: .25rem .55rem; font-size: .85rem; font-weight: 500; }
.linkbtn { background: none; border: 0; color: var(--bad); cursor: pointer; padding: 0; font: inherit; font-size: .85rem; }
details.add > summary { cursor: pointer; color: var(--accent); font-weight: 600; margin: .4rem 0; list-style: none; }
details.add > summary::before { content: "+ "; }
details.add[open] { background: #faf9f7; border: 1px solid var(--line); border-radius: 6px; padding: .6rem .9rem .9rem; }
.filters { display: flex; gap: .5rem; flex-wrap: wrap; margin-bottom: 1rem; }
.filters input, .filters select { width: auto; min-width: 180px; }
.filters input[type=checkbox] { min-width: 0; }

.flash { padding: .65rem .9rem; border-radius: 6px; margin-bottom: 1rem; }
.flash.ok { background: var(--ok-bg); color: var(--ok); }
.flash.error { background: var(--bad-bg); color: var(--bad); }

.tabs { display: flex; gap: .2rem; border-bottom: 1px solid var(--line); margin-bottom: 1rem; }
.tabs a { padding: .5rem .9rem; color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tabs a.on { color: var(--ink); border-color: var(--accent); }

.drop { display: flex; flex-direction: column; align-items: center; gap: .3rem; padding: 2rem 1rem; border: 2px dashed #cfcac1;
  border-radius: var(--radius); background: #faf9f7; cursor: pointer; text-align: center; color: var(--ink); font-size: 1rem; }
.drop:hover { border-color: var(--accent); }
.drop input { width: auto; border: 0; background: none; }
.import-card h2 { gap: .6rem; flex-wrap: wrap; }
/* --- фото ---------------------------------------------------------------- */
.profile { display: grid; grid-template-columns: 132px minmax(0, 1fr); gap: 1.2rem; align-items: start; }
.photo-box { display: flex; flex-direction: column; align-items: center; gap: .35rem; text-align: center; }
.photo { display: block; width: 132px; height: 176px; object-fit: cover; border-radius: 6px; border: 1px solid var(--line); background: #faf9f7; }
.photo-empty { display: flex; flex-direction: column; align-items: center; justify-content: flex-end; color: #d3cec5; padding-bottom: .6rem; }
.photo-empty span { color: var(--muted); font-size: .78rem; margin-top: .3rem; }
.photo-pick { cursor: pointer; }
.photo-hint { font-size: .74rem; line-height: 1.2; }
.import-head { display: flex; gap: 1rem; align-items: flex-start; }
.who-cell { display: flex; gap: .65rem; align-items: center; }
.avatar { flex: none; width: 36px; height: 48px; border-radius: 4px; object-fit: cover; border: 1px solid var(--line); }
.avatar-empty { display: inline-flex; align-items: center; justify-content: center; background: var(--accent-soft); color: var(--accent);
  font-size: .75rem; font-weight: 700; }
@media (max-width: 560px) { .profile { grid-template-columns: 1fr; } }
/* --- публичный реестр ---------------------------------------------------- */
.pub-head { background: #19302a; color: #fff; }
.pub-wrap { max-width: 1120px; margin: 0 auto; padding: 0 1.25rem; }
.pub-brand { display: flex; gap: .9rem; align-items: center; padding-top: 1.4rem; padding-bottom: 1.4rem; }
.pub-brand h1 { color: #fff; font-size: 1.7rem; margin: 0; }
.pub-org { color: #9fb5ab; font-size: .9rem; }
.public main { padding-top: 1.4rem; padding-bottom: 3rem; }
.pub-summary { display: flex; flex-wrap: wrap; gap: .5rem 1.4rem; align-items: center; margin-bottom: 1rem; }
.pub-name { font-weight: 600; white-space: nowrap; }
.pub-catname { color: var(--muted); font-size: .88rem; }
.pub-act { color: var(--muted); }
.pub-note { margin-top: 1rem; max-width: 70ch; }
@media (max-width: 700px) {
  .pub-catname { display: none; }
  .pub-table thead { display: none; }
  .pub-table, .pub-table tbody, .pub-table tr, .pub-table td { display: block; width: 100%; }
  .pub-table tr { padding: .7rem .9rem; border-bottom: 1px solid var(--line); }
  .pub-table td { border: 0; padding: .15rem 0; display: flex; gap: .5rem; align-items: baseline; }
  .pub-table td::before { flex: 0 0 7.5rem; }
  .pub-table td .v { flex: 1; min-width: 0; }
  .pub-table td.pub-name { display: block; font-size: 1.05rem; padding-bottom: .35rem; }
  .pub-table td::before { content: attr(data-label); color: var(--muted); font-size: .82rem; }
  .pub-table td.pub-name::before { content: none; }
  .pub-brand h1 { font-size: 1.3rem; }
}
@media print {
  .public .filters, .pub-note + p { display: none; }
  .pub-head { background: #fff; color: var(--ink); }
  .pub-brand h1 { color: var(--ink); }
}
.disc-picker { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: .8rem; }
.disc-picker fieldset { border: 1px solid var(--line); border-radius: 6px; padding: .5rem .8rem .7rem; margin: 0; }
.disc-picker legend { font-size: .82rem; color: var(--muted); padding: 0 .3rem; }
.disc-picker .check-inline { margin: .18rem 0; font-size: .9rem; }
.disc-picker .disc-group { font-weight: 600; border-bottom: 1px dashed var(--line); padding-bottom: .3rem; margin-bottom: .3rem; }
.disc-chip { display: inline-block; background: var(--accent-soft); color: var(--accent); border-radius: 4px; padding: .05rem .45rem; margin: 0 .3rem .25rem 0; font-size: .82rem; }
.edit-link { display: inline-flex; vertical-align: 1px; color: #a9a39a; padding: 2px 3px; border-radius: 4px; margin-left: .15rem; }
.edit-link:hover { color: var(--accent); background: var(--accent-soft); text-decoration: none; }
.bulk-col { width: 2.2rem; text-align: center; padding-right: 0; }
.bulk-col input { width: auto; cursor: pointer; }
tr.selected td { background: #fdf6e7; }
.bulk-bar { position: sticky; bottom: 0; z-index: 5; display: flex; gap: .8rem; align-items: center; flex-wrap: wrap;
  background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: .6rem 1rem; margin-top: -.4rem;
  box-shadow: 0 -4px 16px rgba(0,0,0,.06); }
.bulk-bar[hidden] { display: none; }
.btn.danger-solid { background: var(--bad); border-color: var(--bad); color: #fff; }
.bulk-list { margin: .2rem 0 1rem; padding-left: 1.4rem; max-height: 22rem; overflow: auto; }
.bulk-list li { padding: .15rem 0; }
.login-wrap { min-height: 100vh; display: grid; place-items: center; }
.login { width: 360px; }

@media (max-width: 900px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  .side { position: static; height: auto; }
  .side .who { position: static; margin-top: 1rem; }
  .brand { margin-bottom: .8rem; }
  .nav { display: flex; flex-wrap: wrap; gap: .25rem; }
  .nav a { margin: 0; }
  .nav-sep { display: none; }
  .filters input, .filters select { flex: 1 1 100%; }
  .g2, .g3, .g4 { grid-template-columns: 1fr; }
  .main { padding: 1rem; }
}
@media print {
  .side, .actions, details.add, form button { display: none !important; }
  .shell { display: block; }
  body { background: #fff; }
}

/* выбор разделов при импорте карточек */
.import-parts { border: 1px solid var(--line, #ddd); border-radius: 8px; padding: .7rem .9rem .8rem; margin: 1rem 0 0; }
.import-parts legend { font-weight: 700; padding: 0 .3rem; }
.import-parts .part-option { align-items: flex-start; margin: .3rem 0; }
.import-parts .part-option input { margin-top: .2rem; }
.part-off, .part-warnings[hidden] { display: none !important; }

/* создание соревнования из справки */
.new-comp { border: 0; padding: 0; margin: 0; min-width: 0; }
.new-comp[disabled] { opacity: .45; }

/* судьи в архиве */
tr.archived > td:not(.bulk-col) { opacity: .6; }

.nowrap { white-space: nowrap; }

/* соревнование ещё не состоялось */
.b-planned { background: #e6eef8; color: #2f5d8a; }

/* реестр приказов */
.sort-link { color: inherit; text-decoration: none; }
.sort-link.on { color: var(--accent); }
.order-rows select { max-width: 100%; }
.filters select[name=org] { max-width: 22rem; }
.filters select.disc-filter { max-width: 20rem; }
.vid-only[hidden] { display: none !important; }
.filters select[name=status] { max-width: 20rem; }

/* сканы приказов */
.scan-ok { display: inline-flex; align-items: center; justify-content: center; width: 1.45rem; height: 1.45rem;
  border-radius: 50%; background: #2e8b57; color: #fff; font-weight: 700; font-size: .85rem; text-decoration: none; }
.scan-none { color: var(--muted); text-decoration: none; }
.scan-file { display: flex; gap: .7rem; align-items: center; }
td.c, th.c { text-align: center; }
.scan-replace label.btn { cursor: pointer; }

/* публичный реестр: скачивание скана приказа */
.pub-scan { white-space: nowrap; }
.pub-pdf { display: inline-block; margin-left: .35rem; padding: 0 .3rem; border-radius: 3px; font-size: .68rem;
  font-weight: 700; letter-spacing: .03em; background: var(--bad-bg); color: var(--bad); vertical-align: 1px; }
.linkbtn-plain { color: var(--accent); cursor: pointer; font-size: .85rem; margin: 0 .3rem; }
#protocols h2 .btn { margin-left: .6rem; vertical-align: middle; }
.order-rows select[name=action] { min-width: 10.5rem; }
.s3-box { border: 1px solid var(--line, #ddd); border-radius: 8px; padding: .6rem .9rem .3rem; margin: .8rem 0 0; }
.s3-box legend { font-weight: 600; padding: 0 .3rem; }
