/* Панель агентов — стиль трекера Floxio (tasks.floxio.ru): Wix Madefor, синий #1E59C6, радиус 10px */
:root {
  --bg: #F5F7FA; --surface: #FFFFFF; --text: #0A0F1E; --muted: #5A6478; --faint: #8B95A8;
  --line: #E5E7EB; --line-strong: #D3D8E0; --hover: #EBEEF3;
  --primary: #1E59C6; --primary-tint: #EAF0FB; --primary-dark: #143F8C;
  --green: #0E8A5F; --green-tint: #E6F4EE; --amber: #B7700A; --amber-tint: #FBF1E2;
  --red: #C4321F; --red-tint: #FBEAE7; --violet: #6B4FC8; --violet-tint: #F0ECFB;
  --display: 'Wix Madefor Display', system-ui, sans-serif; --sans: 'Wix Madefor Text', system-ui, sans-serif;
  --r: 10px; --shadow: 0 1px 2px rgba(10, 15, 30, .04), 0 1px 3px rgba(10, 15, 30, .06);
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { font: 14px/1.5 var(--sans); color: var(--text); background: var(--bg);
  -webkit-font-smoothing: antialiased; font-variant-numeric: tabular-nums; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3 { font-family: var(--display); letter-spacing: -.015em; margin: 0; }
svg.i { width: 16px; height: 16px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.8;
  stroke-linecap: round; stroke-linejoin: round; vertical-align: -3px; }

/* ---------- шапка ---------- */
.bar { position: sticky; top: 0; z-index: 10; background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: saturate(1.4) blur(10px); border-bottom: 1px solid var(--line); }
.bar-in { max-width: 1040px; margin: 0 auto; padding: 0 20px; height: 56px; display: flex; align-items: center; gap: 14px; }
.brand { display: flex; align-items: center; gap: 10px; font: 700 16px var(--display); color: var(--text); }
.brand:hover { text-decoration: none; }
.brand i { width: 26px; height: 26px; border-radius: 7px; background: var(--primary); display: grid; place-items: center;
  color: #fff; font: 700 14px var(--display); font-style: normal; }
.brand span { color: var(--faint); font: 500 13px var(--sans); }
.bar .sp { flex: 1; }
.me { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 13px; }
.av { width: 28px; height: 28px; border-radius: 50%; background: var(--primary); color: #fff; display: inline-grid;
  place-items: center; font: 600 11px var(--sans); flex: none; }
.av.soft { background: var(--primary-tint); color: var(--primary); }
.me form { margin: 0; }

/* ---------- раскладка ---------- */
main { max-width: 1040px; margin: 0 auto; padding: 24px 20px 64px; }
.head { display: flex; align-items: flex-start; gap: 14px; flex-wrap: wrap; margin-bottom: 4px; }
.head h1 { font-size: 24px; font-weight: 700; }
.head .sub { color: var(--faint); font-size: 13px; margin-top: 2px; }
.head .sp { flex: 1; }
.crumb { color: var(--faint); font-size: 13px; margin-bottom: 6px; display: inline-flex; gap: 6px; align-items: center; }
.tabs { display: flex; gap: 2px; margin: 18px 0 22px; border-bottom: 1px solid var(--line); overflow-x: auto;
  scrollbar-width: none; }
.tabs a { padding: 9px 12px; color: var(--muted); font-weight: 500; white-space: nowrap; border-bottom: 2px solid transparent;
  margin-bottom: -1px; display: inline-flex; gap: 7px; align-items: center; }
.tabs a:hover { color: var(--text); text-decoration: none; }
.tabs a.on { color: var(--text); border-color: var(--primary); }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); box-shadow: var(--shadow); }
.pad { padding: 20px; }
.stack > * + * { margin-top: 16px; }
.muted { color: var(--muted); }
.faint { color: var(--faint); font-size: 13px; }
.sec-title { display: flex; align-items: baseline; gap: 10px; margin: 28px 0 12px; }
.sec-title h2 { font-size: 16px; font-weight: 600; }
.sec-title .sp { flex: 1; }

/* ---------- метки ---------- */
.pill { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 999px; font-size: 12px;
  font-weight: 600; background: var(--hover); color: var(--muted); white-space: nowrap; }
.pill::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.pill.plain::before { display: none; }
.pill.good, .pill.s-sent { background: var(--green-tint); color: var(--green); }
.pill.warn, .pill.s-carded, .pill.s-drafted { background: var(--amber-tint); color: var(--amber); }
.pill.bad, .pill.s-failed { background: var(--red-tint); color: var(--red); }
.pill.s-skipped { background: var(--hover); color: var(--faint); }
.pill.brand { background: var(--primary-tint); color: var(--primary); }
.pill.live::before { animation: pulse 2s infinite; }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: .35; } }

