:root {
  --bg: #070b1d;
  --bg2: #0c1230;
  --panel: rgba(20, 28, 66, .72);
  --panel-solid: #141c42;
  --line: rgba(139, 152, 255, .14);
  --text: #e8ebff;
  --muted: #8f97c4;
  --violet: #8b5cf6;
  --cyan: #22d3ee;
  --green: #34d399;
  --amber: #fbbf24;
  --red: #f87171;
  --grad: linear-gradient(135deg, var(--violet), var(--cyan));
  --shadow: 0 18px 50px rgba(0, 0, 0, .45), 0 0 0 1px var(--line);
  --r: 16px;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: Inter, "Segoe UI", system-ui, -apple-system, sans-serif;
  font-size: 14px; color: var(--text);
  background:
    radial-gradient(900px 600px at 85% -10%, rgba(139, 92, 246, .25), transparent 60%),
    radial-gradient(800px 500px at -10% 110%, rgba(34, 211, 238, .16), transparent 60%),
    var(--bg);
  background-attachment: fixed;
}
a { color: var(--cyan); }
button, input, select { font: inherit; color: inherit; }

/* ---------- layout ---------- */
.shell { display: grid; grid-template-columns: 240px 1fr; min-height: 100vh; }
.side {
  position: sticky; top: 0; height: 100vh; padding: 22px 16px;
  background: rgba(8, 12, 34, .7); backdrop-filter: blur(14px);
  border-right: 1px solid var(--line); display: flex; flex-direction: column;
}
.logo { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 19px; letter-spacing: -.3px; padding: 4px 8px 24px; }
.logo-mark { width: 34px; height: 34px; border-radius: 10px; background: var(--grad); display: grid; place-items: center; box-shadow: 0 8px 24px rgba(139, 92, 246, .45); }
.logo span b { background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; }
.nav { position: relative; display: flex; flex-direction: column; gap: 4px; }
.nav-pill { position: absolute; left: 0; right: 0; height: 42px; border-radius: 12px; background: var(--grad); box-shadow: 0 10px 28px rgba(139, 92, 246, .4); transition: transform .35s cubic-bezier(.4, 1.3, .5, 1); z-index: 0; }
.nav button {
  position: relative; z-index: 1; display: flex; align-items: center; gap: 12px; height: 42px; padding: 0 14px;
  border: 0; background: none; border-radius: 12px; cursor: pointer; color: var(--muted); font-weight: 600; text-align: left;
  transition: color .2s;
}
.nav button:hover { color: var(--text); }
.nav button.on { color: #fff; }
.nav svg { width: 18px; height: 18px; flex: none; }
.side-foot { margin-top: auto; padding: 12px 8px 0; border-top: 1px solid var(--line); color: var(--muted); font-size: 12.5px; display: flex; justify-content: space-between; align-items: center; }
.main { padding: 28px 34px 60px; min-width: 0; }
.head { display: flex; align-items: center; gap: 14px; margin-bottom: 24px; flex-wrap: wrap; }
.head h1 { margin: 0; font-size: 26px; letter-spacing: -.5px; }
.head .sub { color: var(--muted); margin-top: 3px; }
.head .grow { flex: 1; }

/* ---------- panels ---------- */
.card { background: var(--panel); backdrop-filter: blur(14px); border-radius: var(--r); box-shadow: var(--shadow); padding: 20px; }
.card h3 { margin: 0 0 14px; font-size: 15px; }
.grid { display: grid; gap: 18px; }
.kpis { grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); margin-bottom: 18px; }
.kpi { position: relative; overflow: hidden; }
.kpi .lbl { color: var(--muted); font-size: 12.5px; font-weight: 600; text-transform: uppercase; letter-spacing: .6px; }
.kpi .val { font-size: 30px; font-weight: 800; margin-top: 8px; letter-spacing: -.8px; }
.kpi::after { content: ""; position: absolute; inset: auto -30px -40px auto; width: 120px; height: 120px; border-radius: 50%; background: var(--c, var(--violet)); opacity: .18; filter: blur(18px); }
.kpi .bar { position: absolute; left: 0; top: 0; bottom: 0; width: 4px; background: var(--c, var(--violet)); }
.two { grid-template-columns: 1.6fr 1fr; }
@media (max-width: 1100px) { .two { grid-template-columns: 1fr; } }

