@font-face {
  font-family: "Manrope";
  src: url("/static/fonts/manrope-cyrillic-wght-normal.woff2") format("woff2");
  font-weight: 200 800;
  font-display: swap;
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}
@font-face {
  font-family: "Manrope";
  src: url("/static/fonts/manrope-latin-wght-normal.woff2") format("woff2");
  font-weight: 200 800;
  font-display: swap;
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

:root {
  color-scheme: dark;
  --bg: #061a26;
  --surface: #092433;
  --raised: #0d3044;
  --line: #1e3644;
  --line-strong: #334955;
  --text: #e6f2f9;
  --muted: #8f99a1;
  --soft: #abb3b8;
  --red: #eb4247;
  --red-hover: #ef686c;
  --blue: #3599ce;
  --green: #45c08d;
  --grey: #738089;
  --radius: 8px;
  --font: "Manrope", Arial, sans-serif;
}

* { box-sizing: border-box; }
html { background: var(--bg); }
body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font: 500 15px/1.5 var(--font);
  font-variant-numeric: tabular-nums;
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3 { margin: 0; font-weight: 700; letter-spacing: -0.01em; }
a { color: var(--blue); }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }
[hidden] { display: none !important; }
.noscript { padding: 24px; }

/* ---------- controls ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 40px; padding: 0 18px;
  border: 1px solid var(--line-strong); border-radius: var(--radius);
  background: transparent; color: var(--text);
  font-weight: 700; cursor: pointer;
}
.btn:hover { background: var(--raised); }
.btn.primary { background: var(--red); border-color: var(--red); color: #fff; }
.btn.primary:hover { background: var(--red-hover); border-color: var(--red-hover); }
.btn.small { min-height: 32px; padding: 0 12px; font-size: 13px; }
.btn.ghost { border-color: transparent; color: var(--soft); }
.btn.ghost:hover { color: var(--text); }
.btn:disabled { opacity: .5; cursor: default; }

.field { display: grid; gap: 6px; margin-bottom: 16px; }
.field > span { font-size: 13px; font-weight: 600; color: var(--soft); }
.field small { color: var(--muted); font-size: 13px; font-weight: 500; }
input, select, textarea {
  width: 100%; min-height: 40px; padding: 8px 12px;
  background: var(--bg); border: 1px solid var(--line-strong); border-radius: var(--radius);
}
textarea { min-height: 76px; resize: vertical; }
input::placeholder, textarea::placeholder { color: var(--muted); }
input:hover, select:hover, textarea:hover { border-color: var(--grey); }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--blue); box-shadow: 0 0 0 3px rgba(53, 153, 206, .25); }
input[aria-invalid="true"] { border-color: var(--red); }
select {
  appearance: none; padding-right: 34px; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.5l5 5 5-5' fill='none' stroke='%238f99a1' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center;
}
.error { color: #ff8a8e; font-size: 14px; font-weight: 600; margin: 0 0 12px; }
.error:empty { display: none; }
input[type="checkbox"] { width: 18px; min-height: 18px; height: 18px; accent-color: var(--green); cursor: pointer; }
input[type="radio"] { width: 18px; min-height: 18px; height: 18px; padding: 0; accent-color: var(--blue); cursor: pointer; }

/* ---------- login ---------- */
.login { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.login-box { width: 100%; max-width: 380px; }
.brand { display: flex; align-items: center; gap: 10px; font-size: 20px; font-weight: 800; letter-spacing: -0.02em; }
.brand svg { width: 28px; height: 28px; }
.login-box h1 { margin: 28px 0 4px; font-size: 26px; }
.login-box p.lead { margin: 0 0 24px; color: var(--muted); }
.login-box .btn { width: 100%; }
.tg-login { min-height: 48px; display: flex; margin-bottom: 8px; }
.login-box .hint { margin: 12px 0 0; color: var(--muted); font-size: 13px; }
.login-box .hint a { color: var(--text); text-decoration: underline; text-underline-offset: 2px; }
.login-box form { margin-top: 20px; }

/* ---------- shell ---------- */
.topbar { position: sticky; top: 0; z-index: 5; background: var(--surface); border-bottom: 1px solid var(--line); }
.topbar-in { max-width: 1240px; margin: 0 auto; padding: 0 24px; min-height: 60px; display: flex; align-items: center; gap: 28px; }
.tabs { display: flex; gap: 4px; flex: 1; overflow-x: auto; }
.tab {
  padding: 18px 12px 16px; border: 0; border-bottom: 2px solid transparent; background: none;
  color: var(--soft); font-weight: 700; cursor: pointer; white-space: nowrap;
}
.tab:hover { color: var(--text); }
.tab[aria-current="page"] { color: var(--text); border-bottom-color: var(--red); }
.who { display: flex; align-items: center; gap: 4px; color: var(--soft); font-size: 14px; white-space: nowrap; }
main { max-width: 1240px; margin: 0 auto; padding: 28px 24px 80px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 20px; }
.page-head h1 { font-size: 28px; }
.page-head p { margin: 4px 0 0; color: var(--muted); }

/* ---------- funnel ---------- */
.funnel { display: flex; margin: 0 0 24px; }
.stage {
  flex: 1 1 0; min-width: 0; min-height: 84px; padding: 14px 34px 14px 28px; margin-left: -14px;
  border: 0; text-align: left; cursor: pointer;
  clip-path: polygon(0 0, calc(100% - 22px) 0, 100% 50%, calc(100% - 22px) 100%, 0 100%, 22px 50%);
  background: var(--surface); color: var(--text);
  display: grid; align-content: center; gap: 2px;
  transition: background .15s;
}
.stage:first-child { margin-left: 0; padding-left: 20px; clip-path: polygon(0 0, calc(100% - 22px) 0, 100% 50%, calc(100% - 22px) 100%, 0 100%); }
.stage:hover { background: var(--raised); }
.stage b { font-size: 30px; line-height: 1; font-weight: 800; }
.stage span { font-size: 13px; font-weight: 700; color: var(--soft); }
.stage[data-s="в работе"] { box-shadow: inset 0 -4px 0 var(--blue); }
.stage[data-s="реализовано"] { box-shadow: inset 0 -4px 0 var(--green); }
.stage[data-s="проиграно"] { box-shadow: inset 0 -4px 0 var(--grey); }
.stage[aria-pressed="true"] { background: var(--raised); }
.stage[aria-pressed="true"] span { color: var(--text); }
.stage:focus-visible { outline-offset: -4px; }

/* ---------- toolbar ---------- */
.toolbar { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 14px; align-items: center; }
.toolbar input[type="search"] { width: 240px; }
.toolbar select { width: auto; min-width: 150px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }
.chip {
  min-height: 34px; padding: 0 14px; border-radius: 999px; border: 1px solid var(--line-strong);
  background: transparent; color: var(--soft); font-weight: 700; font-size: 14px; cursor: pointer;
}
.chip:hover { color: var(--text); border-color: var(--grey); }
.chip[aria-pressed="true"] { background: var(--text); border-color: var(--text); color: var(--bg); }
.spacer { flex: 1; }
.count { color: var(--muted); font-size: 14px; }

/* ---------- table ---------- */
.table-wrap { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th { text-align: left; padding: 12px 16px; color: var(--muted); font-size: 13px; font-weight: 700; border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: 10px 16px; border-bottom: 1px solid var(--line); vertical-align: middle; }
tr:last-child td { border-bottom: 0; }
tbody tr { cursor: pointer; }
table.static tbody tr { cursor: default; }
tbody tr:hover td { background: rgba(13, 48, 68, .6); }
td.id { font-weight: 800; white-space: nowrap; }
td.muted, .muted { color: var(--muted); }
td.company { max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.empty { padding: 56px 24px; text-align: center; color: var(--soft); }
.empty h2 { font-size: 18px; margin-bottom: 6px; color: var(--text); }
.empty p { margin: 0 0 18px; }

.status-select {
  width: auto; min-width: 140px; min-height: 34px; padding: 4px 32px 4px 30px; font-weight: 700; font-size: 14px;
  border-radius: 999px; background-color: transparent;
}
.dot { position: relative; display: inline-block; }
.dot::before {
  content: ""; position: absolute; left: 13px; top: 50%; width: 8px; height: 8px; margin-top: -4px; border-radius: 50%;
  background: var(--grey); z-index: 1; pointer-events: none;
}
.dot[data-s="в работе"]::before { background: var(--blue); }
.dot[data-s="реализовано"]::before { background: var(--green); }
.dot[data-s="проиграно"]::before { background: var(--grey); }
.pill { display: inline-flex; align-items: center; gap: 8px; font-weight: 700; font-size: 14px; }
.pill::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--grey); }
.pill[data-s="в работе"]::before { background: var(--blue); }
.pill[data-s="реализовано"]::before { background: var(--green); }

/* ---------- dialogs ---------- */
dialog { border: 1px solid var(--line-strong); background: var(--surface); color: var(--text); padding: 0; }
dialog::backdrop { background: rgba(3, 12, 18, .7); }
dialog.modal { width: min(480px, calc(100vw - 32px)); border-radius: 12px; }
dialog.sheet { margin: 0 0 0 auto; height: 100vh; max-height: 100vh; width: min(520px, 100vw); border-radius: 0; border-width: 0 0 0 1px; }
.dlg-in { padding: 24px; }
.dlg-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; margin-bottom: 20px; }
.dlg-head h2 { font-size: 20px; }
.dlg-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 8px; }

