/* CRM «стартрек» — та же палитра и шрифты, что у мини-приложения: заголовки Advent Pro, текст Golos, цифры JetBrains Mono */
@font-face { font-family: 'Advent Pro'; font-weight: 700; font-display: swap; src: url('/app/fonts/advent-pro-cyrillic-700-normal.woff2') format('woff2'); unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116; }
@font-face { font-family: 'Advent Pro'; font-weight: 700; font-display: swap; src: url('/app/fonts/advent-pro-latin-700-normal.woff2') format('woff2'); unicode-range: U+0000-00FF, U+2000-206F, U+20AC, U+2122, U+2212; }
@font-face { font-family: 'Advent Pro'; font-weight: 600; font-display: swap; src: url('/app/fonts/advent-pro-cyrillic-600-normal.woff2') format('woff2'); unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116; }
@font-face { font-family: 'Advent Pro'; font-weight: 600; font-display: swap; src: url('/app/fonts/advent-pro-latin-600-normal.woff2') format('woff2'); unicode-range: U+0000-00FF, U+2000-206F, U+20AC, U+2122, U+2212; }
@font-face { font-family: 'Golos Text'; font-weight: 600; font-display: swap; src: url('/app/fonts/golos-text-cyrillic-600-normal.woff2') format('woff2'); unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116; }
@font-face { font-family: 'Golos Text'; font-weight: 600; font-display: swap; src: url('/app/fonts/golos-text-latin-600-normal.woff2') format('woff2'); unicode-range: U+0000-00FF, U+2000-206F, U+20AC, U+2122, U+2212; }
@font-face { font-family: 'Golos Text'; font-weight: 400; font-display: swap; src: url('/app/fonts/golos-text-cyrillic-400-normal.woff2') format('woff2'); unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116; }
@font-face { font-family: 'Golos Text'; font-weight: 400; font-display: swap; src: url('/app/fonts/golos-text-latin-400-normal.woff2') format('woff2'); unicode-range: U+0000-00FF, U+2000-206F, U+20AC, U+2122, U+2212; }
@font-face { font-family: 'Golos Text'; font-weight: 500; font-display: swap; src: url('/app/fonts/golos-text-cyrillic-500-normal.woff2') format('woff2'); unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116; }
@font-face { font-family: 'Golos Text'; font-weight: 500; font-display: swap; src: url('/app/fonts/golos-text-latin-500-normal.woff2') format('woff2'); unicode-range: U+0000-00FF, U+2000-206F, U+20AC, U+2122, U+2212; }
@font-face { font-family: 'JetBrains Mono'; font-weight: 400; font-display: swap; src: url('/app/fonts/jetbrains-mono-cyrillic-400-normal.woff2') format('woff2'); unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116; }
@font-face { font-family: 'JetBrains Mono'; font-weight: 400; font-display: swap; src: url('/app/fonts/jetbrains-mono-latin-400-normal.woff2') format('woff2'); unicode-range: U+0000-00FF, U+2000-206F, U+20AC, U+2122, U+2212; }