/* ---------- controls ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 8px; height: 38px; padding: 0 16px; border-radius: 11px;
  border: 1px solid var(--line); background: rgba(255, 255, 255, .04); cursor: pointer; font-weight: 600;
  transition: transform .15s, box-shadow .2s, background .2s; white-space: nowrap;
}
.btn:hover { background: rgba(255, 255, 255, .08); }
.btn:active { transform: translateY(1px); }
.btn.primary { border: 0; background: var(--grad); color: #fff; box-shadow: 0 8px 22px rgba(139, 92, 246, .38); }
.btn.primary:hover { box-shadow: 0 10px 28px rgba(34, 211, 238, .38); }
.btn.danger { color: var(--red); }
.btn.sm { height: 32px; padding: 0 12px; font-size: 13px; }
.btn:disabled { opacity: .55; cursor: wait; }
.input, select.input {
  height: 38px; padding: 0 12px; border-radius: 11px; border: 1px solid var(--line);
  background: rgba(5, 8, 25, .55); outline: none; transition: border-color .2s, box-shadow .2s; min-width: 0;
}
.input:focus { border-color: var(--violet); box-shadow: 0 0 0 3px rgba(139, 92, 246, .25); }
select.input option { background: var(--panel-solid); }
.filters { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 16px; }
.seg { display: inline-flex; padding: 3px; border-radius: 11px; background: rgba(5, 8, 25, .55); border: 1px solid var(--line); }
.seg button { border: 0; background: none; height: 30px; padding: 0 12px; border-radius: 8px; cursor: pointer; color: var(--muted); font-weight: 600; font-size: 13px; }
.seg button.on { background: var(--grad); color: #fff; }
label.f { display: flex; flex-direction: column; gap: 6px; font-size: 12.5px; color: var(--muted); font-weight: 600; }
label.f .input { color: var(--text); font-weight: 400; }
.form { display: grid; gap: 14px; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }

/* ---------- table ---------- */
.tbl-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-size: 11.5px; text-transform: uppercase; letter-spacing: .6px; color: var(--muted); font-weight: 700; padding: 10px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: 11px 12px; border-bottom: 1px solid rgba(139, 152, 255, .07); white-space: nowrap; }
tbody tr { transition: background .15s; }
tbody tr:hover { background: rgba(139, 92, 246, .08); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.tag { display: inline-flex; align-items: center; gap: 6px; height: 24px; padding: 0 10px; border-radius: 99px; font-size: 12px; font-weight: 700; }
.tag.ftd { background: rgba(52, 211, 153, .15); color: var(--green); box-shadow: inset 0 0 0 1px rgba(52, 211, 153, .35); }
.tag.no { background: rgba(143, 151, 196, .1); color: var(--muted); }
.tag.rs { background: rgba(34, 211, 238, .14); color: var(--cyan); }
.tag.cpl { background: rgba(139, 92, 246, .18); color: #c4b5fd; }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.dot.ok { background: var(--green); box-shadow: 0 0 10px var(--green); }
.dot.bad { background: var(--red); box-shadow: 0 0 10px var(--red); }
.dot.idle { background: var(--muted); }
.pager { display: flex; justify-content: space-between; align-items: center; margin-top: 14px; color: var(--muted); }
.empty { text-align: center; padding: 50px 20px; color: var(--muted); }
.empty b { display: block; color: var(--text); font-size: 16px; margin-bottom: 6px; }

/* ---------- bars ---------- */
.hbar { display: grid; grid-template-columns: 70px 1fr 70px; align-items: center; gap: 10px; margin: 9px 0; font-size: 13px; }
.hbar .track { height: 10px; border-radius: 99px; background: rgba(255, 255, 255, .05); overflow: hidden; position: relative; }
.hbar .fill { position: absolute; inset: 0 auto 0 0; border-radius: 99px; background: var(--grad); }
.hbar .fill.f2 { background: var(--green); opacity: .9; }
.chart { width: 100%; height: 220px; display: block; }

/* ---------- brands ---------- */
.brands { grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); }
.brand-card .top { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }
.brand-card .av { width: 42px; height: 42px; border-radius: 12px; background: var(--grad); display: grid; place-items: center; font-weight: 800; font-size: 17px; flex: none; }
.brand-card .nm { font-weight: 700; font-size: 16px; }
.brand-card .stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 12px 0; }
.brand-card .stats div { background: rgba(5, 8, 25, .45); border-radius: 11px; padding: 10px; }
.brand-card .stats b { display: block; font-size: 18px; }
.brand-card .stats span { color: var(--muted); font-size: 11.5px; }
.brand-card .acts { display: flex; gap: 8px; flex-wrap: wrap; }
.sync-line { font-size: 12.5px; color: var(--muted); display: flex; gap: 8px; align-items: center; }

