:root {
  color-scheme: dark;
  --bg: #05060f;
  --text: #e6e7f2;
  --muted: rgba(220, 222, 255, .5);
  --line: rgba(255, 255, 255, .08);
  --glass: rgba(255, 255, 255, .035);
  --glass-strong: rgba(14, 15, 30, .86);
  --accent: #8b7fd1;
  --accent2: #5b9cc4;
  --work: #86c9a0;
  --ok: #8fb0d9;
  --wait: #d6b56e;
  --bad: #d98b8b;
  --off: #8a8fa3;
  --radius: 18px;
}
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body { font: 14px/1.45 Inter, system-ui, sans-serif; background: var(--bg); color: var(--text); overflow-x: hidden; }
button, input, select, textarea { font: inherit; color: inherit; }
h2, h3 { margin: 0; }

/* ---- фон «Аврора» ---- */
.aurora { position: fixed; inset: -20%; z-index: 0; filter: blur(130px) saturate(90%); opacity: .32; pointer-events: none; }
.aurora i { position: absolute; border-radius: 50%; mix-blend-mode: screen; }
.aurora .b1 { width: 55vw; height: 55vw; background: #3b2a7a; left: 5%; top: 0; animation: drift1 40s ease-in-out infinite alternate; }
.aurora .b2 { width: 50vw; height: 50vw; background: #11405e; right: 0; top: 10%; animation: drift2 48s ease-in-out infinite alternate; }
.aurora .b3 { width: 45vw; height: 45vw; background: #134e3f; left: 30%; bottom: -5%; animation: drift3 56s ease-in-out infinite alternate; }
@keyframes drift1 { to { transform: translate(18vw, 12vh) scale(1.2); } }
@keyframes drift2 { to { transform: translate(-20vw, 18vh) scale(.85); } }
@keyframes drift3 { to { transform: translate(-12vw, -20vh) scale(1.15); } }
.grain { position: fixed; inset: 0; z-index: 1; opacity: .05; pointer-events: none;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='160' height='160'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='3'/></filter><rect width='100%' height='100%' filter='url(%23n)'/></svg>"); }
.app { position: relative; z-index: 2; max-width: 1320px; margin: 0 auto; padding: 22px 26px 60px; }

/* ---- стекло и подсветка рамки ---- */
.glass { background: var(--glass); border: 1px solid var(--line); border-radius: var(--radius);
  backdrop-filter: blur(18px) saturate(130%); -webkit-backdrop-filter: blur(18px) saturate(130%);
  box-shadow: 0 20px 60px rgba(0, 0, 0, .35), inset 0 1px 0 rgba(255, 255, 255, .06); }
.bglow { position: relative; }
.bglow::before { content: ""; position: absolute; inset: 0; border-radius: inherit; padding: 1px; pointer-events: none; opacity: 0; transition: opacity .3s;
  background: radial-gradient(220px circle at var(--mx, 50%) var(--my, 50%), rgba(167, 139, 250, .7), rgba(56, 189, 248, .35) 40%, transparent 70%);
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0); -webkit-mask-composite: xor; mask-composite: exclude; }
.bglow:hover::before { opacity: 1; }
.muted { color: var(--muted); font-size: 12px; }
.label { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .08em; }

/* ---- кнопки и поля ---- */
.btn { padding: 9px 14px; border-radius: 11px; cursor: pointer; background: rgba(255, 255, 255, .06); border: 1px solid rgba(255, 255, 255, .12);
  font-weight: 600; font-size: 13px; white-space: nowrap; transition: background .2s, transform .2s, border-color .2s; }
.btn:hover { background: rgba(255, 255, 255, .12); transform: translateY(-1px); }
.btn.sm { padding: 6px 10px; font-size: 12px; border-radius: 9px; }
.btn.go { border-color: rgba(134, 201, 160, .35); }
.btn.danger { color: #f0c3c3; border-color: rgba(217, 139, 139, .3); }
.star { position: relative; display: inline-flex; padding: 1px; border: 0; border-radius: 12px; overflow: hidden; background: transparent; cursor: pointer; }
.star::before { content: ""; position: absolute; inset: -150%;
  background: conic-gradient(from 0deg, transparent 0 70%, rgba(167, 139, 250, .6) 80%, rgba(56, 189, 248, .5) 90%, transparent); animation: spin 5s linear infinite; }
.star > span { position: relative; z-index: 1; padding: 9px 16px; border-radius: 11px; background: #110f24; font-weight: 700; font-size: 13px; color: #fff; white-space: nowrap; }
@keyframes spin { to { transform: rotate(360deg); } }
input, select, textarea { background: rgba(0, 0, 0, .25); border: 1px solid rgba(255, 255, 255, .12); border-radius: 10px; padding: 8px 11px; outline: none; }
input:focus, select:focus, textarea:focus { border-color: rgba(167, 139, 250, .55); }
input.num { width: 92px; }
input.wide, textarea { width: 100%; }
textarea { font-family: "JetBrains Mono", monospace; font-size: 12px; }
input[type="checkbox"] { accent-color: var(--accent); width: 15px; height: 15px; padding: 0; }
input[type="range"] { accent-color: var(--accent); padding: 0; vertical-align: middle; }
select option { background: #11121f; }

/* ---- шапка ---- */
.top { display: flex; align-items: center; gap: 14px; margin-bottom: 18px; flex-wrap: wrap; }
.logo { width: 38px; height: 38px; border-radius: 11px; background: conic-gradient(from 200deg, #8b7fd1, #5b9cc4, #5fb08a, #8b7fd1); opacity: .9; flex: none; }
.shiny { font: 700 24px Unbounded, sans-serif; letter-spacing: -.4px; margin: 0;
  background: linear-gradient(110deg, #c9cbe0 40%, #eceef8 50%, #c9cbe0 60%); background-size: 250% 100%;
  -webkit-background-clip: text; background-clip: text; color: transparent; animation: shine 7s linear infinite; }
@keyframes shine { from { background-position: 150% 0; } to { background-position: -100% 0; } }
.tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-left: 10px; }
.tab { display: flex; align-items: center; gap: 8px; padding: 8px 14px; border-radius: 11px; font-weight: 600; font-size: 13px;
  color: rgba(230, 231, 242, .6); cursor: pointer; background: transparent; border: 1px solid transparent; transition: .2s; }
.tab:hover { color: var(--text); background: rgba(255, 255, 255, .04); }
.tab.on { color: #fff; background: rgba(255, 255, 255, .06); border-color: rgba(255, 255, 255, .1); }
.tab small { font-weight: 500; color: var(--muted); }
.tab.alert small { color: var(--bad); }
.tab.add { color: var(--muted); }
.live { position: relative; display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--work); flex: none; }
.live::after { content: ""; position: absolute; inset: 0; border-radius: 50%; background: var(--work); animation: ping 2s ease-out infinite; }
@keyframes ping { to { transform: scale(3); opacity: 0; } }
.link { font-size: 11px; padding: 3px 9px; border-radius: 999px; }
.link.on { color: var(--work); background: rgba(134, 201, 160, .1); }
.link.off { color: var(--bad); background: rgba(217, 139, 139, .1); }
.top-actions { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; }

/* ---- бенто ---- */
.bento { display: grid; grid-template-columns: 1.4fr 1fr 1fr 1.2fr; gap: 14px; }
.bento > * { min-width: 0; }
#anarchy { max-width: 100%; min-width: 0; text-overflow: ellipsis; }
#cycle-body { overflow-x: auto; }
.tile { padding: 18px; min-height: 172px; overflow: hidden; }
.big { font: 700 38px Unbounded, sans-serif; letter-spacing: -1px; margin-top: 8px; line-height: 1.1; }
.big.sm { font-size: 30px; margin: 0; }
.big.bad { color: var(--bad); }
.delta { font-size: 12px; color: var(--work); margin-top: 2px; }
.spark { display: block; width: 100%; height: 56px; margin-top: 10px; }
.ring-wrap { display: flex; align-items: center; gap: 16px; margin-top: 10px; }
.ring-bg { stroke: rgba(255, 255, 255, .07); }
#ring { transition: stroke-dashoffset 1.2s cubic-bezier(.2, .9, .2, 1); }
.attn { list-style: none; margin: 8px 0 0; padding: 0; display: grid; gap: 4px; font-size: 12.5px; color: rgba(230, 231, 242, .75); }
.attn li { overflow-wrap: anywhere; }
.attn li::before { content: "•"; color: var(--bad); margin-right: 6px; }
.attn li.calm { color: var(--muted); }
.attn li.calm::before { content: none; }
.feed { grid-column: 4; grid-row: 1 / span 2; display: flex; flex-direction: column; padding: 18px; min-height: 0; }
.feed-list { list-style: none; margin: 10px 0 0; padding: 0; display: flex; flex-direction: column; gap: 8px; overflow: hidden; flex: 1; max-height: 660px;
  -webkit-mask: linear-gradient(#000 82%, transparent); mask: linear-gradient(#000 82%, transparent); }
.ev { display: flex; gap: 10px; align-items: flex-start; padding: 9px 10px; border-radius: 12px; background: rgba(255, 255, 255, .03); font-size: 13px; }
.ev.new { animation: evIn .5s cubic-bezier(.2, .9, .3, 1.2); }
.ev .ico { width: 18px; text-align: center; flex: none; }
.ev .txt { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.ev .t { font: 500 11px "JetBrains Mono", monospace; color: rgba(220, 222, 255, .4); flex: none; padding-top: 2px; }
@keyframes evIn { from { opacity: 0; transform: translateY(-10px) scale(.97); } }

/* ---- панель фермы и боты ---- */
.panel { grid-column: 1 / span 3; padding: 16px; container-type: inline-size; }
.farm-bar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 12px; }
.farm-bar h2 { font: 700 18px Unbounded, sans-serif; margin-right: 6px; }
.menu { position: relative; }
.menu > summary { list-style: none; }
.menu > summary::-webkit-details-marker { display: none; }
.menu-list { position: absolute; right: 0; top: calc(100% + 6px); z-index: 20; display: grid; padding: 6px; min-width: 180px; border-radius: 14px; background: var(--glass-strong); }
.menu-list button { text-align: left; padding: 8px 10px; border-radius: 9px; background: transparent; border: 0; cursor: pointer; }
.menu-list button:hover { background: rgba(255, 255, 255, .07); }
.danger-text { color: #f0c3c3; }
.pick-all { margin-left: auto; display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--muted); cursor: pointer; }
.bot-row { display: grid; grid-template-columns: 22px 38px minmax(120px, 1.1fr) minmax(150px, 1.4fr) minmax(140px, 1.5fr) auto; gap: 14px;
  align-items: center; padding: 10px 12px; border-radius: 13px; transition: background .2s; }
.bot-row:hover { background: rgba(255, 255, 255, .04); }
.bot-row.head-row { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .08em; padding-top: 2px; padding-bottom: 2px; }
.bot-row.head-row:hover { background: none; }
.who b { display: block; }
.who .nick { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.head { width: 34px; height: 34px; border-radius: 9px; overflow: hidden; display: grid; place-items: center; flex: none;
  background: rgba(255, 255, 255, .06); box-shadow: 0 0 0 1px rgba(255, 255, 255, .1); font-size: 18px; }
.head img { width: 100%; height: 100%; display: block; image-rendering: pixelated; }
.pill { display: inline-flex; align-items: center; gap: 7px; padding: 4px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; }
.pill > i { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.p-work { color: var(--work); background: rgba(134, 201, 160, .09); }
.p-ok { color: var(--ok); background: rgba(143, 176, 217, .09); }
.p-wait { color: var(--wait); background: rgba(214, 181, 110, .09); }
.p-bad { color: var(--bad); background: rgba(217, 139, 139, .09); }
.p-off { color: var(--off); background: rgba(138, 143, 163, .1); }
.sub { font-size: 12px; margin-top: 3px; color: var(--muted); overflow-wrap: anywhere; }
.sub.warn { color: var(--wait); }
.sub.bad { color: var(--bad); }
.meter { height: 5px; border-radius: 99px; background: rgba(255, 255, 255, .07); overflow: hidden; margin-bottom: 4px; }
.meter > b { display: block; height: 100%; border-radius: 99px; background: linear-gradient(90deg, #7c74b8, #5d8bab); transition: width .6s; }
.meter.low > b { background: linear-gradient(90deg, #b8836f, #c99a6d); }
.actions { display: flex; gap: 6px; }

/* ---- блоки под бенто ---- */
.card-block { padding: 18px 20px; margin-top: 14px; }
.card-block h2 { font: 700 16px Unbounded, sans-serif; margin-bottom: 12px; }
details.card-block > summary { cursor: pointer; list-style: none; }
details.card-block > summary::-webkit-details-marker { display: none; }
details.card-block > summary h2 { display: inline-block; margin-bottom: 0; }
details.card-block[open] > summary h2 { margin-bottom: 12px; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin: 8px 0; }
.fields { display: grid; gap: 8px; max-width: 760px; }
.field { display: grid; grid-template-columns: 280px 100px 1fr; gap: 8px; align-items: center; }
.hint { color: var(--muted); font-size: 12px; }
table.steps { width: 100%; border-collapse: collapse; margin: 6px 0 10px; }
table.steps th { text-align: left; font-weight: 500; font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; padding: 6px; }
table.steps td { padding: 4px 6px; border-top: 1px solid var(--line); }
table.steps td input:not(.num), table.steps td select { width: 100%; }
.steps .actions .btn { padding: 5px 9px; }

/* ---- выдвижная панель бота ---- */
.drawer { position: fixed; inset: 0; z-index: 50; pointer-events: none; }
.drawer-shade { position: absolute; inset: 0; background: rgba(3, 4, 10, .55); opacity: 0; transition: opacity .25s; }
.drawer-panel { position: absolute; top: 12px; right: 12px; bottom: 12px; width: min(560px, calc(100vw - 24px)); overflow-y: auto; padding: 20px;
  background: var(--glass-strong); transform: translateX(calc(100% + 24px)); transition: transform .35s cubic-bezier(.2, .9, .2, 1); }
.drawer.open { pointer-events: auto; }
.drawer.open .drawer-shade { opacity: 1; }
.drawer.open .drawer-panel { transform: none; }
.drawer-head { display: flex; align-items: center; gap: 12px; }
.drawer-head h2 { font: 700 18px Unbounded, sans-serif; }
.drawer-head .x { margin-left: auto; align-self: flex-start; }
.drawer-status { margin-top: 4px; }
.drawer-body section { margin-top: 20px; }
.drawer-body h3 { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .08em; font-weight: 600; margin-bottom: 8px; }
.drawer-body form { display: grid; gap: 8px; }
.drawer-body label { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.log { height: 260px; overflow: auto; margin: 0; padding: 10px 12px; border-radius: 12px; background: rgba(0, 0, 0, .35); border: 1px solid var(--line);
  font: 12px/1.5 "JetBrains Mono", monospace; color: rgba(220, 222, 255, .75); white-space: pre-wrap; overflow-wrap: anywhere; }
.say { display: flex !important; gap: 8px; margin-top: 8px; }

/* ---- уведомление ---- */
.toast { position: fixed; right: 16px; bottom: 16px; z-index: 80; max-width: 420px; padding: 11px 15px; border-radius: 12px; font-weight: 600; font-size: 13px;
  background: rgba(30, 60, 45, .92); border: 1px solid rgba(134, 201, 160, .3); opacity: 0; transform: translateY(8px); transition: .2s; pointer-events: none; }
.toast.show { opacity: 1; transform: none; }
.toast.bad { background: rgba(70, 30, 34, .92); border-color: rgba(217, 139, 139, .35); }

/* ---- вход ---- */
.login { position: relative; z-index: 2; max-width: 360px; margin: 18vh auto 0; padding: 28px; display: grid; gap: 14px; }
.login .shiny { font-size: 22px; }

/* ---- меньше движения ---- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* ---- узкие экраны ---- */
@media (max-width: 1100px) {
  .bento { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .feed { grid-column: auto; grid-row: auto; }
  .feed-list { max-height: 320px; }
  .panel { grid-column: 1 / -1; }
}
@media (max-width: 700px) {
  .app { padding: 14px 12px 40px; }
  .bento { grid-template-columns: minmax(0, 1fr); }
  .tabs { margin-left: 0; }
  .top-actions { margin-left: 0; }
  .pick-all { margin-left: 0; }
  .field { grid-template-columns: 1fr 92px; }
  .field .hint { grid-column: 1 / -1; }
}

/* ---- таблица ботов по ширине панели ---- */
@container (max-width: 900px) {
  .bot-row { grid-template-columns: 22px 38px minmax(0, 1fr) minmax(0, 1.3fr) minmax(0, 1.2fr); row-gap: 8px; }
  .bot-row .actions { grid-column: 3 / -1; flex-wrap: wrap; }
  .bot-row.head-row > :last-child { display: none; }
}
@container (max-width: 640px) {
  .bot-row.head-row { display: none; }
  .bot-row { grid-template-columns: 22px 38px 1fr; grid-template-areas: "c h w" "s s s" "m m m" "a a a"; background: rgba(255, 255, 255, .03); margin-bottom: 8px; }
  .bot-row .check { grid-area: c; }
  .bot-row .head-cell { grid-area: h; }
  .bot-row .who { grid-area: w; }
  .bot-row .status { grid-area: s; }
  .bot-row .metrics { grid-area: m; }
  .bot-row .actions { grid-area: a; flex-wrap: wrap; }
}
