:root {
  --bg: #f4f6fb;
  --surface: #ffffff;
  --surface-2: #f3f5fa;
  --surface-3: #e9edf5;
  --border: #e3e7ef;
  --border-2: #cfd6e3;
  --text: #0f172a;
  --muted: #5a6476;
  --dim: #8b94a7;
  --accent: #4f46e5;
  --accent-soft: #eef0ff;
  --grad: linear-gradient(135deg, #4f46e5 0%, #6d4aff 55%, #8b5cf6 100%);
  --green: #059669;
  --amber: #b45309;
  --red: #dc2626;
  --blue: #2563eb;
  --radius: 16px;
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, 0.05);
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.04), 0 8px 24px -12px rgba(16, 24, 40, 0.14);
  --shadow-lg: 0 24px 56px -20px rgba(16, 24, 40, 0.3);
  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  color-scheme: light;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { background: var(--bg); color: var(--text); font: 14px/1.5 var(--font); -webkit-font-smoothing: antialiased; }
body { min-height: 100vh; background:
  radial-gradient(900px 500px at 85% -10%, rgba(124, 92, 255, 0.09), transparent 60%),
  radial-gradient(700px 400px at -5% 10%, rgba(59, 130, 246, 0.07), transparent 60%), var(--bg); background-attachment: fixed; }
a { color: var(--accent); text-decoration: none; font-weight: 500; }
button { font-family: inherit; }
::selection { background: rgba(79, 70, 229, 0.18); }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: #d5dae5; border-radius: 10px; border: 2px solid var(--bg); }

.icon { width: 18px; height: 18px; stroke: currentColor; fill: none; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; flex-shrink: 0; }
.icon.sm { width: 15px; height: 15px; }

