:root {
  --bg: #0e1116; --panel: #161b22; --panel2: #1c232d; --line: #2a323e; --text: #e6e9ef; --muted: #8b96a6;
  --accent: #5aa9ff; --accent-bg: #16314f; --good: #3ecf8e; --warn: #f2b84b; --bad: #ff6b6b; --radius: 10px;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.45 system-ui, "Segoe UI", Roboto, sans-serif; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 22px; margin: 0 0 4px; }
h2 { font-size: 17px; margin: 24px 0 10px; }
h3 { font-size: 15px; margin: 0 0 8px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.nowrap { white-space: nowrap; }
.right { text-align: right; }
.good { color: var(--good); } .bad { color: var(--bad); } .warn { color: var(--warn); }

/* оболочка */
.top { position: sticky; top: 0; z-index: 20; background: rgba(14,17,22,.94); backdrop-filter: blur(8px); border-bottom: 1px solid var(--line); }
.top-in { max-width: 1280px; margin: 0 auto; padding: 0 16px; display: flex; align-items: center; gap: 12px; }
.brand { font-weight: 700; letter-spacing: .3px; padding: 12px 0; color: var(--text); white-space: nowrap; }
.brand b { color: var(--accent); }
nav.main { display: flex; gap: 2px; overflow-x: auto; scrollbar-width: none; flex: 1; }
nav.main::-webkit-scrollbar { display: none; }
nav.main a { color: var(--muted); padding: 13px 11px; white-space: nowrap; border-bottom: 2px solid transparent; }
nav.main a:hover { color: var(--text); text-decoration: none; }
nav.main a.on { color: var(--text); border-color: var(--accent); }
.badge { background: var(--warn); color: #1a1405; border-radius: 9px; font-size: 11px; padding: 1px 6px; margin-left: 4px; font-weight: 700; }
.who { color: var(--muted); font-size: 13px; white-space: nowrap; }
main { max-width: 1280px; margin: 0 auto; padding: 18px 16px 60px; }
.fresh { display: flex; flex-wrap: wrap; gap: 6px 14px; color: var(--muted); font-size: 13px; margin-bottom: 14px; }
.alert { border: 1px solid var(--warn); background: #2a2210; color: #f5d98a; padding: 10px 14px; border-radius: var(--radius); margin: 0 0 12px; }
.alert.bad { border-color: var(--bad); background: #2b1517; color: #ffb4b4; }

/* блоки */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; }
.grid { display: grid; gap: 14px; }
.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)); }
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; margin-bottom: 8px; }
.tile { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 14px; display: block; color: var(--text); }
a.tile:hover { border-color: var(--accent); text-decoration: none; }
.tile .n { font-size: 24px; font-weight: 700; }
.tile .l { color: var(--muted); font-size: 13px; }
.row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.between { justify-content: space-between; }
.sp { flex: 1; }

/* таблицы */
.tablewrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 7px 10px; text-align: left; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { color: var(--muted); font-weight: 600; font-size: 13px; white-space: nowrap; background: var(--panel2); position: sticky; top: 0; }
th a { color: var(--muted); } th a:hover { color: var(--text); text-decoration: none; }
th a.on { color: var(--text); }
tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: #1a212b; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
td.dim { color: var(--muted); }

