/* Цифровое табло — общее оформление (участник и организатор) */
:root {
  --bg: #f3f1ec; --card: #ffffff; --ink: #1b1e23; --muted: #666c75; --line: #e1ddd3;
  --accent: #c2491a; --accent-ink: #ffffff; --accent-soft: #fbe9df;
  --head: #1f242b; --head-ink: #f4f2ee; --urgent: #b3261e; --urgent-soft: #fdecea;
  --ok: #1f7a4d; --shadow: 0 1px 2px rgba(20, 22, 26, .06);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #13161a; --card: #1c2026; --ink: #ecebe6; --muted: #9aa0a8; --line: #2b3139;
    --accent: #f0783c; --accent-ink: #1a1208; --accent-soft: #33221a;
    --head: #0d0f12; --head-ink: #ecebe6; --urgent: #ff8a80; --urgent-soft: #3a1c1a;
    --ok: #5fd39a; --shadow: none;
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
}
a { color: inherit; }
h1, h2, h3 { margin: 0; line-height: 1.2; }
button, input, select, textarea { font: inherit; color: inherit; }
[hidden] { display: none !important; }

/* верхняя полоса */
.topbar { background: var(--head); color: var(--head-ink); }
.topbar-in {
  max-width: 880px; margin: 0 auto; padding: 10px 16px;
  display: flex; align-items: center; gap: 12px; min-height: 48px;
}
.brand { display: flex; align-items: center; gap: 9px; text-decoration: none; font-weight: 700; letter-spacing: .02em; }
.brand-mark {
  width: 22px; height: 22px; border-radius: 4px; flex: none;
  background:
    linear-gradient(var(--accent), var(--accent)) 0 0 / 11px 11px no-repeat,
    linear-gradient(var(--accent), var(--accent)) 11px 11px / 11px 11px no-repeat,
    var(--head-ink);
}
.brand { white-space: nowrap; }
@media (max-width: 440px) { .brand .wide { display: none; } }
.topbar .spacer { flex: 1; }
.toplink { font-size: 14px; opacity: .85; text-decoration: none; white-space: nowrap; }
.toplink:hover { opacity: 1; text-decoration: underline; }
.topbtn { background: none; border: 1px solid rgba(255,255,255,.3); color: inherit; border-radius: 8px; padding: 5px 10px; font-size: 14px; cursor: pointer; }

.wrap { max-width: 880px; margin: 0 auto; padding: 16px 16px 48px; }
.section-title {
  font-size: 13px; font-weight: 700; text-transform: uppercase; letter-spacing: .07em;
  color: var(--muted); margin: 26px 0 8px;
}
.card { background: var(--card); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow); }
.pad { padding: 16px; }
.muted { color: var(--muted); }
.small { font-size: 14px; }
.empty { color: var(--muted); padding: 14px 16px; }

/* кнопки и поля */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 9px 16px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--card); cursor: pointer; text-decoration: none; font-weight: 600;
}
.btn:hover { border-color: var(--muted); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.07); }
.btn.big { min-height: 52px; font-size: 17px; width: 100%; }
.btn.small { min-height: 36px; padding: 5px 11px; font-size: 14px; font-weight: 500; }
.btn:disabled { opacity: .55; cursor: default; }
.field { display: block; margin-bottom: 14px; }
.field > span { display: block; font-size: 14px; color: var(--muted); margin-bottom: 4px; }
.input, select.input, textarea.input {
  width: 100%; min-height: 44px; padding: 9px 12px; border-radius: 10px;
  border: 1px solid var(--line); background: var(--card);
}
textarea.input { min-height: 120px; resize: vertical; }
.input:focus, .btn:focus-visible, a:focus-visible, button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.row { display: flex; gap: 10px; flex-wrap: wrap; }
.row > .grow { flex: 1 1 180px; min-width: 0; }
.error { color: var(--urgent); font-size: 14px; margin: 8px 0 0; min-height: 1.2em; }

/* главная: вход по коду */
.codebox h1 { font-size: 22px; margin-bottom: 4px; }
.codeform { display: flex; gap: 8px; margin-top: 12px; }
.codeform .input { flex: 1; min-width: 0; text-transform: uppercase; letter-spacing: .08em; font-weight: 600; }
.codeform .input::placeholder { text-transform: none; letter-spacing: 0; font-weight: 400; }

