:root{
  --bg:#f5f7fb; --panel:#fff; --line:#e5eaf1; --ink:#0f172a;
  --muted:#64748b; --blue:#2563eb; --blue2:#1d4ed8;
  --sb:#0f172a; --sb2:#111c33; --sb-ink:#94a3b8;
}
*{box-sizing:border-box}
body{background:var(--bg);color:var(--ink);font-family:'Inter',system-ui,sans-serif;margin:0}
a{color:inherit;text-decoration:none}
a:hover{text-decoration:none}
::-webkit-scrollbar{width:6px;height:6px}
::-webkit-scrollbar-thumb{background:#cbd5e1;border-radius:4px}
::-webkit-scrollbar-track{background:transparent}

/* ---------- каркас ---------- */
.sidebar{position:fixed;left:0;top:0;bottom:0;width:236px;z-index:40;
  background:linear-gradient(180deg,var(--sb) 0%,var(--sb2) 100%);
  color:#e2e8f0;display:flex;flex-direction:column;
  transition:width .18s ease,transform .18s ease;overflow:hidden}
.main{margin-left:236px;min-height:100vh;transition:margin-left .18s ease}
.wrap{padding:24px 28px 64px;max-width:1560px;margin:0 auto}
body.sb-collapsed .sidebar{width:74px}
body.sb-collapsed .main{margin-left:74px}
.sb-hide{transition:opacity .12s}
body.sb-collapsed .sb-hide{display:none!important}

.sb-head{height:66px;display:flex;align-items:center;justify-content:space-between;
  padding:0 14px 0 18px;border-bottom:1px solid rgba(255,255,255,.07);flex:0 0 auto}
.sb-brand{display:flex;align-items:center;gap:10px;min-width:0}
.sb-logo{width:34px;height:34px;border-radius:10px;display:grid;place-items:center;
  background:linear-gradient(135deg,#3b82f6,#8b5cf6);color:#fff;font-weight:800;font-size:17px;
  box-shadow:0 6px 16px rgba(59,130,246,.35);flex:0 0 auto}
.sb-brand b{display:block;font-size:14.5px;letter-spacing:-.01em;color:#fff}
.sb-brand small{display:block;font-size:10px;color:#64748b;margin-top:1px;white-space:nowrap}
.sb-toggle{width:26px;height:26px;border-radius:7px;border:1px solid rgba(255,255,255,.1);
  background:rgba(255,255,255,.04);color:#94a3b8;cursor:pointer;font-size:17px;line-height:1;
  display:none;place-items:center;flex:0 0 auto}
.sb-toggle:hover{background:rgba(255,255,255,.1);color:#fff}
body.sb-collapsed .sb-toggle{transform:rotate(180deg)}
.sb-scroll{flex:1;overflow-y:auto;overflow-x:hidden;padding:10px 0 6px}
.sb-section{margin-bottom:4px}
.sb-title{font-size:9.5px;letter-spacing:.12em;text-transform:uppercase;color:#475569;
  font-weight:700;padding:10px 22px 5px}
.si{display:flex;align-items:center;gap:10px;margin:2px 10px;padding:9px 12px;
  border-radius:9px;color:var(--sb-ink);font-size:13.5px;font-weight:500;
  transition:background .14s,color .14s;white-space:nowrap}
.si svg{flex:0 0 auto;opacity:.9}
.si:hover{background:rgba(255,255,255,.06);color:#e2e8f0}
.si.active{background:linear-gradient(90deg,rgba(59,130,246,.95),rgba(99,102,241,.85));
  color:#fff;box-shadow:0 6px 16px rgba(37,99,235,.28)}
.si.active svg{opacity:1}
.sb-count{margin-left:auto;background:rgba(255,255,255,.14);color:#dbeafe;font-size:10.5px;
  padding:1px 7px;border-radius:99px;font-weight:700}
body.sb-collapsed .si{justify-content:center;padding:11px 0;margin:3px 12px}
body.sb-collapsed .sb-head{justify-content:center;padding:0}
body.sb-collapsed .sb-brand{display:none}
body.sb-collapsed .sb-title{display:none}
body.sb-collapsed .sb-toggle{display:grid}
.sb-foot{border-top:1px solid rgba(255,255,255,.07);padding:10px;flex:0 0 auto}
.bot-mini{display:flex;align-items:center;gap:9px;padding:8px 10px;border-radius:9px;
  background:rgba(255,255,255,.04);margin-bottom:8px;min-width:0}
.bot-mini:hover{background:rgba(255,255,255,.08)}
.bot-mini b{display:block;font-size:11.5px;color:#e2e8f0;white-space:nowrap}
.bot-mini small{display:block;font-size:10px;color:#64748b;margin-top:1px;white-space:nowrap}
body.sb-collapsed .bot-mini{justify-content:center;padding:9px 0}
.bot-dot{width:8px;height:8px;border-radius:50%;background:#64748b;flex:0 0 auto;
  box-shadow:0 0 0 3px rgba(100,116,139,.15)}
.bot-dot.running{background:#22c55e;box-shadow:0 0 0 3px rgba(34,197,94,.18)}
.bot-dot.paused{background:#f59e0b;box-shadow:0 0 0 3px rgba(245,158,11,.18)}
.bot-dot.stopped{background:#64748b}
.sb-user{display:flex;align-items:center;gap:9px;padding:6px 8px;min-width:0}
.avatar{width:30px;height:30px;border-radius:50%;display:grid;place-items:center;
  background:linear-gradient(135deg,#334155,#475569);color:#e2e8f0;font-size:12px;font-weight:700;flex:0 0 auto}
.sb-user b{display:block;font-size:12px;color:#cbd5e1;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.linkbtn{background:none;border:0;padding:0;cursor:pointer;font-family:inherit;
  font-size:10.5px;color:#64748b;margin-top:1px}
.linkbtn:hover{color:#f87171}
body.sb-collapsed .sb-user{justify-content:center}

/* ---------- мобильная шапка ---------- */
.mtop{display:none;align-items:center;gap:12px;padding:9px 14px;background:#fff;
  border-bottom:1px solid var(--line);position:sticky;top:0;z-index:35}
.mtop button{width:38px;height:38px;border-radius:9px;border:1px solid var(--line);
  background:#fff;font-size:17px;cursor:pointer;color:#334155}
.mtop-brand{font-weight:700;font-size:14.5px;letter-spacing:-.01em}
.mtop-bot{margin-left:auto;display:flex;align-items:center;gap:6px;font-size:11.5px;color:#64748b}
.mtop-bot i{width:7px;height:7px;border-radius:50%;background:#64748b}
.mtop-bot.running i{background:#22c55e}
.mtop-bot.paused i{background:#f59e0b}
.veil{display:none;position:fixed;inset:0;background:rgba(15,23,42,.5);z-index:38}

/* ---------- заголовки и блоки ---------- */
.page-hd{display:flex;flex-wrap:wrap;align-items:flex-end;justify-content:space-between;
  gap:14px;margin-bottom:20px}
.page-hd h1{font-size:22px;font-weight:700;letter-spacing:-.025em;margin:0;line-height:1.2}
.page-hd .sub{font-size:13px;color:var(--muted);margin-top:4px}
.hd-actions{display:flex;gap:8px;flex-wrap:wrap}
.card{background:var(--panel);border:1px solid var(--line);border-radius:14px;
  box-shadow:0 1px 2px rgba(15,23,42,.03)}
.pad{padding:18px 20px}
.sec-hd{display:flex;align-items:center;justify-content:space-between;gap:10px;
  font-size:14px;font-weight:600;margin-bottom:12px}
.mini-link{font-size:11.5px;color:#2563eb;font-weight:600}
.mini-link:hover{text-decoration:underline}
.stat{position:relative;background:var(--panel);border:1px solid var(--line);border-radius:14px;
  padding:16px 18px;overflow:hidden;transition:transform .14s,box-shadow .14s}
.stat:hover{transform:translateY(-1px);box-shadow:0 10px 24px rgba(15,23,42,.06)}
.stat:before{content:'';position:absolute;left:0;top:0;bottom:0;width:3px;background:#3b82f6}
.stat:nth-child(2):before{background:#8b5cf6}
.stat:nth-child(3):before{background:#f59e0b}
.stat:nth-child(4):before{background:#10b981}
.stat b{display:block;font-size:28px;font-weight:700;color:var(--ink);line-height:1.15;
  letter-spacing:-.03em}
.stat span{font-size:11.5px;color:var(--muted);display:block;margin-top:3px}
.stat.warn:before{background:#ef4444}
.stat.warn b{color:#dc2626}

/* ---------- таблицы ---------- */
table{width:100%;border-collapse:collapse;font-size:13.5px}
th,td{padding:10px 14px;text-align:left;border-bottom:1px solid #eef2f7;vertical-align:middle}
th{color:#64748b;font-weight:600;font-size:10.5px;text-transform:uppercase;letter-spacing:.06em;
  background:#f8fafc;position:sticky;top:0;z-index:1}
tr.rw:hover td{background:#f8fafc;cursor:pointer}
tr:last-child td{border-bottom:0}
td{color:#1e293b}

/* ---------- формы ---------- */
.ed{width:100%;background:#fff;border:1px solid #d7dee9;border-radius:9px;padding:8px 10px;
  font-size:13px;color:var(--ink);font-family:inherit;transition:border .14s,box-shadow .14s}
.ed:focus{outline:none;box-shadow:0 0 0 3px rgba(59,130,246,.18);border-color:#60a5fa}
.lbl{font-size:10.5px;font-weight:600;color:var(--muted);margin-bottom:4px;display:block;
  text-transform:uppercase;letter-spacing:.05em}
select.ed{padding:8px 8px}
textarea.ed{min-height:70px;resize:vertical}
.tab{padding:7px 14px;border-radius:8px;font-size:12.5px;font-weight:600;cursor:pointer;
  border:0;background:transparent;color:#64748b;font-family:inherit}
.tab.on{background:#eff6ff;color:#1d4ed8;box-shadow:inset 0 0 0 1px #bfdbfe}
.tab:not(.on):hover{background:#f1f5f9;color:#334155}

/* ---------- метки ---------- */
.chip{display:inline-block;background:#f1f5f9;color:#475569;font-size:11px;
  font-family:'JetBrains Mono',monospace;padding:2px 8px;border-radius:6px;margin:2px}
.badge{display:inline-block;padding:3px 9px;border-radius:99px;font-size:11px;font-weight:600;
  background:#f1f5f9;color:#475569;white-space:nowrap}
.badge.g{background:#dcfce7;color:#166534}
.badge.y{background:#fef3c7;color:#92400e}
.badge.r{background:#fee2e2;color:#991b1b}
.badge.b{background:#dbeafe;color:#1e40af}

/* ---------- кнопки ---------- */
.btn{display:inline-flex;align-items:center;justify-content:center;gap:6px;padding:9px 15px;
  border-radius:9px;font-size:13px;font-weight:600;cursor:pointer;border:1px solid transparent;
  font-family:inherit;transition:background .14s,transform .1s,box-shadow .14s;white-space:nowrap}
.btn:active{transform:translateY(1px)}
.btn.p{background:linear-gradient(180deg,#3b82f6,#2563eb);color:#fff;
  box-shadow:0 4px 12px rgba(37,99,235,.25)}
.btn.p:hover{background:linear-gradient(180deg,#2563eb,#1d4ed8)}
.btn.s{background:#fff;border-color:#d7dee9;color:#475569}
.btn.s:hover{background:#f8fafc;border-color:#cbd5e1}
.btn.d{background:#fff;border-color:#fecaca;color:#dc2626}
.btn.d:hover{background:#fef2f2}
.btn.g{background:linear-gradient(180deg,#10b981,#059669);color:#fff;
  box-shadow:0 4px 12px rgba(16,185,129,.22)}
.btn.sm{padding:5px 10px;font-size:11.5px;border-radius:7px}
.btn[disabled]{opacity:.5;cursor:not-allowed;transform:none;box-shadow:none}

/* ---------- панель бота ---------- */
.bot-panel{display:flex;flex-wrap:wrap;align-items:center;justify-content:space-between;
  gap:16px;background:linear-gradient(120deg,#0f172a,#172554);color:#e2e8f0;
  border-radius:16px;padding:20px 22px;margin-bottom:18px;box-shadow:0 16px 40px rgba(15,23,42,.18)}
.bot-panel .state{display:flex;align-items:center;gap:12px}
.bot-panel .state i{width:11px;height:11px;border-radius:50%;background:#64748b;
  box-shadow:0 0 0 5px rgba(100,116,139,.14)}
.bot-panel .state i.running{background:#22c55e;box-shadow:0 0 0 5px rgba(34,197,94,.16)}
.bot-panel .state i.paused{background:#f59e0b;box-shadow:0 0 0 5px rgba(245,158,11,.16)}
.bot-panel h2{margin:0;font-size:18px;letter-spacing:-.02em}
.bot-panel p{margin:3px 0 0;font-size:12px;color:#94a3b8}
.bot-actions{display:flex;gap:8px;flex-wrap:wrap}
.bot-actions .btn.p{background:#fff;color:#0f172a;box-shadow:none}
.bot-actions .btn.s{background:rgba(255,255,255,.08);border-color:rgba(255,255,255,.16);color:#e2e8f0}
.bot-actions .btn.s:hover{background:rgba(255,255,255,.14)}
.bot-actions .btn.d{background:rgba(239,68,68,.12);border-color:rgba(239,68,68,.35);color:#fca5a5}

/* ---------- журнал ---------- */
.log-row{display:flex;gap:14px;padding:12px 18px;border-bottom:1px solid #eef2f7;align-items:flex-start}
.log-row:last-child{border-bottom:0}
.log-row:hover{background:#f8fafc}
.log-time{width:120px;flex:0 0 auto;font-size:11.5px;color:#94a3b8;font-variant-numeric:tabular-nums}
.log-body{flex:1;min-width:0}
.log-body .txt{font-size:13px;color:#1e293b}
.log-body .meta{font-size:11px;color:#94a3b8;margin-top:2px}
.log-link{color:#2563eb;font-weight:600;font-size:11.5px;margin-left:6px}
.log-actor{font-size:10.5px;color:#64748b;background:#f1f5f9;padding:1px 7px;border-radius:99px}
.log-ico{display:inline-flex;vertical-align:-2px;margin-right:7px;color:#64748b}

/* ---------- модалки ---------- */
.modal{position:fixed;inset:0;z-index:50;background:rgba(15,23,42,.45);display:none;
  align-items:center;justify-content:center;padding:20px;backdrop-filter:blur(4px)}
.modal.open{display:flex}
.modal-box{background:#fff;border-radius:16px;box-shadow:0 25px 50px -12px rgba(0,0,0,.25);
  width:100%;max-width:640px;max-height:90vh;overflow:auto}
.modal-hd{display:flex;align-items:center;justify-content:space-between;
  padding:16px 20px;border-bottom:1px solid var(--line);font-size:14px;font-weight:600}
.modal-bd{padding:18px 20px}
.modal-ft{display:flex;justify-content:space-between;gap:10px;
  padding:14px 20px;border-top:1px solid var(--line)}
.x{width:30px;height:30px;border-radius:8px;border:0;background:transparent;cursor:pointer;color:#64748b}
.x:hover{background:#f1f5f9}

/* ---------- пустые состояния ---------- */
.empty{padding:46px 20px;text-align:center;color:#94a3b8;font-size:13.5px}
.empty b{display:block;color:#475569;margin-bottom:5px;font-size:15px}

/* ---------- предупреждения ---------- */
.note{border:1px solid #fde68a;background:#fffbeb;color:#92400e;
  border-radius:10px;padding:10px 13px;font-size:12.5px}
.note.r{border-color:#fecaca;background:#fef2f2;color:#991b1b}
.note.b{border-color:#bfdbfe;background:#eff6ff;color:#1e40af}

/* ---------- прогресс ---------- */
.pbar{height:8px;background:#e2e8f0;border-radius:99px;overflow:hidden}
.pbar i{display:block;height:100%;background:linear-gradient(90deg,#3b82f6,#8b5cf6);
  border-radius:99px;transition:width .3s}

/* ---------- адаптив ---------- */
@media(min-width:901px){
  .sb-toggle{display:grid}
  .mtop{display:none!important}
}
@media(max-width:900px){
  .sidebar{transform:translateX(-100%);width:250px!important}
  body.open .sidebar{transform:none}
  body.open .veil{display:block}
  .main{margin-left:0!important}
  .mtop{display:flex}
  .wrap{padding:16px 14px 56px}
  .page-hd h1{font-size:19px}
  .card{overflow-x:auto}
  .bot-panel{padding:16px}
  .log-time{width:82px}
  .grid[style*="1.1fr"]{grid-template-columns:1fr!important}
}
