/* Общая структура компонентов ядра. Цвета/шрифты задаёт тема через переменные. */
:root {
  --t-clean: #34d399; --t-ban: #f43f5e; --t-nocheck: #60a5fa; --t-leave: #c084fc;
  --t-watch: #2dd4bf; --t-warn: #f59e0b; --t-pending: #fbbf24; --t-none: #94a3b8;
  --ease: cubic-bezier(.2, .8, .2, 1);
}
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
button { font: inherit; color: inherit; cursor: pointer; }
.mono { font-family: var(--mono, ui-monospace, "JetBrains Mono", Consolas, monospace); }
.ch-muted { color: var(--muted); }
.hidden { display: none !important; }

/* Статус-бейдж */
.ch-badge { --c: var(--t-none); display: inline-flex; align-items: center; gap: 7px; padding: 4px 10px 4px 8px; border-radius: var(--badge-r, 999px);
  font-size: 12px; font-weight: 500; white-space: nowrap; color: var(--c); background: color-mix(in srgb, var(--c) 12%, transparent);
  border: 1px solid color-mix(in srgb, var(--c) 22%, transparent); max-width: 100%; overflow: hidden; text-overflow: ellipsis; }
.ch-badge i { width: 6px; height: 6px; border-radius: 50%; background: var(--c); flex: none; box-shadow: 0 0 8px var(--c); }
.t-clean { --c: var(--t-clean) } .t-ban { --c: var(--t-ban) } .t-nocheck { --c: var(--t-nocheck) } .t-leave { --c: var(--t-leave) }
.t-watch { --c: var(--t-watch) } .t-warn { --c: var(--t-warn) } .t-pending { --c: var(--t-pending) } .t-none { --c: var(--t-none) }
.t-pending i { animation: ch-pulse 1.6s infinite; }
@keyframes ch-pulse { 50% { opacity: .25; transform: scale(.6); } }

.ch-cid { font-family: var(--mono, monospace); font-size: 12.5px; font-weight: 600; letter-spacing: .06em; padding: 3px 9px; border-radius: var(--chip-r, 6px);
  background: var(--chip-bg, rgba(255,255,255,.06)); border: 1px solid var(--line); color: var(--text); transition: .2s var(--ease); }