/* аватарки и ники */
.av { width: 36px; height: 36px; border-radius: 7px; object-fit: cover; background: var(--panel2); flex: none; }
.av.s { width: 28px; height: 28px; border-radius: 6px; }
.av.l { width: 96px; height: 98px; border-radius: 12px; }
.av.m { width: 64px; height: 66px; border-radius: 10px; }
.nickimg { height: 22px; max-width: 160px; object-fit: contain; border-radius: 4px; background: #b9c6d6; image-rendering: auto; }
.nickimg.m { height: 30px; max-width: 220px; }
.person { display: flex; gap: 9px; align-items: center; min-width: 0; }
.person .t { min-width: 0; }
.person .nm { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 260px; display: block; }

/* метки, статусы */
.chip { display: inline-block; font-size: 12px; padding: 1px 8px; border-radius: 10px; background: var(--panel2); border: 1px solid var(--line); color: var(--muted); white-space: nowrap; }
.chip.good { color: var(--good); border-color: #1d5c44; } .chip.bad { color: var(--bad); border-color: #6b2a2a; }
.chip.warn { color: var(--warn); border-color: #6b5420; } .chip.acc { color: var(--accent); border-color: #234b78; }
.tier { display: inline-block; width: 22px; text-align: center; font-weight: 700; border-radius: 6px; background: var(--panel2); }
.tier-A { color: var(--good); } .tier-B { color: var(--warn); } .tier-C { color: var(--bad); }
.delta.up { color: var(--good); } .delta.down { color: var(--bad); } .delta.zero { color: var(--muted); }
.labels { display: flex; flex-wrap: wrap; gap: 4px; }

/* формы */
input, select, textarea, button { font: inherit; color: var(--text); }
input, select, textarea { background: var(--panel2); border: 1px solid var(--line); border-radius: 8px; padding: 7px 10px; min-width: 0; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent-bg); border-color: var(--accent); }
textarea { width: 100%; min-height: 64px; resize: vertical; }
button, .btn { background: var(--panel2); border: 1px solid var(--line); border-radius: 8px; padding: 7px 12px; cursor: pointer; display: inline-block; color: var(--text); }
button:hover, .btn:hover { border-color: var(--accent); text-decoration: none; }
button.primary, .btn.primary { background: var(--accent); border-color: var(--accent); color: #07121f; font-weight: 600; }
button.sm, .btn.sm { padding: 3px 9px; font-size: 13px; }
button:disabled { opacity: .5; cursor: default; }
.filters { display: flex; flex-wrap: wrap; gap: 8px; align-items: end; margin-bottom: 12px; }
.filters label { display: flex; flex-direction: column; gap: 3px; font-size: 12px; color: var(--muted); }
.filters input[type=text], .filters input:not([type]) { width: 130px; }
.filters .w1 { width: 84px !important; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.seg a, .seg span { padding: 6px 12px; color: var(--muted); border-right: 1px solid var(--line); background: var(--panel); }
.seg a:last-child { border-right: 0; }
.seg a.on { background: var(--accent-bg); color: var(--text); }
.seg a:hover { text-decoration: none; color: var(--text); }
.pager { display: flex; gap: 6px; align-items: center; margin: 12px 0; flex-wrap: wrap; }

/* графики */
.chart { position: relative; height: 220px; }
.chart svg { width: 100%; height: 100%; display: block; }
.chart .tip { position: absolute; pointer-events: none; background: #0b0e13; border: 1px solid var(--line); border-radius: 8px; padding: 4px 8px; font-size: 12px; white-space: nowrap; display: none; z-index: 5; }
.legend { display: flex; gap: 12px; font-size: 12px; color: var(--muted); margin-top: 4px; }
.legend i { display: inline-block; width: 10px; height: 3px; margin-right: 5px; vertical-align: middle; border-radius: 2px; }

/* находки */
.finding { padding: 11px 14px; border-bottom: 1px solid var(--line); display: flex; gap: 10px; }
.finding:last-child { border-bottom: 0; }
.finding .k { color: var(--muted); width: 22px; flex: none; text-align: right; }
.finding .links { margin-top: 4px; display: flex; gap: 6px; flex-wrap: wrap; }

/* доска вербовки */
.board { display: grid; grid-template-columns: repeat(7, minmax(220px, 1fr)); gap: 10px; overflow-x: auto; padding-bottom: 8px; align-items: start; }
.col { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); min-height: 120px; }
.col.over { border-color: var(--accent); background: #131d2a; }
.col h3 { padding: 10px 12px; margin: 0; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; background: var(--panel); border-radius: var(--radius) var(--radius) 0 0; }
.col .cards { padding: 8px; display: flex; flex-direction: column; gap: 8px; }
.pc { background: var(--panel2); border: 1px solid var(--line); border-radius: 9px; padding: 9px 10px; cursor: grab; }
.pc.drag { opacity: .4; }
.pc .nm { font-weight: 600; }
.pc .meta { font-size: 12px; color: var(--muted); margin-top: 3px; }
.pc .st { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 8px; }
.pc .st button { padding: 1px 7px; font-size: 12px; border-radius: 7px; }
.pc .st button.cur { background: var(--accent-bg); border-color: var(--accent); }
.pc .clamp { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.more { text-align: center; padding: 8px; font-size: 13px; }

/* пары склеек */
.pair { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin: 10px 0; }
.side { background: var(--panel2); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; }
.side .imgs { display: flex; gap: 12px; align-items: center; margin-bottom: 8px; flex-wrap: wrap; }

.timeline { margin: 0; padding: 0; list-style: none; }
.timeline li { padding: 7px 0 7px 14px; border-left: 2px solid var(--line); margin-left: 4px; position: relative; }
.timeline li::before { content: ""; position: absolute; left: -5px; top: 13px; width: 8px; height: 8px; border-radius: 50%; background: var(--accent); }
.timeline li.note::before { background: var(--warn); }

dl.kv { display: grid; grid-template-columns: max-content 1fr; gap: 4px 14px; margin: 0; }
dl.kv dt { color: var(--muted); } dl.kv dd { margin: 0; }
.toast { position: fixed; left: 50%; bottom: 22px; transform: translateX(-50%); background: #0b0e13; border: 1px solid var(--line); border-radius: 10px; padding: 9px 16px; z-index: 50; display: none; max-width: 90vw; }
.toast.bad { border-color: var(--bad); } .toast.show { display: block; }
details summary { cursor: pointer; color: var(--muted); }
.empty { padding: 28px; text-align: center; color: var(--muted); }
.menu { position: relative; display: inline-block; }
.menu .pop { display: none; position: absolute; right: 0; top: 100%; z-index: 15; background: var(--panel); border: 1px solid var(--line); border-radius: 9px; padding: 6px; min-width: 190px; box-shadow: 0 8px 24px #0008; }
.menu.open .pop { display: block; }
.menu .pop button { display: block; width: 100%; text-align: left; border: 0; background: none; }
.menu .pop button:hover { background: var(--panel2); }

@media (max-width: 900px) {
  .g4, .g3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .board { grid-template-columns: repeat(7, 240px); }
}
@media (max-width: 640px) {
  body { font-size: 14px; }
  main { padding: 12px 12px 70px; }
  .g2, .g3, .g4, .pair { grid-template-columns: 1fr; }
  .who { display: none; }
  .top-in { padding: 0 8px; gap: 6px; }
  .brand span { display: none; }
  th, td { padding: 6px 8px; }
  .person .nm { max-width: 150px; }
}
.pc .chip { max-width: 100%; overflow: hidden; text-overflow: ellipsis; }

/* ---------- вход, админка (TASK_online) ---------- */
body.auth { display: grid; place-items: center; min-height: 100vh; padding: 20px; }
.login { width: 100%; max-width: 380px; }
.login h1 b { color: var(--accent); }
.login label, .fld { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); margin-bottom: 12px; }
.login input, .fld input, .fld select, .fld textarea { font-size: 16px; color: var(--text); }
.logout { margin-left: 4px; }
.subnav { display: flex; gap: 2px; overflow-x: auto; border-bottom: 1px solid var(--line); margin-bottom: 16px; scrollbar-width: none; }
.subnav a { padding: 9px 12px; color: var(--muted); white-space: nowrap; border-bottom: 2px solid transparent; }
.subnav a.on { color: var(--text); border-color: var(--accent); }
.subnav a:hover { text-decoration: none; color: var(--text); }
.subnav .dl { margin-left: auto; }
.stack > * + * { margin-top: 8px; }
.cmds { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 12px; margin-bottom: 8px; }
.runopts { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 10px; }
.runopts label { display: flex; flex-direction: column; gap: 3px; }
.runchecks { display: flex; flex-wrap: wrap; gap: 6px 18px; margin-top: 8px; }
.runchecks label { display: inline-flex; align-items: center; gap: 6px; }
.runchecks input { width: auto; }
.cmd { display: flex; flex-direction: column; gap: 8px; }
.cmd h3 { margin: 0; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.cmd p { margin: 0; flex: 1; }
.cmd label { display: flex; flex-direction: column; gap: 3px; }
.bar { height: 10px; background: var(--panel2); border-radius: 5px; overflow: hidden; margin-top: 8px; }
.bar i { display: block; height: 100%; background: var(--accent); transition: width .4s; }
pre.log, pre.wrap { background: #0b0e13; border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 12px; font: 12px/1.45 ui-monospace, Consolas, monospace;
  white-space: pre-wrap; word-break: break-word; max-height: 360px; overflow: auto; margin: 0; }
pre.wrap { max-height: none; }
.doc { overflow-x: auto; }
.doc h2, .doc h3, .doc h4 { margin: 18px 0 6px; } .doc h2:first-child { margin-top: 0; }
.doc p { margin: 4px 0; } .doc ul { margin: 4px 0; padding-left: 20px; }
.flds { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 4px 16px; }
.fld.bad-field input { border-color: var(--bad); }
.err { color: var(--bad); min-height: 0; }
form[data-config] + form[data-config] { margin-top: 14px; }
.seg button { border: 0; border-right: 1px solid var(--line); border-radius: 0; background: var(--panel); color: var(--muted); }
.seg button:last-child { border-right: 0; }
.seg button.on { background: var(--accent-bg); color: var(--text); }
.clip { max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* нижняя панель и меню «Ещё» — только на телефоне */
nav.bottom, .sheet { display: none; }

@media (max-width: 700px) {
  nav.main, .top .who, .top .logout { display: none; }
  .top-in { justify-content: space-between; padding: 0 12px; }
  .brand span { display: inline; }
  main { padding-bottom: calc(84px + env(safe-area-inset-bottom)); }
  nav.bottom { display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; background: rgba(22,27,34,.97); backdrop-filter: blur(8px);
    border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom); }
  nav.bottom a, nav.bottom button { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 1px; padding: 8px 2px 7px; color: var(--muted);
    background: none; border: 0; border-radius: 0; font-size: 11px; position: relative; min-width: 0; }
  nav.bottom i { font-style: normal; font-size: 19px; line-height: 1.1; }
  nav.bottom a.on, nav.bottom button.on { color: var(--accent); }
  nav.bottom a:hover { text-decoration: none; }
  nav.bottom .badge { position: absolute; top: 4px; left: 54%; margin: 0; }
  .sheet:not([hidden]) { display: block; position: fixed; inset: 0; z-index: 40; background: rgba(0,0,0,.5); }
  .sheet-in { position: absolute; left: 0; right: 0; bottom: 0; background: var(--panel); border-top: 1px solid var(--line); border-radius: 16px 16px 0 0;
    padding: 8px 12px calc(16px + env(safe-area-inset-bottom)); display: flex; flex-direction: column; gap: 2px; }
  .sheet-in a, .sheet-in button { padding: 13px 8px; color: var(--text); font-size: 16px; text-align: left; border: 0; background: none; border-bottom: 1px solid var(--line); border-radius: 0; }
  .sheet-in i { font-style: normal; display: inline-block; width: 26px; color: var(--accent); }
  .sheet-who { padding: 10px 8px 4px; color: var(--muted); font-size: 13px; }
  .toast { bottom: calc(80px + env(safe-area-inset-bottom)); }

  /* таблицы → карточки */
  .tablewrap { border: 0; background: none; overflow: visible; }
  .tablewrap table, .tablewrap tbody { display: block; width: 100%; }
  .tablewrap thead { display: none; }
  .tablewrap tr { display: grid; grid-template-columns: 1fr 1fr; gap: 4px 14px; background: var(--panel); border: 1px solid var(--line);
    border-radius: var(--radius); padding: 9px 12px; margin-bottom: 8px; }
  .tablewrap tbody tr:hover td { background: none; }
  .tablewrap td { display: block; border: 0; padding: 2px 0; text-align: left !important; min-width: 0; white-space: normal; }
  .tablewrap td::before { content: attr(data-label); display: block; font-size: 11px; color: var(--muted); }
  .tablewrap td:first-child, .tablewrap td[colspan], .tablewrap td.wide { grid-column: 1 / -1; }
  .tablewrap td:first-child::before, .tablewrap td[colspan]::before, .tablewrap td:not([data-label])::before, .tablewrap td[data-label=""]::before { display: none; }
  .tablewrap td.empty { padding: 20px; }
  .tablewrap td.blank { display: none; }
  .person .nm { max-width: none; }
  .m-sort { width: 100%; margin: 0 0 10px; font-size: 15px; padding: 9px 10px; }
  .filters { gap: 6px; } .filters label { flex: 1 1 42%; } .filters input, .filters select { width: 100% !important; font-size: 16px; }
  input, select, textarea { font-size: 16px; }                       /* iOS не увеличивает страницу при вводе */
  button, .btn { padding: 9px 13px; } button.sm, .btn.sm { padding: 6px 11px; }
  .cmds { grid-template-columns: 1fr 1fr; gap: 8px; } .cmd { padding: 10px 11px; } .cmd h3 { font-size: 14px; }
  h1 { font-size: 20px; }
}
@media (min-width: 701px) { .m-sort { display: none; } }
@media (min-width: 701px) and (max-width: 1100px) {                  /* планшет */
  main { padding: 16px 20px 60px; }
  .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* переключатель языка RU / EN: в шапке, в меню «Ещё» на телефоне и над формой входа */
.langsw { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; margin-left: auto; font-size: 12px; }
.langsw a { padding: 4px 9px; color: var(--muted); background: var(--panel); border-right: 1px solid var(--line); }
.langsw a:last-child { border-right: 0; }
.langsw a.on { background: var(--accent-bg); color: var(--text); }
.langsw a:hover { text-decoration: none; color: var(--text); }
.login-lang { position: fixed; top: 12px; right: 12px; }