:root {
  --bg: #1d1b1c; --bg-deep: #161415; --panel: #272526; --panel-2: #302d2f; --line: #3d3a3c; --line-soft: rgb(243 239 236 / 0.07);
  --text: #f3efec; --muted: #b7b1b3; --dim: #918b8e;
  --lime: #dafe04; --lime-ink: #1b1d05; --violet: #6a5ac7; --violet-light: #8577de; --mint: #6fd5b2; --orange-bg: #fd7046;
  --late: #ff7a59; --today: #ffd34d;
  --head: 'Advent Pro', 'Arial Narrow', sans-serif; --body: 'Golos Text', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --mono: 'JetBrains Mono', ui-monospace, 'SF Mono', Menlo, monospace;
  --ease: cubic-bezier(0.16, 1, 0.3, 1);
}
* { box-sizing: border-box; margin: 0; }
html { -webkit-text-size-adjust: 100%; }
body { min-height: 100dvh; background: var(--bg); color: var(--text); font: 400 14px/1.45 var(--body); -webkit-font-smoothing: antialiased; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; }
a { color: inherit; }
::selection { background: var(--violet); color: #fff; }
:focus-visible { outline: 2px solid var(--lime); outline-offset: 2px; }
[hidden] { display: none !important; }

/* шапка */
header.top { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 24px; padding: 14px 24px; background: rgb(29 27 28 / 0.94); backdrop-filter: blur(10px); border-bottom: 1px solid var(--line-soft); }
.brand { display: flex; align-items: center; gap: 8px; flex: none; }
.brand svg { width: 24px; height: 22px; }
.brand b { font: 700 19px/1 var(--head); }
.brand span { font: 400 12px/1 var(--mono); color: var(--lime); letter-spacing: 0.06em; }
.top__stats { display: flex; gap: 14px; flex-wrap: wrap; font-size: 13px; color: var(--muted); }
.top__stats b { font: 400 14px/1 var(--mono); color: var(--text); margin-right: 4px; }
.top__stats .is-alert b { color: var(--lime); }
.top__me { margin-left: auto; flex: none; display: flex; align-items: center; gap: 14px; }
.top__name { font-size: 13px; color: var(--muted); }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 36px; padding: 0 14px; border-radius: 10px; font-weight: 500; font-size: 13.5px; text-decoration: none; white-space: nowrap; transition: background 0.2s var(--ease), color 0.2s var(--ease); }
.btn--main { background: var(--text); color: var(--bg); }
.btn--main:hover { background: #fff; }
.btn--lime { background: var(--lime); color: var(--lime-ink); }
.btn--ghost { border: 1px solid var(--line); }
.btn--ghost:hover { background: var(--panel); }
.btn--text { color: var(--dim); padding: 0 4px; }
.btn--text:hover { color: var(--text); }
.btn:disabled { opacity: 0.5; cursor: default; }

.view { padding: 18px 24px 40px; }

/* разделы в шапке */
.nav { display: flex; gap: 4px; }
.nav a { padding: 8px 14px; border-radius: 99px; font: 600 15px/1 var(--head); letter-spacing: 0.04em; text-transform: uppercase; color: var(--muted); text-decoration: none; transition: background 0.2s var(--ease), color 0.2s var(--ease); white-space: nowrap; }
.nav a:hover { color: var(--text); background: var(--panel); }
.nav a.is-on { background: var(--lime); color: var(--lime-ink); }
.sum { display: flex; gap: 18px; flex-wrap: wrap; font-size: 13px; color: var(--muted); margin: 0 0 14px; }
.sum b { font: 400 15px/1 var(--mono); color: var(--text); margin-right: 5px; }
.sum .is-alert b { color: var(--lime); }

/* страницы архива потока */
.pg { max-width: 1200px; margin: 0 auto; }
.pg-head { margin: 6px 0 14px; }
.pg-t { font: 700 clamp(30px, 4vw, 44px)/1 var(--head); letter-spacing: 0.02em; }
.pg-n { color: var(--dim); font-size: 13px; margin-top: 6px; }
.subnav { position: sticky; top: 65px; z-index: 3; display: flex; gap: 6px; flex-wrap: wrap; padding: 10px 0; background: var(--bg); }
.subnav a { padding: 7px 13px; border: 1px solid var(--line); border-radius: 99px; font-size: 13px; color: var(--muted); text-decoration: none; }
.subnav a:hover { color: var(--text); border-color: var(--violet-light); }
.search--pg { display: block; max-width: 420px; margin: 4px 0 6px; }
.pg-lock { font-size: 12.5px; color: var(--dim); margin: 8px 0 18px; }
.ablk { scroll-margin-top: 130px; }
.ablk + .ablk { margin-top: 8px; }

/* разделы из дашборда потока: его стили (archive.css) + наши цвета и шрифты */
.arch { --ink: var(--bg); --ink-2: var(--panel); --ink-3: var(--panel-2); --line: #3d3a3c; --line-2: #4a4446; --txt: var(--text); --txt-2: var(--muted); --txt-3: var(--dim); --violet-lt: var(--violet-light); --orange: #fe572b; --display: var(--head); font-size: 15px; line-height: 1.55; }
.arch img { max-width: 100%; }
.arch .wk { display: none; }
.arch .wk.on { display: block; }
.arch .sw-tab.on { background: var(--violet); border-color: var(--violet); color: #fff; }
.arch .sw-tab { cursor: pointer; }
.d-script-b { width: 100%; }
.d-script { margin-top: 10px; }
.d-script .arch .panel { padding: 0; background: none; border: 0; }

/* фильтры */
.bar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 14px; }
.search { position: relative; flex: 1 1 280px; max-width: 420px; }
.search svg { position: absolute; left: 12px; top: 50%; translate: 0 -50%; width: 16px; height: 16px; stroke: var(--dim); fill: none; stroke-width: 2; }
.search input { width: 100%; height: 38px; padding: 0 12px 0 36px; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; }
.search input::placeholder { color: var(--dim); }
.sel { height: 38px; padding: 0 30px 0 12px; background: var(--panel) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23918b8e' stroke-width='2'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E") no-repeat right 10px center / 14px; border: 1px solid var(--line); border-radius: 10px; appearance: none; cursor: pointer; }
.sel.is-set { border-color: var(--lime); }
.bar__count { margin-left: auto; font: 400 12px/1 var(--mono); color: var(--dim); }

/* таблица */
.tbl-wrap { overflow: auto; border: 1px solid var(--line); border-radius: 14px; max-height: calc(100dvh - 160px); }
.tbl-wrap table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.tbl-wrap thead th { position: sticky; top: 0; z-index: 1; background: var(--bg-deep); text-align: left; font: 500 11px/1 var(--mono); letter-spacing: 0.06em; text-transform: uppercase; color: var(--dim); padding: 12px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.tbl-wrap thead th[data-sort] { cursor: pointer; user-select: none; }
.tbl-wrap thead th[data-sort]:hover, .tbl-wrap thead th.is-sorted { color: var(--text); }
.tbl-wrap thead th.is-sorted::after { content: ' ↓'; }
.tbl-wrap thead th.is-sorted.is-asc::after { content: ' ↑'; }
.tbl-wrap tbody tr { cursor: pointer; transition: background 0.15s; }
.tbl-wrap tbody tr:hover { background: var(--panel); }
.tbl-wrap tbody tr.is-open { background: var(--panel-2); }
.tbl-wrap tbody td { padding: 11px 12px; border-bottom: 1px solid var(--line-soft); vertical-align: top; white-space: nowrap; }
.tbl-wrap tbody tr:last-child td { border-bottom: 0; }
td.num, td.date { font: 400 12.5px/1.45 var(--mono); color: var(--muted); }
td.name { font-weight: 500; }
td.wrap { white-space: normal; min-width: 220px; max-width: 320px; color: var(--muted); font-size: 12.5px; }
td.c { text-align: center; color: var(--muted); }
tr.is-new td.num { color: var(--lime); }
.dim { color: var(--dim); }

.st, .kind { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); }
.st::before, .kind::before { content: ''; width: 7px; height: 7px; border-radius: 50%; background: var(--dim); flex: none; }
.kind::before { border-radius: 2px; }
.st[data-s='new']::before { background: var(--lime); } .st[data-s='new'] { color: var(--text); }
.st[data-s='taken']::before, .st[data-s='contacted']::before { background: var(--violet-light); }
.st[data-s='noanswer']::before { background: var(--late); }
.st[data-s='thinking']::before { background: var(--today); }
.st[data-s='paid']::before { background: var(--mint); }
.kind[data-k='lead']::before { background: var(--lime); } .kind[data-k='lab']::before { background: var(--mint); } .kind[data-k='club']::before { background: var(--orange-bg); } .kind[data-k='partner']::before { background: var(--violet-light); }
.ava { flex: none; width: 20px; height: 20px; border-radius: 50%; display: inline-grid; place-items: center; font: 600 9px/1 var(--body); color: #fff; vertical-align: -5px; margin-right: 6px; }

.empty { padding: 60px 20px; text-align: center; color: var(--dim); }
.empty b { display: block; font: 700 24px/1.1 var(--head); color: var(--text); margin-bottom: 6px; }

/* карточка заявки справа */
.drawer { position: fixed; inset: 0; z-index: 20; }
.drawer__shade { position: absolute; inset: 0; background: rgb(0 0 0 / 0.45); animation: fade 0.2s var(--ease); }
.drawer__panel { position: absolute; top: 0; right: 0; bottom: 0; width: min(480px, 100%); overflow-y: auto; background: var(--bg); border-left: 1px solid var(--line); padding: 26px 26px 40px; animation: slide 0.35s var(--ease); }
.drawer__x { position: absolute; top: 16px; right: 16px; width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; }
.drawer__x:hover { background: var(--panel); }
.drawer__x svg { width: 18px; height: 18px; stroke: var(--muted); stroke-width: 2; fill: none; }
@keyframes slide { from { translate: 40px 0; opacity: 0; } }
@keyframes fade { from { opacity: 0; } }

.d-kicker { display: flex; gap: 10px; align-items: center; font: 400 12px/1 var(--mono); color: var(--dim); margin-bottom: 10px; }
.d-title { font: 700 30px/1.05 var(--head); margin: 0 40px 8px 0; }
.d-sec { margin-top: 22px; }
.d-sec > h3 { font: 500 11px/1 var(--mono); letter-spacing: 0.08em; text-transform: uppercase; color: var(--dim); margin-bottom: 10px; }
.d-take { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 16px; background: var(--panel); border-radius: 14px; margin-top: 18px; }
.d-take p { color: var(--muted); font-size: 13px; }
.chips { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; }
.chip { height: 34px; padding: 0 10px; border-radius: 9px; background: var(--panel); justify-content: flex-start; display: flex; align-items: center; }
.chip:hover { background: var(--panel-2); }
.chip.is-on { background: var(--text); }
.chip.is-on .st { color: var(--bg); }
.who { display: flex; flex-wrap: wrap; gap: 6px; }
.who .chip { display: inline-flex; width: auto; }
.who .chip.is-on { color: var(--bg); }
dl.data { background: var(--panel); border-radius: 14px; overflow: hidden; }
dl.data div { display: grid; grid-template-columns: 140px 1fr; gap: 12px; padding: 10px 14px; border-bottom: 1px solid var(--line-soft); }
dl.data div:last-child { border-bottom: 0; }
dl.data dt { color: var(--dim); font-size: 13px; }
dl.data dd { word-break: break-word; }
dl.data a { text-decoration-color: var(--line); text-underline-offset: 3px; }
.notes { list-style: none; padding: 0; display: grid; gap: 8px; margin-bottom: 10px; }
.notes li { background: var(--panel); border-radius: 12px; padding: 10px 14px; }
.notes small { display: block; font: 400 11.5px/1.3 var(--mono); color: var(--dim); margin-bottom: 4px; }
.note-form { display: flex; gap: 8px; align-items: flex-end; }
.note-form textarea { flex: 1; min-height: 42px; max-height: 160px; resize: vertical; padding: 10px 12px; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; }
.hist { list-style: none; padding: 0 0 0 12px; border-left: 1px solid var(--line); display: grid; gap: 6px; font-size: 13px; color: var(--muted); }
.hist time { font: 400 12px/1 var(--mono); color: var(--dim); margin-right: 8px; }
.d-link { display: inline-block; margin-top: 18px; font-size: 13px; color: var(--muted); }

/* вход */
.login { min-height: calc(100dvh - 120px); display: grid; place-items: center; }
.login__card { width: min(420px, 100%); background: var(--panel); border-radius: 20px; padding: 32px 30px; }
.login__card h1 { font: 700 34px/1 var(--head); margin-bottom: 12px; }
.login__card p, .login__card small { display: block; color: var(--dim); font-size: 12.5px; line-height: 1.5; text-wrap: pretty; }
.login__card p { margin-bottom: 20px; }
.login__card .btn { width: 100%; height: 44px; }
.login__card small { margin-top: 14px; }
.login__card code { font: 400 12.5px/1 var(--mono); color: var(--text); }
.login__warn { background: rgb(255 122 89 / 0.12); color: var(--late) !important; padding: 10px 12px; border-radius: 10px; font-size: 13px; }

.loading { display: flex; gap: 10px; align-items: center; justify-content: center; padding: 80px 0; color: var(--dim); }
.loading span { width: 14px; height: 14px; border: 2px solid var(--line); border-top-color: var(--lime); border-radius: 50%; animation: spin 0.8s linear infinite; }
@keyframes spin { to { rotate: 360deg; } }

.toast { position: fixed; left: 50%; bottom: 24px; translate: -50% 0; z-index: 30; background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 12px; font-weight: 500; font-size: 13.5px; box-shadow: 0 8px 30px rgb(0 0 0 / 0.35); }
.toast.is-err { background: var(--late); color: #fff; }

@media (max-width: 760px) {
  header.top { flex-wrap: wrap; gap: 10px 16px; padding: 12px 16px; }
  .top__stats { order: 3; width: 100%; }
  .top__name, #export { display: none; }
  .nav { order: 4; width: 100%; overflow-x: auto; scrollbar-width: none; margin: 0 -16px; padding: 0 16px; width: calc(100% + 32px); }
  .nav a { padding: 7px 12px; font-size: 14px; }
  .subnav { top: 104px; flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; }
  .ablk { scroll-margin-top: 170px; }
  .view { padding: 14px 16px 30px; }
  .search { max-width: none; flex-basis: 100%; }
  .sel { flex: 1 1 calc(50% - 5px); min-width: 0; }
  .bar__count { width: 100%; margin: 0; }
  /* на телефоне строки таблицы — карточки: имя и номер, направление · статус · ответственный, телефон и дата */
  .tbl-wrap { max-height: none; overflow: visible; border: 0; border-radius: 0; }
  .tbl-wrap table, .tbl-wrap tbody { display: block; }
  .tbl-wrap thead { display: none; }
  .tbl-wrap tbody tr { display: grid; grid-template-columns: auto auto 1fr; gap: 6px 14px; padding: 12px 14px; border: 1px solid var(--line); border-radius: 14px; margin-bottom: 8px; }
  .tbl-wrap tbody td { padding: 0; border: 0 !important; white-space: normal; }
  td.name { grid-area: 1 / 1 / 2 / 3; font-size: 15px; }
  td.num { grid-area: 1 / 3; justify-self: end; }
  td.k { grid-area: 2 / 1; } td.s { grid-area: 2 / 2; } td.w { grid-area: 2 / 3; justify-self: end; font-size: 13px; color: var(--muted); }
  td.p { grid-area: 3 / 1 / 4 / 3; font-size: 13px; color: var(--muted); }
  td.date { grid-area: 3 / 3; justify-self: end; font-size: 11.5px; }
  td.e, td.t, td.c, td.wrap { display: none; }
  .drawer__panel { padding: 22px 16px 32px; border-left: 0; }
  .chips { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  dl.data div { grid-template-columns: 1fr; gap: 2px; }
  .note-form { flex-direction: column; align-items: stretch; }
}
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