/* Buttons & forms */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 40px; padding: 0 16px; border-radius: 11px; border: 1px solid var(--border); background: var(--surface); color: var(--text); font-weight: 600; font-size: 13.5px; cursor: pointer; transition: transform .12s, background .15s, border-color .15s, box-shadow .15s, filter .15s; white-space: nowrap; box-shadow: var(--shadow-sm); text-decoration: none; }
.btn:hover { background: var(--surface-2); border-color: var(--border-2); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.primary { background: var(--grad); border-color: transparent; color: #fff; box-shadow: 0 8px 20px -10px rgba(79, 70, 229, 0.8); }
.btn.primary:hover { filter: brightness(1.06); }
.btn.danger { background: #fef2f2; border-color: #fecaca; color: var(--red); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--muted); box-shadow: none; }
.btn.ghost:hover { color: var(--text); background: var(--surface-3); }
.btn.sm { height: 32px; padding: 0 12px; font-size: 12.5px; border-radius: 9px; }
.btn.block { width: 100%; }
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.field label { font-size: 12.5px; font-weight: 600; color: var(--muted); }
.field .hint { font-size: 12px; color: var(--dim); }
.input, .select, .textarea { width: 100%; background: var(--surface); border: 1px solid var(--border-2); border-radius: 11px; color: var(--text); font: 14px var(--font); padding: 10px 13px; outline: none; transition: border-color .15s, box-shadow .15s; }
.input::placeholder { color: #a3abbb; }
.input:focus, .select:focus, .textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.14); }
.input:disabled { background: var(--surface-2); color: var(--muted); }
.form-msg { font-size: 13px; margin-top: 10px; min-height: 18px; }
.form-msg.ok { color: var(--green); }
.form-msg.bad { color: var(--red); }

/* Auth screen */
.auth { min-height: 100vh; display: grid; grid-template-columns: 1.1fr 1fr; }
.auth-side { padding: 56px; display: flex; flex-direction: column; justify-content: space-between; background: linear-gradient(160deg, #4338ca 0%, #6d28d9 60%, #7c3aed 100%); color: #fff; position: relative; overflow: hidden; }
.auth-side::after { content: ''; position: absolute; width: 460px; height: 460px; right: -160px; bottom: -160px; border-radius: 50%; background: radial-gradient(circle, rgba(255, 255, 255, 0.18), transparent 65%); }
.auth-side::before { content: ''; position: absolute; width: 300px; height: 300px; left: -120px; top: 30%; border-radius: 50%; background: radial-gradient(circle, rgba(96, 165, 250, 0.35), transparent 65%); }
.auth-side .brand { color: #fff; position: relative; z-index: 1; }
.auth-side .logo { background: rgba(255, 255, 255, 0.18); box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.3); }
.auth-side h2 { font-size: 42px; line-height: 1.08; letter-spacing: -.03em; max-width: 460px; margin: 28px 0 14px; position: relative; z-index: 1; }
.auth-side h2 span { color: #c7d2fe; }
.auth-side p { color: rgba(255, 255, 255, 0.82); max-width: 420px; font-size: 15px; position: relative; z-index: 1; }
.auth-feats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; max-width: 480px; position: relative; z-index: 1; }
.auth-feats div { padding: 14px 12px; border-radius: 14px; background: rgba(255, 255, 255, 0.12); border: 1px solid rgba(255, 255, 255, 0.22); backdrop-filter: blur(6px); font-size: 12.5px; font-weight: 600; display: flex; flex-direction: column; gap: 8px; color: #fff; }
.auth-feats .icon { color: #fff; opacity: .9; }
.auth-main { display: flex; align-items: center; justify-content: center; padding: 40px 24px; }
.auth-box { width: 100%; max-width: 380px; background: var(--surface); padding: 32px; border-radius: 20px; border: 1px solid var(--border); box-shadow: var(--shadow-lg); }
.auth-box h1 { font-size: 24px; letter-spacing: -.02em; margin-bottom: 6px; }
.auth-box .sub { color: var(--muted); margin-bottom: 24px; }
.auth-box .err { color: var(--red); font-size: 13px; margin-bottom: 12px; background: #fef2f2; border: 1px solid #fecaca; padding: 8px 12px; border-radius: 10px; }
.auth-box .auth-switch { margin-top: 18px; text-align: center; color: var(--muted); font-size: 13px; }
.auth-box .auth-switch button { background: none; border: none; color: var(--accent); font-weight: 600; cursor: pointer; font-size: 13px; }
.brand { display: flex; align-items: center; gap: 11px; font-weight: 700; font-size: 16px; letter-spacing: -.01em; }
.logo { width: 38px; height: 38px; border-radius: 11px; background: var(--grad); display: grid; place-items: center; color: #fff; box-shadow: 0 8px 18px -8px rgba(79, 70, 229, 0.7); flex-shrink: 0; }
.logo .icon { width: 20px; height: 20px; stroke-width: 2.2; }

/* App layout */
.layout { display: grid; grid-template-columns: 252px 1fr; min-height: 100vh; }
.sidebar { position: sticky; top: 0; height: 100vh; padding: 22px 14px; border-right: 1px solid var(--border); background: var(--surface); display: flex; flex-direction: column; gap: 4px; }
.sidebar .brand { padding: 0 8px 22px; }
.nav-btn { display: flex; align-items: center; gap: 11px; padding: 10px 12px; border-radius: 11px; border: none; background: none; color: var(--muted); font-size: 13.5px; font-weight: 600; cursor: pointer; text-align: left; width: 100%; transition: background .15s, color .15s; text-decoration: none; }
.nav-btn:hover { background: var(--surface-2); color: var(--text); }
.nav-btn.active { background: var(--accent-soft); color: var(--accent); }
.nav-btn.active .icon { color: var(--accent); }
.nav-btn .count { margin-left: auto; font-size: 11px; background: #d1fae5; color: #047857; padding: 1px 7px; border-radius: 99px; }
.sidebar .spacer { flex: 1; }
.user-card { display: flex; align-items: center; gap: 10px; padding: 12px; border-radius: 14px; background: var(--surface-2); border: 1px solid var(--border); }
.user-card .av { width: 34px; height: 34px; border-radius: 50%; background: var(--grad); color: #fff; display: grid; place-items: center; font-weight: 700; font-size: 12px; flex-shrink: 0; }
.user-card .who { flex: 1; min-width: 0; }
.user-card b { display: block; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-card span { display: block; font-size: 11.5px; color: var(--dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.content { padding: 32px 40px 60px; max-width: 1200px; width: 100%; }
.page-title { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 24px; flex-wrap: wrap; }
.page-title h1 { font-size: 28px; letter-spacing: -.03em; }
.page-title p { color: var(--muted); margin-top: 2px; }
.mobile-bar { display: none; }

/* Cards & grids */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; margin-bottom: 18px; box-shadow: var(--shadow); }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 16px; flex-wrap: wrap; }
.card-title { font-size: 15px; font-weight: 700; letter-spacing: -.01em; display: flex; align-items: center; gap: 9px; }
.card-title .icon { color: var(--accent); }
.grid { display: grid; gap: 16px; }
.g-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.g-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g-21 { grid-template-columns: 2fr 1fr; }
.kpi { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; position: relative; overflow: hidden; box-shadow: var(--shadow); }
.kpi .k-label { font-size: 12.5px; color: var(--muted); font-weight: 600; display: flex; align-items: center; gap: 8px; }
.kpi .k-label .icon { color: var(--c, var(--accent)); width: 30px; height: 30px; padding: 7px; border-radius: 9px; background: color-mix(in srgb, var(--c, #4f46e5) 11%, white); }
.kpi .k-val { font-size: 30px; font-weight: 700; letter-spacing: -.03em; margin-top: 10px; font-variant-numeric: tabular-nums; }
.kpi .k-sub { font-size: 12px; color: var(--dim); margin-top: 2px; }
.kpi.hl { background: var(--grad); border-color: transparent; color: #fff; box-shadow: 0 16px 32px -16px rgba(79, 70, 229, 0.7); }
.kpi.hl .k-label, .kpi.hl .k-sub { color: rgba(255, 255, 255, 0.85); }
.kpi.hl .k-label .icon { color: #fff; background: rgba(255, 255, 255, 0.18); }

.pill { display: inline-flex; align-items: center; gap: 7px; height: 26px; padding: 0 11px; border-radius: 99px; font-size: 12px; font-weight: 600; background: var(--surface-2); color: var(--muted); border: 1px solid var(--border); white-space: nowrap; }
.pill .dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.pill.live { color: var(--green); background: #ecfdf5; border-color: #a7f3d0; }
.pill.live .dot { animation: pulse 1.6s infinite; }
.pill.warn { color: var(--amber); background: #fffbeb; border-color: #fde68a; }
.pill.bad { color: var(--red); background: #fef2f2; border-color: #fecaca; }
.pill.info { color: var(--blue); background: #eff6ff; border-color: #bfdbfe; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(5, 150, 105, 0.45); } 70% { box-shadow: 0 0 0 8px rgba(5, 150, 105, 0); } 100% { box-shadow: 0 0 0 0 rgba(5, 150, 105, 0); } }
.badge { display: inline-flex; align-items: center; gap: 4px; height: 22px; padding: 0 8px; border-radius: 7px; font-size: 11.5px; font-weight: 600; background: var(--surface-3); color: var(--muted); white-space: nowrap; }
.badge.green { background: #d1fae5; color: #047857; }
.badge.red { background: #fee2e2; color: #b91c1c; }
.badge.amber { background: #fef3c7; color: #92400e; }
.badge.blue { background: #dbeafe; color: #1d4ed8; }
.badge.violet { background: #ede9fe; color: #6d28d9; }

.banner { display: flex; gap: 12px; align-items: flex-start; padding: 14px 16px; border-radius: 14px; margin-bottom: 18px; font-size: 13.5px; }
.banner .icon { margin-top: 2px; }
.banner.warn { background: #fffbeb; border: 1px solid #fde68a; color: #92400e; }
.banner.info { background: #eff6ff; border: 1px solid #bfdbfe; color: #1e40af; }
.banner.ok { background: #ecfdf5; border: 1px solid #a7f3d0; color: #065f46; }
.banner b { color: inherit; }
.banner .grow { flex: 1; }

/* Bot cards */
.bot { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; position: relative; overflow: hidden; transition: border-color .15s, transform .15s, box-shadow .15s; display: flex; flex-direction: column; min-height: 170px; box-shadow: var(--shadow); }
.bot:hover { border-color: color-mix(in srgb, var(--c) 40%, white); transform: translateY(-2px); box-shadow: 0 14px 30px -16px color-mix(in srgb, var(--c) 55%, transparent); }
.bot.running { border-color: color-mix(in srgb, var(--c) 35%, white); }
.bot.running::before { content: ''; position: absolute; inset: 0 0 auto 0; height: 3px; background: linear-gradient(90deg, transparent, var(--c), transparent); animation: sweep 2.2s linear infinite; }
@keyframes sweep { from { transform: translateX(-100%); } to { transform: translateX(100%); } }
.bot.locked { opacity: .55; }
.bot .b-top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.bot .b-icon { width: 42px; height: 42px; border-radius: 12px; display: grid; place-items: center; background: color-mix(in srgb, var(--c) 11%, white); color: var(--c); }
.bot h3 { font-size: 15px; letter-spacing: -.01em; margin-bottom: 4px; }
.bot .b-status { color: var(--muted); font-size: 13px; flex: 1; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.bot .b-foot { display: flex; justify-content: space-between; align-items: center; margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--border); font-size: 12px; color: var(--dim); gap: 8px; }

/* Tables */
.table-wrap { overflow-x: auto; margin: 0 -20px -20px; }
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
th { text-align: left; font-size: 11.5px; font-weight: 700; color: var(--dim); text-transform: uppercase; letter-spacing: .05em; padding: 10px 20px; border-bottom: 1px solid var(--border); white-space: nowrap; background: var(--surface-2); }
td { padding: 12px 20px; border-bottom: 1px solid var(--border); vertical-align: middle; }
tr:last-child td { border-bottom: none; }
tbody tr:hover td { background: #fafbfe; }
td.num { font-variant-numeric: tabular-nums; text-align: right; }
th.num { text-align: right; }
.td-user { display: flex; align-items: center; gap: 10px; }
.td-user .av { width: 32px; height: 32px; border-radius: 50%; background: var(--accent-soft); display: grid; place-items: center; font-weight: 700; font-size: 11.5px; color: var(--accent); flex-shrink: 0; }
.td-user b { display: block; font-size: 13.5px; }
.td-user span { display: block; font-size: 12px; color: var(--dim); }

/* Feed */
.feed-item { display: flex; gap: 12px; padding: 11px 0; border-bottom: 1px solid var(--border); }
.feed-item:last-child { border-bottom: none; }
.feed-item .f-ico { width: 32px; height: 32px; border-radius: 10px; display: grid; place-items: center; background: color-mix(in srgb, var(--c, #8b95a9) 11%, white); color: var(--c, var(--muted)); flex-shrink: 0; }
.feed-item .f-ico .icon { width: 15px; height: 15px; }
.feed-item .f-text { font-size: 13.5px; word-break: break-word; }
.feed-item .f-meta { font-size: 12px; color: var(--dim); margin-top: 2px; }
.feed-item.error .f-text { color: #b91c1c; }
.feed-item.success .f-text { color: #047857; }

/* Chart */
.chart { width: 100%; height: 190px; display: block; }
.chart .bar { fill: url(#barGrad); transition: opacity .15s; }
.chart .bar:hover { opacity: .75; }
.chart text { fill: var(--dim); font-size: 10px; font-family: var(--font); }
.chart .grid-line { stroke: #edf0f6; }

.ring { position: relative; width: 128px; height: 128px; flex-shrink: 0; }
.ring svg { transform: rotate(-90deg); }
.ring .r-center { position: absolute; inset: 0; display: grid; place-items: center; text-align: center; }
.ring .r-center b { display: block; font-size: 22px; letter-spacing: -.02em; }
.ring .r-center span { font-size: 11px; color: var(--dim); }

.empty { text-align: center; color: var(--dim); padding: 36px 16px; font-size: 13.5px; }
.empty .icon { width: 32px; height: 32px; display: block; margin: 0 auto 10px; opacity: .55; }
.muted { color: var(--muted); }
.dim { color: var(--dim); }
.row-flex { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

/* Modal & toast */
.modal { position: fixed; inset: 0; background: rgba(15, 23, 42, 0.38); backdrop-filter: blur(5px); display: flex; align-items: center; justify-content: center; padding: 20px; z-index: 100; }
.modal[hidden] { display: none; }
.modal-box { width: 100%; max-width: 540px; max-height: 90vh; overflow-y: auto; background: var(--surface); border: 1px solid var(--border); border-radius: 20px; padding: 26px; box-shadow: var(--shadow-lg); animation: pop .2s ease; }
.modal-box h3 { font-size: 19px; letter-spacing: -.01em; margin-bottom: 4px; }
.modal-box .m-sub { color: var(--muted); font-size: 13px; margin-bottom: 18px; }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 18px; }
@keyframes pop { from { opacity: 0; transform: translateY(8px) scale(.98); } to { opacity: 1; transform: none; } }
#toasts { position: fixed; right: 20px; bottom: 20px; display: flex; flex-direction: column; gap: 8px; z-index: 200; }
.toast { display: flex; align-items: center; gap: 10px; padding: 12px 16px; border-radius: 12px; background: #0f172a; color: #f8fafc; box-shadow: var(--shadow-lg); font-size: 13.5px; animation: pop .2s ease; max-width: 380px; }
.toast.ok .icon { color: #34d399; }
.toast.bad { background: #7f1d1d; }
.toast.bad .icon { color: #fca5a5; }

.switch { position: relative; width: 40px; height: 23px; flex-shrink: 0; display: inline-block; }
.switch input { opacity: 0; width: 0; height: 0; position: absolute; }
.switch .track { position: absolute; inset: 0; border-radius: 99px; background: #d7dce6; transition: background .2s; cursor: pointer; }
.switch .track::after { content: ''; position: absolute; top: 3px; left: 3px; width: 17px; height: 17px; border-radius: 50%; background: #fff; transition: transform .2s cubic-bezier(.3, 1.4, .6, 1); box-shadow: 0 1px 3px rgba(16, 24, 40, 0.25); }
.switch input:checked + .track { background: var(--grad); }
.switch input:checked + .track::after { transform: translateX(17px); }
.feat-toggles { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.feat-toggle { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 12px; background: var(--surface-2); border: 1px solid var(--border); cursor: pointer; font-size: 13px; font-weight: 600; }
.feat-toggle .icon { color: var(--c); }
.feat-toggle .grow { flex: 1; }

@media (max-width: 1000px) {
  .g-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .g-3, .g-21 { grid-template-columns: 1fr; }
}
@media (max-width: 820px) {
  .auth { grid-template-columns: 1fr; }
  .auth-side { display: none; }
  .layout { grid-template-columns: 1fr; }
  .sidebar { display: none; }
  .mobile-bar { display: flex; align-items: center; gap: 6px; padding: 12px 16px; border-bottom: 1px solid var(--border); position: sticky; top: 0; background: rgba(255, 255, 255, 0.92); backdrop-filter: blur(12px); z-index: 20; overflow-x: auto; }
  .mobile-bar .nav-btn { width: auto; white-space: nowrap; padding: 8px 11px; }
  .content { padding: 20px 16px 50px; }
  .g-2, .feat-toggles { grid-template-columns: 1fr; }
  .auth-box { padding: 24px; box-shadow: var(--shadow); }
}
@media (max-width: 480px) { .g-4 { grid-template-columns: 1fr 1fr; } .kpi .k-val { font-size: 24px; } }
