:root {
  --bg: #0b1120;
  --panel: #111a2e;
  --panel-2: #16213c;
  --border: #243049;
  --text: #e5edff;
  --muted: #8a98b8;
  --primary: #6366f1;
  --primary-2: #818cf8;
  --danger: #ef4444;
  --ok: #22c55e;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  background:
    radial-gradient(900px 500px at 100% -10%, rgba(99,102,241,.18), transparent 60%),
    radial-gradient(700px 500px at -10% 110%, rgba(45,212,191,.12), transparent 55%),
    var(--bg);
  background-attachment: fixed;
  color: var(--text);
}
.hidden { display: none !important; }
.muted { color: var(--muted); }
.error { color: var(--danger); font-size: 13px; margin-top: 8px; min-height: 16px; }

/* LOGIN */
.login { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px; }
.login-card {
  background: var(--panel); border: 1px solid var(--border); border-radius: 16px;
  padding: 32px; width: 100%; max-width: 360px; display: flex; flex-direction: column; gap: 12px;
}
.login-card h1 { margin: 0; font-size: 26px; }
.login-card p { margin: 0 0 8px; }

/* LAYOUT */
.app { display: flex; min-height: 100vh; }
.sidebar {
  width: 230px; background: var(--panel); border-right: 1px solid var(--border);
  padding: 20px 14px; display: flex; flex-direction: column; gap: 6px; position: sticky; top: 0; height: 100vh;
}
.brand { font-size: 20px; font-weight: 800; padding: 6px 10px 16px; }
.sidebar nav { display: flex; flex-direction: column; gap: 4px; }
.sidebar nav a {
  padding: 11px 12px; border-radius: 10px; color: var(--muted); cursor: pointer;
  font-size: 14px; font-weight: 600; text-decoration: none;
}
.sidebar nav a:hover { background: var(--panel-2); color: var(--text); }
.sidebar nav a.active { background: var(--primary); color: #fff; }
.logout { margin-top: auto; }
.content { flex: 1; padding: 28px 32px; overflow-x: hidden; }

/* TYPOGRAPHY */
h2 { margin: 0 0 4px; font-size: 24px; }
.view > p.sub { color: var(--muted); margin: 0 0 22px; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 12px; }

/* BUTTONS */
.btn {
  border: 1px solid var(--border); background: var(--panel-2); color: var(--text);
  padding: 10px 16px; border-radius: 10px; font-size: 14px; font-weight: 600; cursor: pointer;
}
.btn:hover { filter: brightness(1.1); }
.btn.primary { background: linear-gradient(135deg, var(--primary), var(--primary-2)); border-color: var(--primary); color: #fff; }
.btn.danger { background: transparent; border-color: var(--danger); color: var(--danger); }
.btn.ghost { background: transparent; }
.btn.sm { padding: 6px 10px; font-size: 13px; }

/* INPUTS */
input, textarea, select {
  background: var(--bg); border: 1px solid var(--border); color: var(--text);
  padding: 11px 12px; border-radius: 10px; font-size: 14px; width: 100%; font-family: inherit;
}
input:focus, textarea:focus, select:focus { outline: 2px solid var(--primary); border-color: var(--primary); }
label { display: block; font-size: 13px; color: var(--muted); margin: 12px 0 6px; font-weight: 600; }
textarea { resize: vertical; min-height: 70px; }

/* CARDS / GRID */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 14px; }
.card {
  background: var(--panel); border: 1px solid var(--border); border-radius: 14px; padding: 16px;
  transition: transform .12s ease, border-color .15s ease;
}
.card.stat:hover { transform: translateY(-3px); border-color: var(--primary); }
.stat .num { font-size: 30px; font-weight: 800;
  background: linear-gradient(135deg, var(--text), var(--primary-2));
  -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent; }
.stat .lbl { color: var(--muted); font-size: 13px; }

.list { display: flex; flex-direction: column; gap: 10px; }
.item {
  background: var(--panel); border: 1px solid var(--border); border-radius: 12px;
  padding: 14px 16px; display: flex; align-items: center; justify-content: space-between; gap: 12px;
}
.item .meta { min-width: 0; }
.item .title { font-weight: 700; }
.item .desc { color: var(--muted); font-size: 13px; word-break: break-all; }
.item .actions { display: flex; gap: 8px; flex-shrink: 0; }
.tag { display: inline-block; font-size: 11px; padding: 2px 8px; border-radius: 999px; background: var(--panel-2); color: var(--muted); margin-left: 6px; }
.tag.cloak { background: #3b1d1d; color: #fda4a4; }
.tag.ok { background: #14321f; color: #86efac; }

/* MODAL */
.modal { position: fixed; inset: 0; background: rgba(0,0,0,.6); display: flex; align-items: flex-start;
         justify-content: center; padding: 40px 16px; overflow-y: auto; z-index: 50; }
.modal-card { background: var(--panel); border: 1px solid var(--border); border-radius: 16px;
              padding: 24px; width: 100%; max-width: 560px; }
.modal-card h3 { margin: 0 0 14px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 20px; }

/* BUTTON EDITOR ROW */
.btn-editor { background: var(--panel-2); border: 1px solid var(--border); border-radius: 12px; padding: 14px; margin-bottom: 12px; }
.btn-editor .head { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.hint { font-size: 12px; color: var(--muted); margin-top: 4px; }
.color-row { display: flex; gap: 8px; align-items: center; }
.color-row input[type=color] { width: 46px; padding: 2px; height: 42px; }

/* TOAST */
.toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
         background: var(--ok); color: #04210f; padding: 12px 20px; border-radius: 10px; font-weight: 700; z-index: 100; }
.toast.err { background: var(--danger); color: #fff; }

/* THEME SWATCHES */
.swatches { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 6px; }
.swatch {
  width: 70px; height: 46px; border-radius: 10px; border: 2px solid var(--border); cursor: pointer;
  position: relative; overflow: hidden; padding: 0; color: #fff;
}
.swatch span {
  position: absolute; bottom: 0; left: 0; right: 0; font-size: 10px; font-weight: 700;
  background: rgba(0,0,0,.45); padding: 1px 0; text-align: center; text-transform: capitalize;
}
.swatch.active { border-color: var(--primary-2); box-shadow: 0 0 0 2px var(--primary); }

/* BUTTON EDITOR + LIVE PREVIEW */
.editor-layout { display: grid; grid-template-columns: 1fr 300px; gap: 22px; align-items: start; }
.editor-col { min-width: 0; }
.preview-col { position: sticky; top: 20px; display: flex; flex-direction: column; gap: 10px; align-items: center; }
.phone {
  width: 280px; height: 560px; border-radius: 34px; border: 10px solid #1c2538;
  box-shadow: 0 18px 40px rgba(0,0,0,.45); overflow: hidden; background: #000;
}
.phone iframe { width: 100%; height: 100%; border: 0; }

/* ANALYTICS — country bars */
.bars { display: flex; flex-direction: column; gap: 9px; margin-top: 8px; }
.bar-row { display: grid; grid-template-columns: 70px 1fr 42px; align-items: center; gap: 10px; }
.bar-label { font-size: 13px; font-weight: 600; }
.bar-track { background: var(--bg); border-radius: 999px; height: 12px; overflow: hidden; }
.bar-fill { height: 100%; background: linear-gradient(90deg, var(--primary), var(--primary-2)); border-radius: 999px; }
.bar-val { font-size: 13px; text-align: right; color: var(--muted); }

/* ANALYTICS — daily sparkline */
.sparkline { display: flex; align-items: flex-end; gap: 4px; height: 130px; margin-top: 12px; }
.spark { flex: 1; display: flex; gap: 2px; align-items: flex-end; height: 100%; min-width: 3px; }
.spark-bar { flex: 1; border-radius: 3px 3px 0 0; min-height: 2px; }
.spark-bar.v { background: var(--primary); }
.spark-bar.c { background: #22c55e; }
.legend { font-size: 12px; color: var(--muted); display: flex; gap: 14px; align-items: center; margin-top: 4px; }
.dot { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 4px; vertical-align: middle; }
.dot.v { background: var(--primary); }
.dot.c { background: #22c55e; }
.mini { display: flex; justify-content: space-between; gap: 10px; padding: 6px 0; border-bottom: 1px solid var(--border); font-size: 14px; }
.mini:last-child { border-bottom: none; }
.mini span { color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* BOT DETECTION LIST */
.bot-list { display: flex; flex-direction: column; gap: 8px; max-height: 320px; overflow-y: auto; }
.bot-hit { display: flex; flex-direction: column; gap: 2px; padding: 8px 0; border-bottom: 1px solid var(--border); font-size: 13px; }
.bot-hit:last-child { border-bottom: none; }
.bot-hit .ua { color: var(--muted); font-size: 11px; word-break: break-all; }

@media (max-width: 720px) {
  .editor-layout { grid-template-columns: 1fr; }
  .preview-col { position: static; order: -1; }
  .app { flex-direction: column; }
  .sidebar { width: 100%; height: auto; position: static; flex-direction: row; flex-wrap: wrap; }
  .sidebar nav { flex-direction: row; flex-wrap: wrap; }
  .logout { margin: 0; }
  .grid2 { grid-template-columns: 1fr; }
}