.choice { display: grid; gap: 10px; margin-bottom: 4px; }
.choice button {
  text-align: left; padding: 16px 18px; border-radius: var(--radius); border: 1px solid var(--line-strong);
  background: var(--bg); cursor: pointer; display: grid; gap: 2px;
}
.choice button:hover { border-color: var(--blue); background: var(--raised); }
.choice b { font-size: 16px; }
.choice span { color: var(--muted); font-size: 14px; }
.notice { padding: 14px 16px; border-radius: var(--radius); background: var(--raised); border-left: 3px solid var(--blue); margin-bottom: 16px; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; align-items: start; }

.sheet-head { padding: 20px 24px 16px; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: var(--surface); z-index: 2; }
.sheet-head .ids { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.sheet-head h2 { font-size: 24px; }
.sheet-head p { margin: 2px 0 0; color: var(--muted); }
.sheet-body { padding: 20px 24px 32px; }
.processed { display: flex; align-items: center; gap: 10px; padding: 12px 14px; border: 1px solid var(--line-strong); border-radius: var(--radius); margin-bottom: 18px; font-weight: 700; }
.timeline { list-style: none; margin: 0 0 18px; padding: 0; display: grid; gap: 0; }
.timeline li { padding: 10px 0 10px 18px; border-left: 2px solid var(--line); position: relative; }
.timeline li::before { content: ""; position: absolute; left: -5px; top: 17px; width: 8px; height: 8px; border-radius: 50%; background: var(--line-strong); }
.timeline li.comment::before { background: var(--blue); }
.timeline .meta { font-size: 13px; color: var(--muted); }
.timeline .meta b { color: var(--soft); }
.timeline .body { white-space: pre-wrap; overflow-wrap: anywhere; }
.timeline li.comment .body { margin-top: 4px; padding: 10px 12px; background: var(--bg); border-radius: var(--radius); }
h3.section { font-size: 15px; margin: 24px 0 12px; }

/* ---------- activity / team ---------- */
.day { margin: 26px 0 8px; font-size: 14px; font-weight: 800; color: var(--soft); }
.feed { list-style: none; margin: 0; padding: 0; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.feed li { display: grid; grid-template-columns: 56px 110px 1fr; gap: 14px; padding: 12px 16px; border-bottom: 1px solid var(--line); cursor: pointer; align-items: baseline; }
.feed li:last-child { border-bottom: 0; }
.feed li:hover { background: rgba(13, 48, 68, .6); }
.feed time { color: var(--muted); font-size: 13px; }
.feed .did { font-weight: 800; }
.feed .what { overflow-wrap: anywhere; }
.feed .what small { color: var(--muted); font-size: 13px; }
.team-add { display: grid; grid-template-columns: 1fr 1fr auto; gap: 12px; align-items: end; margin-bottom: 20px; }
.team-add .field { margin: 0; }
.tag { font-size: 12px; font-weight: 700; color: var(--muted); border: 1px solid var(--line-strong); border-radius: 999px; padding: 1px 8px; margin-left: 8px; }

#toast {
  position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 20px); opacity: 0; pointer-events: none;
  background: var(--text); color: var(--bg); font-weight: 700; padding: 10px 18px; border-radius: var(--radius); z-index: 100;
  transition: opacity .18s, transform .18s;
}
#toast.on { opacity: 1; transform: translate(-50%, 0); }
#toast.bad { background: #ffb4b6; }