/* ---------- кнопки и поля ---------- */
.btn { display: inline-flex; align-items: center; gap: 7px; border: 1px solid var(--line-strong); background: var(--surface);
  border-radius: 8px; padding: 8px 14px; cursor: pointer; font-weight: 500; color: var(--text); line-height: 1.3; }
.btn:hover { background: var(--bg); text-decoration: none; }
.btn.pri { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn.pri:hover { background: var(--primary-dark); border-color: var(--primary-dark); }
.btn.ghost { border-color: transparent; background: none; color: var(--muted); padding: 6px 8px; }
.btn.ghost:hover { background: var(--hover); color: var(--text); }
.btn.danger { color: var(--red); }
.btn.sm { padding: 5px 10px; font-size: 13px; }
.btn.block { width: 100%; justify-content: center; padding: 11px; }
form.inline { display: inline; margin: 0; }
.input, input:not([type=checkbox]), select, textarea { width: 100%; padding: 9px 12px; border: 1px solid var(--line-strong);
  border-radius: 8px; background: var(--surface); outline: none; transition: border-color .15s, box-shadow .15s; }
input:focus, select:focus, textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-tint); }
textarea { resize: vertical; min-height: 90px; }
.affix { position: relative; display: flex; align-items: center; }
.affix input { padding-right: 46px; }
.affix span { position: absolute; right: 12px; color: var(--faint); font-size: 13px; pointer-events: none; }

