:root {
  --ink: #12161f;
  --ink-2: #3b4352;
  --muted: #6b7383;
  --line: #e2e5ea;
  --bg: #f5f6f8;
  --card: #ffffff;
  --accent: #ff5a1f;
  --accent-ink: #ffffff;
  --accent-soft: #fff0e9;
  --ok: #1f8a4c;
  --ok-soft: #e7f5ec;
  --warn: #b26a00;
  --warn-soft: #fff5e0;
  --err: #c62828;
  --err-soft: #fdecec;
  --info: #1d5fbf;
  --info-soft: #e8f0fc;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(18, 22, 31, .06), 0 4px 16px rgba(18, 22, 31, .06);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --ink: #eef0f4; --ink-2: #c7ccd6; --muted: #949cab; --line: #2a303b; --bg: #0f1218; --card: #171b23;
    --accent-soft: #3a1d10; --ok-soft: #12301f; --warn-soft: #33260c; --err-soft: #3a1515; --info-soft: #132540;
    --shadow: 0 1px 2px rgba(0,0,0,.3), 0 4px 16px rgba(0,0,0,.25);
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  min-height: 100vh; display: flex; flex-direction: column;
}
a { color: inherit; }
h1 { font-size: clamp(1.5rem, 4vw, 2rem); line-height: 1.2; margin: .2em 0 .4em; letter-spacing: -.01em; }
h2 { font-size: 1.2rem; margin: 1.2em 0 .6em; }
.wrap { width: 100%; max-width: 1180px; margin: 0 auto; padding: 0 16px; }
main.wrap { flex: 1; padding-top: 20px; padding-bottom: 40px; }
.muted { color: var(--muted); }
.small { font-size: .86rem; }
.nowrap { white-space: nowrap; }
.right { text-align: right; }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.inline { display: inline; }
.note { color: var(--muted); font-size: .9rem; }
.crumb { margin: 0 0 8px; font-size: .92rem; }
.crumb a { color: var(--muted); text-decoration: none; }
.crumb a:hover { color: var(--ink); }