@media (max-width: 760px) {
  .topbar-in { padding: 10px 16px 0; gap: 4px 12px; flex-wrap: wrap; }
  .brand { flex: 1; }
  .tabs { order: 3; flex-basis: 100%; margin: 0 -8px; }
  .tab { padding: 10px 12px 12px; }
  main { padding: 20px 16px 80px; }
  .who .name { display: none; }
  .funnel { flex-direction: column; }
  .stage, .stage:first-child { margin: 0 0 -1px; clip-path: none; min-height: 64px; padding: 12px 18px; }
  .row2, .team-add { grid-template-columns: 1fr; }
  .toolbar input[type="search"], .toolbar select { width: 100%; }
  .feed li { grid-template-columns: 1fr; gap: 2px; }
  table, thead, tbody, tr, td { display: block; }
  thead { display: none; }
  tbody tr { padding: 12px 16px; border-bottom: 1px solid var(--line); display: grid; grid-template-columns: 1fr auto; gap: 2px 12px; }
  tbody td { border: 0; padding: 0; }
  td.company { max-width: none; grid-column: 1 / -1; }
  td.hide-m { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}

.tag.boost { background: color-mix(in srgb, var(--blue) 22%, transparent); color: var(--text); margin-left: 0; }
.radios { border: 0; padding: 0; margin: 0 0 14px; }
.radios legend { padding: 0; margin-bottom: 6px; color: var(--muted); font-size: 13px; }
.radios > div { display: flex; gap: 12px; }
.radio { display: inline-flex; align-items: center; gap: 8px; padding: 9px 14px; border: 1px solid var(--line); border-radius: 8px; cursor: pointer; }
.radio:has(input:checked) { border-color: var(--blue); background: var(--raised); }
.radio:has(input:focus-visible) { outline: 2px solid var(--blue); outline-offset: 2px; }
.mgr-add { grid-template-columns: 1fr auto; max-width: 480px; }
.mgr-names { color: var(--muted); line-height: 1.7; max-width: 720px; }