/* ---------- modal ---------- */
.modal-bg { position: fixed; inset: 0; background: rgba(3, 5, 16, .7); backdrop-filter: blur(6px); display: grid; place-items: center; z-index: 50; padding: 20px; animation: fade .2s; }
.modal { width: min(620px, 100%); max-height: 90vh; overflow: auto; background: var(--panel-solid); border-radius: 20px; box-shadow: var(--shadow); padding: 24px; animation: pop .25s cubic-bezier(.4, 1.4, .5, 1); }
.modal h2 { margin: 0 0 18px; font-size: 20px; }
.modal .foot { display: flex; justify-content: flex-end; gap: 10px; margin-top: 20px; }
pre.raw { background: rgba(5, 8, 25, .7); border-radius: 12px; padding: 14px; font-size: 12px; max-height: 300px; overflow: auto; white-space: pre-wrap; word-break: break-all; }
.note { background: rgba(34, 211, 238, .08); border: 1px solid rgba(34, 211, 238, .25); border-radius: 12px; padding: 12px 14px; color: #bdf3fb; font-size: 13px; line-height: 1.5; }
.note.bad { background: rgba(248, 113, 113, .08); border-color: rgba(248, 113, 113, .3); color: #fecaca; }
@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { opacity: 0; transform: scale(.95) translateY(10px); } }

/* ---------- auth ---------- */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.auth .card { width: min(400px, 100%); padding: 32px; }
.auth .logo { justify-content: center; font-size: 24px; padding-bottom: 8px; }
.auth p { color: var(--muted); text-align: center; margin: 0 0 22px; line-height: 1.5; }
.secret { font-family: ui-monospace, Consolas, monospace; font-size: 15px; letter-spacing: 1.5px; text-align: center; background: rgba(5, 8, 25, .7); border-radius: 12px; padding: 14px; word-break: break-all; user-select: all; }
.code-input { text-align: center; font-size: 22px; letter-spacing: 8px; height: 50px; }

#toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); z-index: 100; display: flex; flex-direction: column; gap: 8px; align-items: center; }
.toast { background: var(--panel-solid); box-shadow: var(--shadow); border-radius: 12px; padding: 11px 18px; font-weight: 600; animation: pop .25s; border-left: 4px solid var(--cyan); }
.toast.err { border-left-color: var(--red); }

@media (max-width: 820px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: static; height: auto; flex-direction: row; align-items: center; gap: 10px; padding: 12px; overflow-x: auto; }
  .logo { padding: 0 8px 0 0; }
  .nav { flex-direction: row; }
  .nav-pill { display: none; }
  .nav button.on { background: var(--grad); }
  .side-foot { display: none; }
  .main { padding: 20px 14px 40px; }
  .row2 { grid-template-columns: 1fr; }
}

.drop { height: 38px; display: flex; align-items: center; padding: 0 14px; border-radius: 11px; border: 1.5px dashed rgba(139,152,255,.35); background: rgba(5,8,25,.55); cursor: pointer; color: var(--text); font-weight: 400; transition: border-color .2s, background .2s; }
.drop:hover, .drop.over { border-color: var(--cyan); background: rgba(34,211,238,.06); }
.tag.bad { background: rgba(248,113,113,.15); color: var(--red); }
.tag.warn { background: rgba(251,191,36,.14); color: var(--amber); }
a.btn { text-decoration: none; }