.ch-cid:hover { background: var(--accent); color: var(--accent-ink, #000); border-color: var(--accent); transform: translateY(-1px); }
.ch-link { color: var(--accent); text-decoration: none; font-size: 13px; white-space: nowrap; }
.ch-link:hover { text-decoration: underline; }
.ch-edit { width: 30px; height: 30px; border-radius: 8px; border: 1px solid transparent; background: transparent; color: var(--muted); transition: .2s; flex: none; }
.ch-edit:hover { background: var(--chip-bg, rgba(255,255,255,.06)); border-color: var(--line); color: var(--text); }

/* Таблица */
.ch-table-wrap { overflow: auto; }
.ch-table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.ch-table th { text-align: left; font-weight: 500; font-size: 11.5px; letter-spacing: .08em; text-transform: uppercase; color: var(--muted);
  padding: 12px 14px; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: var(--table-head, var(--bg)); z-index: 1; white-space: nowrap; }
.ch-table td { padding: 11px 14px; border-bottom: 1px solid var(--line-soft, var(--line)); vertical-align: middle; }
.ch-table tbody tr { animation: ch-row-in .45s var(--ease) both; animation-delay: calc(var(--i) * 14ms); transition: background .15s; }
.ch-table tbody tr:hover { background: var(--row-hover, rgba(255,255,255,.025)); }
@keyframes ch-row-in { from { opacity: 0; transform: translateY(6px); } }
.ch-table .w-num { width: 56px; } .ch-table .w-cid { width: 90px; } .ch-table .w-act { width: 44px; text-align: right; }
.ch-table .w-wide { min-width: 220px; }
.ch-row { color: var(--muted); font-family: var(--mono, monospace); font-size: 12px; }
.ch-clip { max-width: 340px; overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; color: var(--text-2, var(--text)); }
.ch-empty { text-align: center; padding: 48px !important; color: var(--muted); }
.ch-pager { display: flex; justify-content: space-between; align-items: center; padding: 14px 4px 0; font-size: 13px; }
.ch-pager-btns { display: flex; gap: 6px; }
.ch-pager-btns button { min-width: 34px; height: 32px; border-radius: 8px; border: 1px solid var(--line); background: transparent; transition: .2s; }
.ch-pager-btns button:hover:not(:disabled) { background: var(--accent); color: var(--accent-ink, #000); border-color: var(--accent); }
.ch-pager-btns button:disabled { opacity: .3; cursor: default; }

/* Фильтры */
.ch-select, .ch-input { font: inherit; font-size: 13.5px; color: var(--text); background: var(--input-bg, rgba(255,255,255,.04)); border: 1px solid var(--line);
  border-radius: var(--input-r, 10px); padding: 9px 12px; outline: none; transition: border-color .2s, box-shadow .2s, background .2s; min-width: 0; }
.ch-select { appearance: none; padding-right: 30px; background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 15px) 52%, calc(100% - 10px) 52%; background-size: 5px 5px; background-repeat: no-repeat; }
.ch-select option { background: #111; color: #eee; }
.ch-input:focus, .ch-select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent); }
textarea.ch-input { resize: vertical; min-height: 80px; }
.ch-pill { display: inline-flex; align-items: center; gap: 8px; padding: 7px 13px; border-radius: 999px; border: 1px solid var(--line); background: transparent;
  font-size: 13px; color: var(--text-2, var(--text)); transition: .25s var(--ease); }
.ch-pill b { font-weight: 500; font-size: 11.5px; color: var(--muted); }
.ch-pill:hover { border-color: var(--text-2, var(--text)); }
.ch-pill.on { background: var(--accent); color: var(--accent-ink, #000); border-color: var(--accent); }
.ch-pill.on b { color: inherit; opacity: .65; }

/* Форма */
.ch-form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.ch-field { display: flex; flex-direction: column; gap: 7px; }
.ch-field.wide { grid-column: 1 / -1; }
.ch-field > span { font-size: 12px; color: var(--muted); letter-spacing: .02em; }
.ch-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.ch-chip { padding: 4px 10px; font-size: 12px; border-radius: 999px; border: 1px dashed var(--line); background: transparent; color: var(--muted); transition: .2s; }
.ch-chip:hover { color: var(--text); border-style: solid; }
.ch-chip.on { background: color-mix(in srgb, var(--accent) 16%, transparent); color: var(--accent); border: 1px solid var(--accent); }

.ch-btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 9px 16px; border-radius: var(--btn-r, 10px); font-size: 13.5px; font-weight: 500;
  border: 1px solid var(--line); background: var(--chip-bg, rgba(255,255,255,.05)); transition: .25s var(--ease); white-space: nowrap; }
.ch-btn:hover { border-color: var(--text-2, var(--text)); transform: translateY(-1px); }
.ch-btn-primary { background: var(--accent); color: var(--accent-ink, #000); border-color: var(--accent); }
.ch-btn-primary:hover { filter: brightness(1.08); box-shadow: 0 8px 28px -8px var(--accent); }
.ch-btn:disabled { opacity: .5; pointer-events: none; }

/* Участники (зарплаты) */
.ch-member { display: grid; grid-template-columns: 44px minmax(150px, 1.3fr) repeat(4, minmax(70px, .6fr)) minmax(170px, 1.2fr) 32px; align-items: center; gap: 16px;
  padding: 14px 16px; border-bottom: 1px solid var(--line-soft, var(--line)); animation: ch-row-in .5s var(--ease) both; animation-delay: calc(var(--i) * 40ms); }
.ch-avatar { width: 40px; height: 40px; border-radius: var(--avatar-r, 12px); display: grid; place-items: center; font-weight: 700; font-size: 13px;
  background: var(--avatar-bg, color-mix(in srgb, var(--accent) 18%, transparent)); color: var(--accent); }
.ch-member-name { font-weight: 600; } .ch-member-role { font-size: 12.5px; color: var(--muted); }
.ch-member-stat span { display: block; font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
.ch-member-stat b { font-weight: 600; font-size: 14px; }
.ch-member-pay b { font-size: 15px; } .ch-member-pay .ch-muted { font-size: 11.5px; margin-left: 8px; }
.ch-member-bar { height: 4px; background: var(--line); border-radius: 4px; overflow: hidden; margin-bottom: 6px; }
.ch-member-bar i { display: block; height: 100%; background: var(--accent); border-radius: 4px; animation: ch-grow 1.1s var(--ease) both; transform-origin: left; }
@keyframes ch-grow { from { transform: scaleX(0); } }

/* Досье */
.ch-dactions { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 22px; }
.ch-dsec { margin-bottom: 22px; }
.ch-dsec h4 { display: flex; align-items: center; gap: 10px; margin: 0 0 10px; font-size: 12px; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); font-weight: 500; }
.ch-dsec h4 span { padding: 1px 8px; border-radius: 999px; background: var(--chip-bg, rgba(255,255,255,.06)); color: var(--text); font-size: 11px; }
.ch-dcard { padding: 12px 14px; border: 1px solid var(--line); border-radius: var(--card-r-sm, 12px); margin-bottom: 8px; font-size: 13.5px; line-height: 1.5;
  background: var(--chip-bg, rgba(255,255,255,.02)); animation: ch-row-in .45s var(--ease) both; animation-delay: calc(var(--i) * 50ms + 120ms); }
.ch-dcard-top { display: flex; align-items: center; gap: 10px; margin-bottom: 6px; flex-wrap: wrap; }
.ch-dcard-top .ch-badge { margin-left: auto; }
.ch-dnone { font-size: 13px; padding: 6px 0; }

/* Toast */
.ch-toasts { position: fixed; bottom: 24px; right: 24px; display: flex; flex-direction: column; gap: 10px; z-index: 999; }
.ch-toast { padding: 12px 16px 12px 14px; border-radius: 12px; font-size: 13.5px; display: flex; gap: 10px; align-items: center; min-width: 260px;
  background: var(--toast-bg, #151515); border: 1px solid var(--line); box-shadow: 0 20px 50px -10px rgba(0,0,0,.6); animation: ch-toast .5s var(--ease) both; }
.ch-toast::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--t-clean); box-shadow: 0 0 10px var(--t-clean); }
.ch-toast.err::before { background: var(--t-ban); box-shadow: 0 0 10px var(--t-ban); }
.ch-toast.out { animation: ch-toast-out .35s ease forwards; }
@keyframes ch-toast { from { opacity: 0; transform: translateY(16px) scale(.96); } }
@keyframes ch-toast-out { to { opacity: 0; transform: translateX(30px); } }

@media (max-width: 900px) {
  .ch-member { grid-template-columns: 40px 1fr auto; } .ch-member-stat { display: none; } .ch-member-pay { grid-column: 2 / 3; }
  .ch-form-grid { grid-template-columns: 1fr; }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; } }

/* Тонкие скроллбары */
* { scrollbar-width: thin; scrollbar-color: rgba(255,255,255,.14) transparent; }
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,.12); border-radius: 8px; border: 2px solid transparent; background-clip: padding-box; }
::-webkit-scrollbar-thumb:hover { background-color: rgba(255,255,255,.25); }