/* переключатель */
.switch { position: relative; display: inline-block; width: 40px; height: 22px; flex: none; }
.switch input { opacity: 0; width: 0; height: 0; position: absolute; }
.switch span { position: absolute; inset: 0; border-radius: 22px; background: var(--line-strong); transition: background .2s; cursor: pointer; }
.switch span::after { content: ""; position: absolute; width: 18px; height: 18px; left: 2px; top: 2px; border-radius: 50%;
  background: #fff; box-shadow: 0 1px 2px rgba(0, 0, 0, .2); transition: transform .2s; }
.switch input:checked + span { background: var(--primary); }
.switch input:checked + span::after { transform: translateX(18px); }
.switch input:focus-visible + span { box-shadow: 0 0 0 3px var(--primary-tint); }
.switch input:disabled + span { opacity: .5; cursor: default; }

.flash { display: flex; gap: 10px; align-items: center; padding: 11px 14px; border-radius: var(--r); margin-bottom: 18px; font-weight: 500; }
.flash.ok { background: var(--green-tint); color: var(--green); }
.flash.err { background: var(--red-tint); color: var(--red); }

/* ---------- сводка ---------- */
.status { display: grid; grid-template-columns: 1fr auto; gap: 18px; align-items: center; padding: 20px 22px;
  border-left: 4px solid var(--green); }
.status.warn { border-left-color: var(--amber); }
.status.bad { border-left-color: var(--red); }
.status h2 { font-size: 18px; display: flex; gap: 10px; align-items: center; }
.status p { margin: 6px 0 0; color: var(--muted); }
.status .acts { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.meters { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px; }
.meter { padding: 18px 20px; }
.meter .lbl { color: var(--muted); font-size: 13px; display: flex; justify-content: space-between; }
.meter .val { font: 700 28px var(--display); margin: 4px 0 10px; letter-spacing: -.02em; }
.meter .val small { font: 500 15px var(--sans); color: var(--faint); margin-left: 4px; letter-spacing: 0; }
.track { height: 6px; border-radius: 6px; background: var(--hover); overflow: hidden; }
.track b { display: block; height: 100%; border-radius: 6px; background: var(--primary); }
.track b.full { background: var(--amber); }
.kpis { display: grid; grid-template-columns: repeat(4, 1fr); }
.kpi { padding: 16px 20px; border-left: 1px solid var(--line); }
.kpi:first-child { border-left: 0; }
.kpi .val { font: 700 22px var(--display); }
.kpi .lbl { color: var(--muted); font-size: 13px; display: flex; gap: 6px; align-items: center; }

/* ---------- списки (лента, получатели, история) ---------- */
.list { padding: 0; }
.item { display: grid; grid-template-columns: 1fr auto; gap: 6px 16px; padding: 14px 20px; border-top: 1px solid var(--line); }
.item:first-child { border-top: 0; }
.item .t { font-weight: 600; color: var(--text); }
.item .meta { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; color: var(--faint); font-size: 13px; }
.item .why { color: var(--muted); font-size: 13px; grid-column: 1 / -1; }
.item .right { text-align: right; display: flex; flex-direction: column; align-items: flex-end; gap: 6px; }
.item details { grid-column: 1 / -1; }
details > summary { cursor: pointer; color: var(--primary); font-size: 13px; list-style: none; display: inline-flex; gap: 4px; align-items: center; }
details > summary::-webkit-details-marker { display: none; }
.draft { margin: 10px 0 0; padding: 12px 14px; background: var(--bg); border-radius: 8px; white-space: pre-wrap; font-size: 13.5px; }
.fb { display: grid; grid-template-columns: 180px 1fr auto; gap: 8px; margin-top: 10px; }
.fb textarea { min-height: 38px; height: 38px; }
.empty { padding: 40px 20px; text-align: center; color: var(--faint); }

.seg { display: inline-flex; padding: 3px; background: var(--hover); border-radius: 9px; gap: 2px; flex-wrap: wrap; }
.seg a { padding: 6px 12px; border-radius: 7px; color: var(--muted); font-weight: 500; font-size: 13px; display: inline-flex; gap: 6px; }
.seg a:hover { color: var(--text); text-decoration: none; }
.seg a.on { background: var(--surface); color: var(--text); box-shadow: var(--shadow), 0 0 0 1px var(--line); }
.seg a .n { color: var(--faint); font-weight: 400; }
.toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 14px; }
.toolbar .search { flex: 1 1 220px; display: flex; gap: 8px; }
.toolbar .search input { max-width: 320px; margin-left: auto; }

.person { display: flex; align-items: center; gap: 12px; }
.person .nm { font-weight: 600; }
.chk { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); }
.row-acts { display: flex; gap: 16px; align-items: center; flex-wrap: wrap; justify-content: flex-end; }
.steps { counter-reset: s; list-style: none; padding: 0; margin: 0 0 16px; display: grid; gap: 10px; }
.steps li { counter-increment: s; display: flex; gap: 12px; align-items: flex-start; color: var(--muted); }
.steps li::before { content: counter(s); width: 24px; height: 24px; border-radius: 50%; background: var(--primary-tint);
  color: var(--primary); font-weight: 600; font-size: 12px; display: grid; place-items: center; flex: none; }
.pend { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; padding: 12px 0; border-top: 1px solid var(--line); }
.pend input { width: 200px; }

.changes { margin: 8px 0 0; padding: 0; list-style: none; display: grid; gap: 4px; }
.changes li { font-size: 13.5px; }
.changes s { color: var(--faint); text-decoration: none; }
.changes b { font-weight: 600; }

table.simple { width: 100%; border-collapse: collapse; font-size: 13.5px; }
table.simple td, table.simple th { text-align: left; padding: 10px 20px; border-top: 1px solid var(--line); }
table.simple th { color: var(--faint); font-weight: 500; font-size: 12px; border-top: 0; }

/* ---------- настройки ---------- */
.group { display: grid; grid-template-columns: 260px 1fr; gap: 28px; padding: 24px 0; border-top: 1px solid var(--line); }
.group:first-of-type { border-top: 0; padding-top: 4px; }
.group .about h3 { font-size: 15px; font-weight: 600; }
.group .about p { color: var(--muted); font-size: 13px; margin: 6px 0 0; }
.group .fields { padding: 4px 20px; }
.fld { padding: 14px 0; border-top: 1px solid var(--line); }
.fld:first-child { border-top: 0; }
.fld label.l { display: block; font-weight: 600; margin-bottom: 6px; }
.fld .hint { color: var(--faint); font-size: 12.5px; margin: 6px 0 0; }
.fld .err { color: var(--red); font-size: 12.5px; margin: 6px 0 0; font-weight: 500; }
.fld.has-err input, .fld.has-err select, .fld.has-err textarea { border-color: var(--red); }
.fld.toggle { display: grid; grid-template-columns: 1fr auto; gap: 12px; align-items: center; }
.fld.toggle label.l { margin: 0; }
.fld.toggle .hint { grid-column: 1 / -1; margin-top: -4px; }
.w-sm { max-width: 180px; }
.savebar { position: sticky; bottom: 16px; margin-top: 8px; display: flex; gap: 12px; align-items: center; justify-content: flex-end;
  padding: 12px 16px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r);
  box-shadow: 0 8px 24px rgba(10, 15, 30, .08); }