/* header */
.top { background: var(--ink); color: #fff; }
@media (prefers-color-scheme: dark) { .top { background: #07090d; border-bottom: 1px solid var(--line); } }
.top-in { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 58px; flex-wrap: wrap; }
.brand { font-weight: 800; text-decoration: none; display: flex; align-items: center; gap: 10px; font-size: 1.05rem; }
.brand-bib { background: #fff; color: var(--accent); border-radius: 6px; padding: 2px 7px; font-size: .85rem; letter-spacing: .02em; }
.top nav { display: flex; gap: 16px; align-items: center; flex-wrap: wrap; font-size: .93rem; }
.top nav a { text-decoration: none; opacity: .9; }
.top nav a:hover { opacity: 1; text-decoration: underline; }
.top .muted { color: #b8bfcc; }
.linklike { background: none; border: 0; padding: 0; color: inherit; font: inherit; cursor: pointer; opacity: .9; }
.linklike:hover { text-decoration: underline; }

.foot { display: flex; justify-content: space-between; gap: 8px; flex-wrap: wrap; padding: 18px 16px 28px; color: var(--muted); font-size: .85rem; border-top: 1px solid var(--line); }

/* buttons & forms */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 9px 16px; border-radius: 10px; border: 1px solid var(--line); background: var(--card);
  color: var(--ink); font: inherit; font-weight: 600; text-decoration: none; cursor: pointer; white-space: nowrap;
}
.btn:hover { border-color: var(--ink-2); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.06); }
.btn.danger { background: var(--err); border-color: var(--err); color: #fff; }
.btn.ghost { background: transparent; }
.btn.ghost.danger { color: var(--err); border-color: transparent; }
.btn.small { padding: 5px 10px; font-size: .86rem; border-radius: 8px; }
.btn.big { padding: 14px 22px; font-size: 1.05rem; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
kbd { font: 600 .72rem ui-monospace, monospace; border: 1px solid currentColor; border-radius: 4px; padding: 0 4px; opacity: .7; }

label { display: block; margin: 0 0 14px; font-weight: 600; font-size: .92rem; }
input, select, textarea {
  display: block; width: 100%; margin-top: 5px; padding: 10px 12px; font: inherit; font-weight: 400;
  border: 1px solid var(--line); border-radius: 10px; background: var(--card); color: var(--ink);
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: 1px; border-color: transparent; }
label.check { display: flex; gap: 10px; align-items: flex-start; font-weight: 400; }
label.check input { width: auto; margin-top: 4px; }
.row { display: flex; gap: 14px; flex-wrap: wrap; }
.row > label { flex: 1 1 180px; }
.row .grow, .grow { flex: 3 1 260px; }
.row.center { align-items: center; }
.small-input { display: inline-block; width: 170px; padding: 5px 8px; margin: 0; font-size: .86rem; }

.panel { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; margin: 0 0 20px; box-shadow: var(--shadow); }
.panel > h1:first-child, .panel > h2:first-child { margin-top: 0; }
.panel.narrow { max-width: 560px; margin-left: auto; margin-right: auto; }
.prose { max-width: 820px; margin: 0 auto; }
.prose h2 { margin-top: 1.6em; }

.flash { padding: 11px 14px; border-radius: 10px; margin: 0 0 14px; background: var(--ok-soft); color: var(--ok); font-weight: 600; }
.flash.err { background: var(--err-soft); color: var(--err); }
.flash.warn { background: var(--warn-soft); color: var(--warn); }
.flash.block { display: block; text-decoration: none; }
.empty { text-align: center; padding: 40px 16px; color: var(--muted); background: var(--card); border: 1px dashed var(--line); border-radius: var(--radius); }

/* home */
.hero { padding: 18px 0 8px; }
.hero h1 { font-size: clamp(1.8rem, 5vw, 2.6rem); font-weight: 800; }
.hero p { color: var(--ink-2); font-size: 1.08rem; max-width: 640px; margin-top: 0; }
.comp-list { list-style: none; padding: 0; margin: 20px 0; display: grid; gap: 12px; }
.comp-card { display: flex; align-items: center; gap: 16px; padding: 14px 16px; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); text-decoration: none; box-shadow: var(--shadow); transition: transform .12s, border-color .12s; }
.comp-card:hover { border-color: var(--accent); transform: translateY(-1px); }
.comp-date { flex: 0 0 64px; text-align: center; border-radius: 10px; background: var(--accent-soft); color: var(--accent); padding: 6px 4px; line-height: 1.1; }
.comp-date .d { display: block; font-size: 1.6rem; font-weight: 800; }
.comp-date .m { display: block; font-size: .72rem; font-weight: 700; text-transform: uppercase; letter-spacing: .03em; }
.comp-body { flex: 1; min-width: 0; }
.comp-body h2 { margin: 0; font-size: 1.1rem; }
.comp-body p { margin: 2px 0 0; }
.comp-count { text-align: right; color: var(--muted); font-size: .8rem; line-height: 1.1; }
.comp-count strong { display: block; font-size: 1.3rem; color: var(--ink); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { font-size: .78rem; font-weight: 600; padding: 2px 9px; border-radius: 99px; background: var(--bg); border: 1px solid var(--line); color: var(--ink-2); }

/* competition page + bib search */
.comp-head .desc { color: var(--ink-2); max-width: 760px; }
.bib-search { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 14px; margin: 18px 0 24px; padding: 20px; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.bib-label { flex-basis: 100%; margin: 0; font-size: .82rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.bib-card { position: relative; flex: 1 1 220px; max-width: 320px; background: #fff; border: 2px solid var(--ink); border-radius: 12px; padding: 8px 22px; }
.bib-card::before { content: ""; position: absolute; left: 0; right: 0; top: 0; height: 12px; background: var(--accent); border-radius: 9px 9px 0 0; }
.bib-card input { border: 0; background: transparent; color: #12161f; text-align: center; font: 800 2.6rem/1.1 system-ui, sans-serif; letter-spacing: .04em; padding: 12px 0 4px; margin: 0; font-variant-numeric: tabular-nums; }
.bib-card input:focus { outline: none; }
.bib-card input::placeholder { color: #d4d8de; }
.pin { position: absolute; width: 8px; height: 8px; border-radius: 50%; background: #c8ccd3; box-shadow: inset 0 0 0 2px #9aa0aa; }
.pin.tl { top: 18px; left: 7px; } .pin.tr { top: 18px; right: 7px; } .pin.bl { bottom: 8px; left: 7px; } .pin.br { bottom: 8px; right: 7px; }
.bib-search select { width: auto; flex: 0 1 220px; margin: 0; }
.results-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; }
.bibtag { background: var(--ink); color: #fff; border-radius: 6px; padding: 0 8px; }

/* grids */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 12px; margin: 14px 0; }
.ph { margin: 0; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; position: relative; display: flex; flex-direction: column; }
.ph img { display: block; width: 100%; aspect-ratio: 3 / 2; object-fit: cover; background: var(--line); }
.ph figcaption { padding: 8px 10px; display: flex; flex-direction: column; gap: 4px; font-size: .86rem; }
.ph .acts { display: flex; justify-content: space-between; gap: 8px; }
.ph .acts a { font-weight: 600; }
.danger-link { color: var(--err) !important; }
.ph.unsorted { border-color: var(--warn); }
.ph.error { border-color: var(--err); }
.ph.hidden-ph img { opacity: .4; }
.ph-placeholder { aspect-ratio: 3 / 2; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; padding: 10px; color: var(--muted); background: var(--bg); overflow: hidden; word-break: break-all; }
.ph .sel { position: absolute; top: 6px; left: 6px; margin: 0; z-index: 2; background: rgba(255,255,255,.9); border-radius: 6px; padding: 3px 5px; }
.ph .sel input { margin: 0; width: 18px; height: 18px; }
.staff-grid { grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); }
.bibs-input { margin: 0; padding: 6px 8px; font-weight: 700; }
.bibs-input.saved { outline: 2px solid var(--ok); }
.bibs-input.failed { outline: 2px solid var(--err); }
.bulkbar { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; position: sticky; top: 0; z-index: 5; background: var(--bg); padding: 8px 0; }
.bulkbar label { margin: 0; }

/* staff */
.page-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 10px; }
.page-head p { margin: 0; }
.table { width: 100%; border-collapse: collapse; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; margin-bottom: 14px; }
.table th, .table td { padding: 10px 12px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
.table th { font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); background: var(--bg); }
.table th.num, .table td.num { text-align: right; }
.table tr:last-child td { border-bottom: 0; }
.table tr.off td { opacity: .55; }
.badge { display: inline-block; padding: 1px 8px; border-radius: 99px; font-size: .8rem; font-weight: 700; text-decoration: none; }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.info { background: var(--info-soft); color: var(--info); }
.badge.err { background: var(--err-soft); color: var(--err); }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin: 10px 0 14px; }
.stat { display: block; padding: 14px 16px; border-radius: var(--radius); background: var(--ok-soft); color: var(--ok); text-decoration: none; }
.stat strong { display: block; font-size: 1.8rem; line-height: 1.1; font-variant-numeric: tabular-nums; }
.stat.warn { background: var(--warn-soft); color: var(--warn); }
.stat.info { background: var(--info-soft); color: var(--info); }
.stat.err { background: var(--err-soft); color: var(--err); }
.actions-row { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 20px; }
.danger-zone { border-color: var(--err); }
.tabs { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; border-bottom: 1px solid var(--line); margin-bottom: 10px; }
.tabs a { padding: 8px 12px; text-decoration: none; color: var(--muted); border-bottom: 2px solid transparent; font-weight: 600; font-size: .92rem; }
.tabs a.on { color: var(--ink); border-color: var(--accent); }
.tab-search { margin-left: auto; }
.tab-search input { margin: 0 0 4px; padding: 6px 10px; width: 170px; }
.pager { display: flex; flex-wrap: wrap; gap: 6px; }
.pager a { padding: 4px 10px; border: 1px solid var(--line); border-radius: 8px; text-decoration: none; background: var(--card); }
.pager a.on { background: var(--ink); color: var(--bg); }

.courses { border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px 14px; margin: 0 0 18px; }
.courses legend { font-weight: 700; padding: 0 6px; }
.course-head, .course-row { display: grid; grid-template-columns: 2fr 1fr 1fr 1fr 40px; gap: 8px; align-items: center; }
.course-head { font-size: .78rem; color: var(--muted); font-weight: 600; margin-bottom: 4px; }
.course-row { margin-bottom: 8px; }
.course-row input { margin: 0; }
@media (max-width: 640px) {
  .course-head { display: none; }
  .course-row { grid-template-columns: 1fr 1fr; padding: 10px; border: 1px solid var(--line); border-radius: 10px; }
  .course-row input[name=course_name] { grid-column: 1 / -1; }
  .table { display: block; overflow-x: auto; }
}

/* upload */
.drop { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 36px 16px; border: 2px dashed var(--line); border-radius: var(--radius); text-align: center; cursor: pointer; font-weight: 400; background: var(--bg); }
.drop.over, .drop:hover { border-color: var(--accent); background: var(--accent-soft); }
.drop input { display: none; }
.progress { margin: 14px 0; }
.bar { height: 12px; background: var(--line); border-radius: 99px; overflow: hidden; }
.bar span { display: block; height: 100%; width: 0; background: var(--accent); transition: width .2s; }
.errors { color: var(--err); max-height: 180px; overflow: auto; }

/* tri */
.tri { display: grid; grid-template-columns: 1fr 320px; gap: 18px; align-items: start; }
.tri-img { background: #000; border-radius: var(--radius); overflow: hidden; cursor: zoom-in; position: relative; }
.tri-img img { display: block; width: 100%; max-height: 78vh; object-fit: contain; transition: transform .15s; transform-origin: center; }
.tri-img.zoom { cursor: zoom-out; }
.tri-img.zoom img { transform: scale(2.4); }
.tri-form { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; display: flex; flex-direction: column; gap: 10px; position: sticky; top: 12px; }
.tri-input { font-size: 2rem; font-weight: 800; text-align: center; margin: 0; letter-spacing: .03em; }
@media (max-width: 860px) { .tri { grid-template-columns: 1fr; } .tri-form { position: static; } }

/* removal */
.retrait-img { max-width: 220px; border-radius: 10px; display: block; margin: 0 0 16px; }
.req-list { display: grid; gap: 12px; }
.req { display: flex; gap: 14px; align-items: flex-start; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; flex-wrap: wrap; }
.req img { width: 160px; border-radius: 8px; display: block; }
.req p { margin: 0 0 4px; }
.req-acts { display: flex; flex-direction: column; gap: 8px; }

/* lightbox */
.lightbox { position: fixed; inset: 0; background: rgba(5, 7, 10, .92); z-index: 100; display: flex; align-items: center; justify-content: center; flex-direction: column; gap: 14px; padding: 16px; }
.lightbox[hidden] { display: none; }
.lightbox img { max-width: 100%; max-height: calc(100vh - 110px); border-radius: 6px; }
.lb-close { position: absolute; top: 8px; right: 14px; background: none; border: 0; color: #fff; font-size: 2.4rem; cursor: pointer; line-height: 1; }
.ph.review { border-color: var(--info); box-shadow: 0 0 0 2px var(--info-soft); }
