:root{
  --bg: #06070d;
  --bg-2: #0a0c18;
  --panel: rgba(255,255,255,0.035);
  --panel-border: rgba(255,255,255,0.08);
  --panel-border-hover: rgba(167,139,250,0.35);
  --text: #eef0fb;
  --text-dim: #9aa0c0;
  --text-faint: #676d92;
  --violet: #a78bfa;
  --violet-2: #7c5cff;
  --cyan: #5eead4;
  --pink: #f472b6;
  --amber: #fbbf24;
  --emerald: #34d399;
  --red: #fb7185;
  --radius: 16px;
  --radius-sm: 10px;
  font-size: 15px;
}

*{ box-sizing: border-box; }
html,body{ height:100%; }
body{
  margin:0;
  background: var(--bg);
  color: var(--text);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  overflow-x:hidden;
}

/* ---------------- Cosmic background ---------------- */
.cosmos{
  position: fixed; inset:0; z-index:0; overflow:hidden;
  background:
    radial-gradient(ellipse 120% 80% at 15% -10%, #171034 0%, transparent 55%),
    radial-gradient(ellipse 100% 70% at 90% 10%, #0c2233 0%, transparent 50%),
    linear-gradient(180deg, #06070d 0%, #080913 60%, #05060b 100%);
}
.cosmos-glow{
  position:absolute; border-radius:50%; filter: blur(90px); opacity:.35;
  animation: drift 26s ease-in-out infinite alternate;
}
.glow-a{ width:520px; height:520px; background: radial-gradient(circle, #7c5cff, transparent 70%); top:-120px; left:-100px; }
.glow-b{ width:600px; height:600px; background: radial-gradient(circle, #14b8a6, transparent 70%); bottom:-200px; right:-150px; animation-duration: 32s; animation-delay: -8s; }
@keyframes drift{
  0%{ transform: translate(0,0) scale(1); }
  100%{ transform: translate(40px,30px) scale(1.08); }
}
#stars{ position:absolute; inset:0; width:100%; height:100%; }

/* ---------------- Login ---------------- */
.login-screen{
  position:fixed; inset:0; z-index:20; display:flex; align-items:center; justify-content:center;
}
.login-card{
  width: 360px; padding: 40px 32px; text-align:center;
  background: linear-gradient(180deg, rgba(255,255,255,0.05), rgba(255,255,255,0.02));
  border:1px solid var(--panel-border); border-radius: 20px;
  backdrop-filter: blur(20px);
  box-shadow: 0 30px 80px rgba(0,0,0,.55), 0 0 60px rgba(124,92,255,.08);
}
.login-logo{ margin-bottom: 28px; }
.logo-orb{
  width:56px; height:56px; margin:0 auto 14px; border-radius:16px;
  background: conic-gradient(from 180deg, var(--violet-2), var(--cyan), var(--pink), var(--violet-2));
  box-shadow: 0 0 40px rgba(124,92,255,.5);
}
.login-title{ font-size:20px; font-weight:700; letter-spacing:.2px; }
.login-sub{ font-size:13px; color: var(--text-dim); margin-top:4px; }
.login-card input{
  width:100%; padding:13px 14px; margin-bottom:14px; border-radius: 12px;
  border:1px solid var(--panel-border); background: rgba(255,255,255,0.04); color:var(--text); font-size:14px;
  outline:none; transition: border-color .15s;
}
.login-card input:focus{ border-color: var(--violet); }
.login-hint{ margin-top:14px; font-size:12px; color:var(--text-faint); }
.login-error{ margin-top:12px; font-size:12.5px; color: var(--red); }
.hidden{ display:none !important; }

/* ---------------- Layout ---------------- */
.app{ position:relative; z-index:1; display:flex; min-height:100vh; }
.sidebar{
  width: 248px; flex-shrink:0; padding:22px 16px; display:flex; flex-direction:column;
  background: rgba(10,11,22,0.55); border-right:1px solid var(--panel-border);
  backdrop-filter: blur(16px);
  position: sticky; top:0; height:100vh;
}
.brand{ display:flex; align-items:center; gap:12px; padding: 6px 8px 26px; }
.brand-orb{
  width:38px; height:38px; border-radius:11px; flex-shrink:0;
  background: conic-gradient(from 180deg, var(--violet-2), var(--cyan), var(--pink), var(--violet-2));
  box-shadow: 0 0 24px rgba(124,92,255,.45);
}
.brand-name{ font-weight:700; font-size:14.5px; }
.brand-tag{ font-size:11px; color:var(--text-faint); letter-spacing:.4px; text-transform:uppercase; }

.nav{ display:flex; flex-direction:column; gap:3px; flex:1; }
.nav-item{
  display:flex; align-items:center; gap:11px; text-align:left; width:100%;
  padding: 11px 13px; border-radius: 11px; border:none; background:transparent;
  color: var(--text-dim); font-size: 13.6px; font-weight:500; cursor:pointer;
  transition: background .15s, color .15s;
}
.nav-ico{ width:18px; text-align:center; opacity:.85; font-size:13px; color: var(--violet); }
.nav-item:hover{ background: rgba(255,255,255,0.045); color: var(--text); }
.nav-item.active{
  background: linear-gradient(90deg, rgba(124,92,255,.18), rgba(124,92,255,.03));
  color:#fff; box-shadow: inset 2px 0 0 var(--violet);
}
.sidebar-footer{ display:flex; flex-direction:column; gap:8px; padding-top:14px; border-top:1px solid var(--panel-border); }
.status-chip{ display:flex; align-items:center; gap:8px; font-size:12px; color:var(--text-dim); padding:6px 4px; }
.status-chip .dot{ width:7px; height:7px; border-radius:50%; background: var(--text-faint); box-shadow:0 0 0 rgba(0,0,0,0); }
.status-chip.on .dot{ background: var(--emerald); box-shadow: 0 0 8px var(--emerald); }
.status-chip.off .dot{ background: var(--red); box-shadow: 0 0 8px var(--red); }

.content{ flex:1; padding: 30px 38px 60px; max-width: 1320px; }
.view{ display:none; animation: fadein .25s ease; }
.view.active{ display:block; }
@keyframes fadein{ from{ opacity:0; transform: translateY(6px);} to{opacity:1; transform:none;} }

.view-head{ display:flex; justify-content:space-between; align-items:flex-end; margin-bottom: 24px; gap:16px; flex-wrap:wrap; }
.view-head h1{ margin:0 0 4px; font-size: 24px; font-weight:700; letter-spacing:-.2px; }
.view-head .sub{ margin:0; color: var(--text-dim); font-size:13.5px; }
.head-actions{ display:flex; gap:10px; }

/* ---------------- Stat cards ---------------- */
.stat-grid{ display:grid; grid-template-columns: repeat(4,1fr); gap:16px; margin-bottom:22px; }
.stat-card{
  padding:20px 20px; border-radius: var(--radius); background: var(--panel);
  border:1px solid var(--panel-border); position:relative; overflow:hidden;
  transition: transform .18s, border-color .18s;
}
.stat-card:hover{ transform: translateY(-2px); border-color: var(--panel-border-hover); }
.stat-card::before{
  content:""; position:absolute; top:-40px; right:-40px; width:120px; height:120px; border-radius:50%;
  filter: blur(40px); opacity:.5;
}
.stat-card.glow-violet::before{ background: var(--violet-2); }
.stat-card.glow-cyan::before{ background: var(--cyan); }
.stat-card.glow-emerald::before{ background: var(--emerald); }
.stat-card.glow-amber::before{ background: var(--amber); }
.stat-label{ font-size:12.5px; color:var(--text-dim); margin-bottom:10px; }
.stat-value{ font-size:30px; font-weight:700; letter-spacing:-.5px; }
.stat-foot{ font-size:12px; color:var(--text-faint); margin-top:6px; }

/* ---------------- Panel cards ---------------- */
.panel-row{ display:grid; grid-template-columns: 2fr 1fr; gap:18px; align-items:start; }
.panel-card{
  background: var(--panel); border:1px solid var(--panel-border); border-radius: var(--radius);
  padding: 20px 22px 22px;
}
.panel-card.wide{ min-width:0; }
.panel-card-head{ display:flex; align-items:center; justify-content:space-between; margin-bottom:14px; }
.panel-card-head h2{ font-size:15px; margin:0; font-weight:600; }
.badge{ font-size:11.5px; padding:4px 10px; border-radius:20px; background: rgba(167,139,250,.15); color: var(--violet); border:1px solid rgba(167,139,250,.3); }

/* ---------------- Buttons / inputs ---------------- */
.btn{
  border:none; border-radius: 10px; padding: 10px 16px; font-size:13.5px; font-weight:600;
  cursor:pointer; transition: transform .1s, filter .15s, background .15s; color:#fff;
}
.btn:active{ transform: scale(.97); }
.btn-primary{ background: linear-gradient(135deg, var(--violet-2), #5b8dff); box-shadow: 0 8px 24px rgba(124,92,255,.35); }
.btn-primary:hover{ filter: brightness(1.1); }
.btn-ghost{ background: rgba(255,255,255,0.05); color: var(--text-dim); border:1px solid var(--panel-border); }
.btn-ghost:hover{ color:#fff; border-color: var(--panel-border-hover); }
.btn-danger{ background: rgba(251,113,133,.15); color: var(--red); border:1px solid rgba(251,113,133,.35); }
.btn-sm{ padding:6px 12px; font-size:12px; }
.btn-block{ width:100%; }

.search-input, .select, .textarea, .field-input{
  background: rgba(255,255,255,0.04); border:1px solid var(--panel-border); color:var(--text);
  border-radius: 10px; padding: 10px 13px; font-size:13.5px; outline:none; transition:border-color .15s;
  font-family: inherit;
}
.search-input:focus, .select:focus, .textarea:focus, .field-input:focus{ border-color: var(--violet); }
.textarea{ width:100%; resize: vertical; line-height:1.55; }
.search-input{ width:240px; }

/* ---------------- Tables ---------------- */
.table-wrap{ overflow-x:auto; }
table.data-table{ width:100%; border-collapse: collapse; font-size:13.3px; }
table.data-table th{
  text-align:left; padding: 10px 14px; color: var(--text-faint); font-weight:600; font-size:11.5px;
  text-transform:uppercase; letter-spacing:.4px; border-bottom:1px solid var(--panel-border);
}
table.data-table td{ padding: 13px 14px; border-bottom:1px solid rgba(255,255,255,.045); vertical-align:middle; }
table.data-table tr:last-child td{ border-bottom:none; }
table.data-table tr.clickable{ cursor:pointer; transition: background .12s; }
table.data-table tr.clickable:hover{ background: rgba(167,139,250,.06); }

.pill{ display:inline-flex; align-items:center; gap:6px; padding:4px 11px; border-radius:20px; font-size:11.5px; font-weight:600; white-space:nowrap; }
.pill-emerald{ background: rgba(52,211,153,.15); color: var(--emerald); }
.pill-amber{ background: rgba(251,191,36,.15); color: var(--amber); }
.pill-violet{ background: rgba(167,139,250,.15); color: var(--violet); }
.pill-red{ background: rgba(251,113,133,.15); color: var(--red); }
.pill-gray{ background: rgba(255,255,255,.08); color: var(--text-dim); }

.avatar{
  width:30px; height:30px; border-radius:9px; display:inline-flex; align-items:center; justify-content:center;
  background: linear-gradient(135deg, var(--violet-2), var(--cyan)); font-size:12px; font-weight:700; color:#0a0a12;
  margin-right:10px; flex-shrink:0;
}
.user-cell{ display:flex; align-items:center; }

/* ---------------- Toggle switches ---------------- */
.toggle-row{ display:flex; align-items:center; justify-content:space-between; padding: 13px 2px; border-bottom:1px solid rgba(255,255,255,.05); }
.toggle-row:last-child{ border-bottom:none; }
.toggle-row.big{ padding: 20px 4px; }
.toggle-title{ font-size:14px; font-weight:600; }
.toggle-desc{ font-size:12px; color:var(--text-dim); margin-top:3px; max-width:360px; }
.switch{ position:relative; display:inline-block; width:46px; height:26px; flex-shrink:0; }
.switch input{ opacity:0; width:0; height:0; }
.slider{ position:absolute; cursor:pointer; inset:0; background: rgba(255,255,255,.12); border-radius:20px; transition:.2s; }
.slider::before{ content:""; position:absolute; width:20px; height:20px; left:3px; top:3px; background:#fff; border-radius:50%; transition:.2s; }
.switch input:checked + .slider{ background: linear-gradient(135deg, var(--violet-2), var(--cyan)); }
.switch input:checked + .slider::before{ transform: translateX(20px); }

/* ---------------- Cards grid (accounts) ---------------- */
.cards-grid{ display:grid; grid-template-columns: repeat(auto-fill, minmax(280px,1fr)); gap:16px; }
.account-card{ background: var(--panel); border:1px solid var(--panel-border); border-radius: var(--radius); padding:18px 20px; transition: border-color .15s, transform .15s; }
.account-card:hover{ border-color: var(--panel-border-hover); transform: translateY(-2px); }
.account-card h3{ margin:0 0 4px; font-size:15px; }
.account-card .acc-meta{ font-size:12px; color:var(--text-faint); margin-bottom:12px; }
.acc-chips{ display:flex; flex-wrap:wrap; gap:6px; }
.acc-chip{ font-size:11.5px; padding:4px 9px; border-radius:8px; background: rgba(255,255,255,.06); border:1px solid var(--panel-border); }

/* ---------------- Modals ---------------- */
.modal-overlay{
  position:fixed; inset:0; background: rgba(4,4,10,.72); backdrop-filter: blur(6px);
  display:none; align-items:center; justify-content:center; z-index:50; padding:24px;
}
.modal-overlay.open{ display:flex; }
.modal{
  width:560px; max-width:100%; max-height:88vh; overflow-y:auto;
  background: linear-gradient(180deg, rgba(20,20,34,.98), rgba(12,12,22,.98));
  border:1px solid var(--panel-border); border-radius:20px; padding:26px 28px;
  box-shadow: 0 40px 100px rgba(0,0,0,.6);
}
.modal h2{ margin:0 0 4px; font-size:18px; }
.modal .modal-sub{ color:var(--text-dim); font-size:12.5px; margin-bottom:20px; }
.modal-close{ float:right; background:none; border:none; color:var(--text-faint); font-size:18px; cursor:pointer; }
.field{ margin-bottom:14px; }
.field label{ display:block; font-size:12px; color:var(--text-dim); margin-bottom:6px; }
.field-input{ width:100%; }
.field-row{ display:flex; gap:10px; }
.field-row .field{ flex:1; }

.dropzone{
  border:1.5px dashed var(--panel-border); border-radius:14px; padding:26px; text-align:center;
  color: var(--text-dim); font-size:13px; cursor:pointer; transition: border-color .15s, background .15s;
  margin-bottom:16px;
}
.dropzone:hover, .dropzone.drag{ border-color: var(--violet); background: rgba(167,139,250,.05); }
.dropzone img{ max-width:100%; max-height:180px; border-radius:10px; margin-top:10px; }

.checkbox-row{ display:flex; align-items:center; gap:8px; font-size:12.5px; color:var(--text-dim); }
.broadcast-controls{ display:flex; gap:10px; margin-top:14px; align-items:center; flex-wrap:wrap; }

.tg-preview{ background:#0e1621; border-radius:14px; padding:18px; }
.tg-bubble{ background:#1f2c38; color:#e9edef; padding:12px 14px; border-radius:12px 12px 12px 3px; font-size:13.5px; line-height:1.5; white-space:pre-wrap; margin-bottom:10px; }
.tg-btn{ display:inline-block; background:#2b5278; color:#8ab4f8; padding:8px 16px; border-radius:8px; font-size:13px; text-align:center; }

.history-item{ padding:12px 0; border-bottom:1px solid rgba(255,255,255,.05); font-size:12.8px; }
.history-item:last-child{ border-bottom:none; }
.history-text{ color:var(--text); margin-bottom:5px; line-height:1.4; }
.history-meta{ color:var(--text-faint); font-size:11.5px; }

.toast{
  position:fixed; bottom:26px; left:50%; transform: translateX(-50%) translateY(20px);
  background: rgba(20,20,34,.95); border:1px solid var(--panel-border-hover); color:#fff;
  padding:12px 22px; border-radius:12px; font-size:13px; opacity:0; pointer-events:none;
  transition: all .25s; z-index:100; box-shadow: 0 12px 30px rgba(0,0,0,.5);
}
.toast.show{ opacity:1; transform: translateX(-50%) translateY(0); }

.empty-state{ text-align:center; padding: 40px 20px; color: var(--text-faint); font-size:13px; }

@media (max-width: 980px){
  .stat-grid{ grid-template-columns: repeat(2,1fr); }
  .panel-row{ grid-template-columns: 1fr; }
}