.savebar .faint { margin-right: auto; }
.ro { padding: 14px 20px; border-top: 1px solid var(--line); }
.ro:first-child { border-top: 0; }
.ro b { font-weight: 600; display: block; margin-bottom: 4px; }
.ro pre { white-space: pre-wrap; font: 13px/1.5 var(--sans); color: var(--muted); margin: 0; max-height: 160px; overflow: auto; }

/* ---------- кабинеты и вход ---------- */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 14px; }
.tile { display: flex; flex-direction: column; gap: 12px; padding: 18px 20px; color: var(--text); transition: border-color .15s, box-shadow .15s; }
.tile:hover { text-decoration: none; border-color: var(--line-strong); box-shadow: 0 6px 18px rgba(10, 15, 30, .07); }
.tile .top { display: flex; justify-content: space-between; gap: 10px; align-items: flex-start; }
.tile h3 { font-size: 16px; }
.auth { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.auth .card { width: 100%; max-width: 400px; padding: 32px 28px; }
.auth .brand { justify-content: center; margin-bottom: 22px; font-size: 18px; }
.auth h1 { font-size: 20px; text-align: center; }
.auth .lead { text-align: center; color: var(--muted); margin: 8px 0 22px; }
.auth label { font-weight: 600; display: block; margin-bottom: 6px; }
.auth .code { text-align: center; font: 600 24px var(--display); letter-spacing: .4em; }
.auth .foot { text-align: center; color: var(--faint); font-size: 13px; margin-top: 18px; }

@media (max-width: 760px) {
  main { padding: 18px 14px 56px; }
  .bar-in { padding: 0 14px; }
  .brand span, .me .nm { display: none; }
  .head h1 { font-size: 20px; }
  .tabs a { padding: 9px 10px; }
  .tabs a svg.i { display: none; }
  .status { grid-template-columns: 1fr; }
  .status .acts { justify-content: flex-start; }
  .meters { grid-template-columns: 1fr; }
  .kpis { grid-template-columns: repeat(2, 1fr); }
  .kpi:nth-child(3) { border-left: 0; }
  .kpi:nth-child(n+3) { border-top: 1px solid var(--line); }
  .group { grid-template-columns: 1fr; gap: 10px; }
  .item { grid-template-columns: 1fr; }
  .item .right { align-items: flex-start; text-align: left; flex-direction: row; }
  .fb { grid-template-columns: 1fr; }
  .toolbar .search input { max-width: none; }
  .w-sm { max-width: none; }
  table.simple td, table.simple th { padding: 10px 14px; }
}

/* ---------- агент-мордочка ---------- */
.bot { position: relative; display: inline-block; flex: none; }
.bot svg { display: block; overflow: visible; }
.bot .head { fill: var(--c); }
.bot .ear { fill: var(--c); filter: brightness(.82); }
.bot .stem { stroke: var(--c); stroke-width: 2.6; stroke-linecap: round; }
.bot .bulb { fill: #C9CFD9; }
.bot .visor { fill: #0F1A2E; }
.bot .eyes rect { fill: #7CF3C4; }
.bot .eyes path { stroke: #9FB1CF; stroke-width: 2.4; fill: none; stroke-linecap: round; }
.bot .eyes.cross path { stroke: #FF8A7A; }
.bot .mouth { stroke: #fff; stroke-width: 2.4; fill: none; stroke-linecap: round; opacity: .9; }
.bot .eyes.shut, .bot .eyes.cross, .bot .mouth.flat { display: none; }
.bot .zz { display: none; position: absolute; right: -6px; top: -4px; font: 700 13px var(--display); color: var(--faint);
  font-style: normal; }
.bot .zz b { font-size: 10px; margin-left: 1px; vertical-align: 6px; }

/* работает: моргает, огонёк мигает, покачивается */
.bot.on svg { animation: bob 3.2s ease-in-out infinite; }
.bot.on .bulb { fill: #22C55E; animation: glow 1.6s ease-in-out infinite; }
.bot.on .eyes.open rect { transform-box: fill-box; transform-origin: center; animation: blink 4.5s infinite; }
@keyframes bob { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-2px); } }
@keyframes glow { 0%, 100% { opacity: 1; } 50% { opacity: .35; } }
@keyframes blink { 0%, 93%, 100% { transform: scaleY(1); } 95% { transform: scaleY(.1); } }

/* отдыхает (вне рабочих часов) и пауза: глаза закрыты, z-z */
.bot.rest .eyes.open, .bot.paused .eyes.open, .bot.off .eyes.open { display: none; }
.bot.rest .eyes.shut, .bot.paused .eyes.shut, .bot.off .eyes.shut { display: inline; }
.bot.rest .zz, .bot.paused .zz { display: block; animation: zz 2.4s ease-in-out infinite; }
.bot.rest .bulb { fill: #F5B544; }
@keyframes zz { 0% { opacity: 0; transform: translate(0, 4px); } 40% { opacity: 1; } 100% { opacity: 0; transform: translate(4px, -6px); } }
.bot.paused, .bot.off { filter: grayscale(1); opacity: .65; }
.bot.paused .mouth.smile, .bot.off .mouth.smile, .bot.bad .mouth.smile { display: none; }
.bot.paused .mouth.flat, .bot.off .mouth.flat, .bot.bad .mouth.flat { display: inline; }

/* нужна помощь */
.bot.bad .eyes.open { display: none; }
.bot.bad .eyes.cross { display: inline; }
.bot.bad .bulb { fill: #EF4444; animation: glow .9s ease-in-out infinite; }
.bot.bad svg { animation: shake 3s ease-in-out infinite; }
@keyframes shake { 0%, 90%, 100% { transform: rotate(0); } 93% { transform: rotate(-4deg); } 96% { transform: rotate(4deg); } }
@media (prefers-reduced-motion: reduce) { .bot * , .bot svg { animation: none !important; } }

.state-line { display: inline-flex; align-items: center; gap: 7px; font-size: 13px; font-weight: 600; color: var(--muted); }
.state-line::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--faint); }
.state-line.on { color: var(--green); }
.state-line.on::before { background: #22C55E; box-shadow: 0 0 0 3px #22C55E33; animation: glow 1.6s infinite; }
.state-line.rest { color: var(--amber); }
.state-line.rest::before { background: #F5B544; }
.state-line.bad { color: var(--red); }
.state-line.bad::before { background: #EF4444; }

/* карточка агента в списке */
.agent { display: flex; flex-direction: column; gap: 16px; padding: 20px; color: var(--text); position: relative;
  transition: border-color .15s, box-shadow .15s, transform .15s; }
.agent:hover { text-decoration: none; border-color: var(--line-strong); box-shadow: 0 8px 22px rgba(10, 15, 30, .08); transform: translateY(-1px); }
.agent .who { display: grid; grid-template-columns: auto 1fr; gap: 14px; align-items: center; }
.agent .nm { font: 700 17px var(--display); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.agent .niche { color: var(--muted); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-height: 19px; }
.agent .nums { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; border-top: 1px solid var(--line); padding-top: 14px; }
.agent .nums b { display: block; font: 700 17px var(--display); }
.agent .nums span { color: var(--faint); font-size: 12px; }
.agent.paused, .agent.off { background: #F1F3F6; }
.agent.paused .nm, .agent.paused .nums b, .agent.off .nm { color: var(--muted); }
.agent.paused .track b { background: var(--faint); }
.agent.bad { border-color: #F3C2BA; }
.agent.on::after { content: ""; position: absolute; inset: -1px; border-radius: var(--r); pointer-events: none;
  box-shadow: inset 0 3px 0 #22C55E; }

/* шапка кабинета */
.head .who { display: flex; gap: 16px; align-items: center; }
.head .who .sub { margin-top: 4px; }
.agent .state-line { white-space: nowrap; max-width: 100%; overflow: hidden; text-overflow: ellipsis; margin-top: 4px; }