/* список гонок */
.racelist { display: grid; gap: 8px; }
.racecard {
  display: flex; align-items: center; gap: 12px; padding: 13px 16px; text-decoration: none;
  width: 100%; text-align: left; cursor: pointer;
}
.racecard:hover { border-color: var(--muted); }
.racecard .rc-main { flex: 1; min-width: 0; }
.racecard .rc-title { font-weight: 700; font-size: 17px; }
.racecard .rc-sub { color: var(--muted); font-size: 14px; }
.chev { color: var(--muted); font-size: 20px; flex: none; }
.tag {
  display: inline-block; font-size: 12px; font-weight: 700; padding: 2px 7px; border-radius: 6px;
  background: var(--accent-soft); color: var(--accent); white-space: nowrap; vertical-align: middle;
}
.tag.grey { background: var(--line); color: var(--muted); }
.tag.live { background: var(--ok); color: #fff; }

/* шапка гонки */
.racehead { padding: 14px 0 4px; }
.racehead h1 { font-size: 22px; }
.racehead .sub { color: var(--muted); font-size: 15px; margin-top: 3px; }

/* срочное */
.urgent {
  border: 1px solid var(--urgent); border-left-width: 5px; background: var(--urgent-soft);
  border-radius: 10px; padding: 11px 14px; margin-top: 10px;
}
.urgent .u-head { font-weight: 700; color: var(--urgent); font-size: 14px; text-transform: uppercase; letter-spacing: .05em; }
.urgent .u-body { white-space: pre-wrap; overflow-wrap: anywhere; margin-top: 2px; }
.urgent .u-time { color: var(--muted); font-size: 13px; margin-top: 4px; }

/* строки документов */
.list { overflow: hidden; }
.doc {
  display: flex; align-items: center; gap: 11px; padding: 10px 14px; text-decoration: none;
  border-top: 1px solid var(--line); min-height: 54px;
}
.list > .doc:first-child, .list > .folder:first-child > .folder-head { border-top: 0; }
a.doc:hover { background: var(--bg); }
.doc .d-main { flex: 1; min-width: 0; }
.doc .d-title { font-weight: 400; overflow-wrap: anywhere; }
.adm .doc .d-title { font-weight: 600; }
/* ещё не открывали на этом устройстве */
.doc.unread .d-title { font-weight: 700; }
.doc.unread .d-title::before {
  content: ""; display: inline-block; width: 8px; height: 8px; border-radius: 50%;
  background: var(--accent); margin-right: 7px; vertical-align: middle; position: relative; top: -1px;
}
.newcount {
  flex: none; font-size: 12px; font-weight: 700; padding: 2px 7px; border-radius: 999px;
  background: var(--accent); color: var(--accent-ink); white-space: nowrap;
}
.sharebox { margin-top: 10px; }
.bigcode { font-size: 22px; letter-spacing: .1em; }
.filebox { padding: 12px 14px; border: 1px dashed var(--muted); border-radius: 10px; margin-bottom: 14px; }
.multirow { margin-bottom: 10px; }
.doc .d-time { color: var(--muted); font-size: 13px; font-variant-numeric: tabular-nums; }
.badge {
  flex: none; width: 54px; text-align: center; font-size: 10px; font-weight: 800; letter-spacing: .02em;
  padding: 5px 0; border-radius: 6px; background: var(--line); color: var(--muted);
}
.badge.pdf { background: #fbe3e0; color: #a3261c; }
.badge.image { background: #e0eefb; color: #1c5fa3; }
.badge.text { background: #e6f3e6; color: #2a6b2a; }
.badge.link { background: #efe6fa; color: #5b34a0; }
@media (prefers-color-scheme: dark) {
  .badge.pdf { background: #4a211d; color: #ffb4ab; }
  .badge.image { background: #1b3350; color: #a8cdf5; }
  .badge.text { background: #1e3a22; color: #a5d8a8; }
  .badge.link { background: #33254d; color: #d0b8f5; }
}

/* папки */
.folder-head {
  display: flex; align-items: center; gap: 11px; width: 100%; padding: 12px 14px; min-height: 54px;
  background: none; border: 0; border-top: 1px solid var(--line); text-align: left; cursor: pointer;
}
button.folder-head:hover { background: var(--bg); }
.folder-ico { flex: none; width: 54px; text-align: center; font-size: 21px; line-height: 1; }
.folder-title { flex: 1; min-width: 0; font-weight: 700; }
.folder-count { color: var(--muted); font-size: 14px; }
.folder-arrow { color: var(--muted); transition: transform .15s; flex: none; }
.folder.open > .folder-head .folder-arrow { transform: rotate(90deg); }
.folder-body { display: none; background: color-mix(in srgb, var(--bg) 55%, var(--card)); }
.folder.open > .folder-body { display: block; }
.folder-body .folder-head, .folder-body .doc { padding-left: 28px; }
.folder-body .folder-body .doc { padding-left: 42px; }

/* страница документа */
.back { display: inline-flex; align-items: center; gap: 6px; text-decoration: none; color: var(--muted); padding: 10px 0; font-size: 15px; }
.back:hover { color: var(--ink); }
.dochead h1 { font-size: 21px; overflow-wrap: anywhere; }
.dochead .meta { color: var(--muted); font-size: 14px; margin-top: 5px; }
.verbox { margin-top: 12px; padding: 10px 14px; border-radius: 10px; background: var(--accent-soft); font-size: 14px; }
.verbox a { color: var(--accent); font-weight: 600; }
.docbody { margin-top: 14px; }
.textdoc { white-space: pre-wrap; overflow-wrap: anywhere; font-size: 17px; }
.docimg { max-width: 100%; height: auto; border-radius: 8px; display: block; }
.pdfframe { width: 100%; height: 78vh; border: 1px solid var(--line); border-radius: 10px; margin-top: 12px; background: #fff; }
@media (max-width: 700px) { .pdfframe { display: none; } }
/* PDF на странице (телефон) */
.pdfview { margin: 12px -8px 0; }
.pdfpage { background: #fff; border: 1px solid var(--line); margin-bottom: 8px; overflow: hidden; }
.pdfpage canvas { display: block; width: 100%; height: auto; }
.pdfchip {
  position: sticky; top: 8px; z-index: 2; width: max-content; margin: 0 auto 8px; padding: 4px 12px;
  border-radius: 999px; background: var(--ink); color: var(--bg); font-size: 13px; font-weight: 600; opacity: .88;
}
.actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* кабинет */
.codechip {
  display: inline-flex; align-items: center; gap: 10px; padding: 6px 6px 6px 12px;
  border: 1px dashed var(--muted); border-radius: 10px; margin-top: 10px;
}
.codechip b { font-size: 19px; letter-spacing: .1em; }
.kinds { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
@media (max-width: 420px) { .kinds { grid-template-columns: repeat(2, 1fr); } }
.kind {
  min-height: 62px; padding: 8px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--card); font-weight: 600; cursor: pointer; line-height: 1.2;
}
.kind:hover { border-color: var(--muted); }
.kind.on { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.kind.urgent-kind:not(.on) { color: var(--urgent); border-color: var(--urgent); }
.step { font-size: 15px; font-weight: 700; margin: 20px 0 8px; }
.step i { font-style: normal; display: inline-block; width: 24px; height: 24px; line-height: 24px; text-align: center; border-radius: 50%; background: var(--ink); color: var(--bg); font-size: 13px; margin-right: 6px; }
.modes { display: inline-flex; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; margin-bottom: 12px; }
.modes button { border: 0; background: var(--card); padding: 9px 16px; min-height: 42px; cursor: pointer; }
.modes button + button { border-left: 1px solid var(--line); }
.modes button.on { background: var(--ink); color: var(--bg); }
.tools { display: flex; gap: 4px; flex: none; align-items: center; }
.iconbtn {
  width: 38px; height: 38px; border-radius: 8px; border: 1px solid var(--line); background: var(--card);
  cursor: pointer; font-size: 16px; line-height: 1; padding: 0;
}
.iconbtn:hover { border-color: var(--muted); }
.iconbtn:disabled { opacity: .3; cursor: default; }
.editpart { padding-bottom: 14px; margin-bottom: 14px; border-bottom: 1px dashed var(--muted); }
.btn.danger { color: var(--urgent); border-color: var(--urgent); }
.d-title.gone { text-decoration: line-through; color: var(--muted); }
.replacebox { padding: 12px 14px 14px; border-top: 1px dashed var(--line); background: var(--accent-soft); }
.adm .folder-head { cursor: default; }
.adm .sub .folder-head, .adm .sub .doc { padding-left: 28px; }
@media (max-width: 520px) {
  .adm .doc { flex-wrap: wrap; }
  .adm .doc .tools { width: 100%; justify-content: flex-end; }
}
.notice { padding: 11px 14px; border-radius: 10px; background: var(--line); margin-top: 12px; font-size: 15px; }

.toast {
  position: fixed; left: 50%; bottom: 22px; transform: translateX(-50%); z-index: 10;
  background: var(--ink); color: var(--bg); padding: 11px 18px; border-radius: 10px;
  font-weight: 600; max-width: calc(100vw - 32px); box-shadow: 0 6px 20px rgba(0,0,0,.25);
}
.editmenu { display: grid; gap: 8px; }
.editmenu .btn { flex-direction: column; align-items: flex-start; gap: 0; text-align: left; min-height: 52px; }
.editmenu .btn span { font-weight: 400; font-size: 13px; color: var(--muted); }

/* QR-код */
.qrbox { margin: 8px 0 10px; }
.qr { width: 220px; max-width: 100%; height: auto; display: block; border-radius: 8px; border: 1px solid var(--line); }

/* люди и должности */
.tempbox { border-color: var(--accent); background: var(--accent-soft); margin-bottom: 8px; }
.rolesel { width: auto; min-height: 36px; padding: 4px 8px; font-size: 14px; }
.rolelist { margin: 8px 0 0; padding-left: 18px; }
.rolelist li { margin-bottom: 4px; }

/* «Для кого» */
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  min-height: 40px; padding: 6px 14px; border-radius: 999px; border: 1px solid var(--line);
  background: var(--card); cursor: pointer; font-weight: 600;
}
.chip.on { background: var(--ink); border-color: var(--ink); color: var(--bg); }
.tag.aud { background: var(--line); color: var(--ink); }

/* люди и статистика */
.person .jobs { margin-top: 4px; }
.person .jobs a { color: var(--accent); }
.tiles { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
@media (max-width: 560px) { .tiles { grid-template-columns: repeat(2, 1fr); } }
.tile { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; }
.tile b { display: block; font-size: 30px; line-height: 1.1; font-variant-numeric: tabular-nums; }
.tile span { color: var(--muted); font-size: 13px; }
.tile:first-child { border-color: var(--ok); }
.tile:first-child b { color: var(--ok); }
.statnum { flex: none; text-align: right; font-size: 14px; color: var(--muted); font-variant-numeric: tabular-nums; }
.statnum b { color: var(--ink); font-size: 17px; }
.bar { height: 5px; border-radius: 3px; background: var(--line); margin-top: 6px; overflow: hidden; }
.bar i { display: block; height: 100%; background: var(--ok); }
.tag.few { background: var(--urgent-soft); color: var(--urgent); }
@media (max-width: 520px) {
  .adm .doc .statnum { width: 100%; text-align: left; }
}

/* секретариат: экипажи */
.startno {
  flex: none; width: 54px; text-align: center; font-weight: 800; font-size: 18px;
  font-variant-numeric: tabular-nums; align-self: flex-start; padding-top: 2px;
}
.entry.dead .d-title, .entry.dead .d-main .small { text-decoration: line-through; color: var(--muted); }
.entry .tag { margin-top: 4px; }
.personbox { border: 1px solid var(--line); border-radius: 10px; padding: 12px 12px 0; margin-bottom: 10px; }
.personbox b { display: block; margin-bottom: 8px; }
.docreq { border-top: 1px solid var(--line); padding: 10px 0; }
.docstate { width: auto; min-width: 150px; }
.check { display: flex; align-items: center; gap: 8px; min-height: 40px; cursor: pointer; }
.check input { width: 20px; height: 20px; }
