:root {
  --bg: #0b0f17;
  --bg-soft: #111726;
  --card: #141b2b;
  --card-2: #182033;
  --line: #223049;
  --text: #e8edf7;
  --muted: #8b9ac0;
  --accent: #4f8cff;
  --accent-2: #2ee6a8;
  --warn: #ffb020;
  --danger: #ff5d6c;
  --radius: 14px;
  --shadow: 0 10px 30px rgba(0, 0, 0, .35);
  font-size: 16px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: radial-gradient(1200px 600px at 80% -10%, #1b2540 0%, var(--bg) 55%) fixed;
  color: var(--text);
  font-family: "Inter", "Segoe UI", system-ui, -apple-system, sans-serif;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---------------------------------------------------------------- layout */

.shell { display: flex; min-height: 100vh; }

.sidebar {
  width: 240px;
  flex-shrink: 0;
  padding: 22px 16px;
  border-right: 1px solid var(--line);
  background: rgba(10, 14, 22, .6);
  backdrop-filter: blur(8px);
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.logo {
  font-weight: 700;
  font-size: 1.25rem;
  letter-spacing: -.02em;
  padding: 6px 10px 18px;
  display: flex;
  align-items: center;
  gap: 9px;
}
.logo .dot {
  width: 10px; height: 10px; border-radius: 50%;
  background: var(--accent-2);
  box-shadow: 0 0 14px var(--accent-2);
}

.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px;
  border-radius: 10px;
  color: var(--muted);
  font-weight: 500;
  font-size: .93rem;
}
.nav-item:hover { background: var(--card); color: var(--text); text-decoration: none; }
.nav-item.active { background: linear-gradient(90deg, rgba(79,140,255,.18), transparent); color: var(--text); }
.nav-item.active::before {
  content: ""; width: 3px; height: 18px; border-radius: 3px; background: var(--accent);
  margin-left: -12px; margin-right: 9px;
}

.sidebar-footer { margin-top: auto; border-top: 1px solid var(--line); padding-top: 14px; }
.sidebar-user { font-size: .82rem; color: var(--muted); padding: 0 12px 10px; }

.content { flex: 1; padding: 26px 30px 60px; max-width: 1500px; min-width: 0; }

.page-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; flex-wrap: wrap; margin-bottom: 22px;
}
h1 { font-size: 1.5rem; margin: 0; letter-spacing: -.02em; }
h2 { font-size: 1.05rem; margin: 0 0 14px; letter-spacing: -.01em; }
h3 { font-size: .95rem; margin: 0 0 10px; }
.sub { color: var(--muted); font-size: .85rem; margin-top: 4px; }

/* ---------------------------------------------------------------- cards */

.card {
  background: linear-gradient(180deg, var(--card-2), var(--card));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow);
}
.card + .card { margin-top: 18px; }

.grid { display: grid; gap: 18px; }
.grid.kpi { grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); }
.grid.two { grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); }
.grid.three { grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }
.grid + .grid, .grid + .card, .card + .grid { margin-top: 18px; }

.kpi-card .label { color: var(--muted); font-size: .78rem; text-transform: uppercase; letter-spacing: .07em; }
.kpi-card .value { font-size: 2rem; font-weight: 700; margin-top: 8px; letter-spacing: -.03em; }
.kpi-card .hint { color: var(--muted); font-size: .8rem; margin-top: 6px; }
.delta { font-size: .8rem; font-weight: 600; }
.delta.up { color: var(--accent-2); }
.delta.down { color: var(--danger); }

/* ---------------------------------------------------------------- controls */

.toolbar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

.chip {
  padding: 7px 13px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--muted);
  font-size: .84rem;
  font-weight: 500;
}
.chip:hover { color: var(--text); text-decoration: none; border-color: var(--accent); }
.chip.active { background: var(--accent); border-color: var(--accent); color: #fff; }

.btn {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 9px 16px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--card-2);
  color: var(--text);
  font-size: .88rem;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
}
.btn:hover { border-color: var(--accent); text-decoration: none; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { filter: brightness(1.08); }
.btn.ghost { background: transparent; }
.btn.danger { color: var(--danger); border-color: rgba(255,93,108,.35); background: rgba(255,93,108,.08); }
.btn.sm { padding: 6px 11px; font-size: .8rem; border-radius: 8px; }

input[type="text"], input[type="password"], input[type="number"], input[type="url"], select, textarea {
  width: 100%;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: #0e1524;
  color: var(--text);
  font-size: .9rem;
  font-family: inherit;
  outline: none;
}
input:focus, select:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(79,140,255,.15); }
textarea { min-height: 70px; resize: vertical; }
label.field { display: block; margin-bottom: 12px; }
label.field > span { display: block; font-size: .78rem; color: var(--muted); margin-bottom: 6px; letter-spacing: .03em; }
.check { display: flex; align-items: center; gap: 8px; font-size: .87rem; color: var(--muted); }
.check input { width: 16px; height: 16px; accent-color: var(--accent); }

.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 0 16px; }
.form-actions { display: flex; gap: 10px; align-items: center; margin-top: 6px; flex-wrap: wrap; }

/* ---------------------------------------------------------------- table */

table { width: 100%; border-collapse: collapse; font-size: .88rem; }
th {
  text-align: left; color: var(--muted); font-weight: 600; font-size: .74rem;
  text-transform: uppercase; letter-spacing: .07em;
  padding: 0 12px 10px; border-bottom: 1px solid var(--line);
}
td { padding: 12px; border-bottom: 1px solid rgba(34,48,73,.55); vertical-align: middle; }
tr:last-child td { border-bottom: none; }
tr:hover td { background: rgba(79,140,255,.045); }
.table-wrap { overflow-x: auto; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }

.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 9px; border-radius: 999px;
  font-size: .74rem; font-weight: 600;
  background: var(--bg-soft); color: var(--muted); border: 1px solid var(--line);
}
.badge.on { color: var(--accent-2); border-color: rgba(46,230,168,.3); background: rgba(46,230,168,.08); }
.badge.off { color: var(--muted); }
.badge.bot { color: var(--warn); border-color: rgba(255,176,32,.3); background: rgba(255,176,32,.08); }
.badge.ios { color: #d7c7ff; }
.badge.android { color: #a6e7a6; }

code.slug {
  font-family: "JetBrains Mono", ui-monospace, Menlo, Consolas, monospace;
  font-size: .84rem;
  background: #0e1524;
  border: 1px solid var(--line);
  padding: 3px 8px;
  border-radius: 7px;
}

.muted { color: var(--muted); }
.small { font-size: .8rem; }
.nowrap { white-space: nowrap; }
.truncate { max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: inline-block; vertical-align: bottom; }

/* ---------------------------------------------------------------- bars / charts */

.bar-row { display: grid; grid-template-columns: 1fr auto; gap: 4px 12px; margin-bottom: 13px; align-items: center; }
.bar-row .bar-label { font-size: .86rem; }
.bar-row .bar-value { font-size: .86rem; font-variant-numeric: tabular-nums; color: var(--muted); }
.bar-track { grid-column: 1 / -1; height: 7px; border-radius: 999px; background: #0e1524; overflow: hidden; }
.bar-fill { height: 100%; border-radius: 999px; background: linear-gradient(90deg, var(--accent), #7aa8ff); }
.bar-fill.alt { background: linear-gradient(90deg, var(--accent-2), #7df0cd); }
.bar-fill.warn { background: linear-gradient(90deg, var(--warn), #ffd27a); }

.chart { width: 100%; height: 260px; }
.legend { display: flex; gap: 16px; flex-wrap: wrap; font-size: .8rem; color: var(--muted); margin-top: 10px; }
.legend span.key { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }

.empty { text-align: center; color: var(--muted); padding: 30px 10px; font-size: .88rem; }

/* ---------------------------------------------------------------- flash */

.flash {
  padding: 12px 16px; border-radius: 12px; margin-bottom: 18px;
  font-size: .88rem; border: 1px solid;
}
.flash.ok { background: rgba(46,230,168,.09); border-color: rgba(46,230,168,.3); color: #a7f5da; }
.flash.err { background: rgba(255,93,108,.09); border-color: rgba(255,93,108,.3); color: #ffc3c9; }

/* ---------------------------------------------------------------- login */

.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.login-card { width: 100%; max-width: 380px; }
.login-card h1 { margin-bottom: 6px; }

/* ---------------------------------------------------------------- public */

.pub {
  min-height: 100vh; display: grid; place-items: center; padding: 24px; text-align: center;
}
.pub-card { max-width: 420px; width: 100%; }
.pub-card .tg-icon {
  width: 74px; height: 74px; border-radius: 50%; margin: 0 auto 18px;
  background: linear-gradient(135deg, #2aabee, #229ed9);
  display: grid; place-items: center; box-shadow: 0 12px 34px rgba(34,158,217,.35);
}
.pub-card h1 { font-size: 1.35rem; margin-bottom: 8px; }
.pub-card p { color: var(--muted); font-size: .92rem; line-height: 1.55; margin: 0 0 22px; }
.btn-tg {
  display: block; width: 100%; padding: 15px 20px; border-radius: 14px;
  background: linear-gradient(135deg, #2aabee, #229ed9); color: #fff;
  font-weight: 700; font-size: 1rem; border: none; cursor: pointer; font-family: inherit;
}
.btn-tg:hover { filter: brightness(1.06); text-decoration: none; }
.pub-hint { font-size: .78rem; color: var(--muted); margin-top: 16px; }

/* ---------------------------------------------------------------- responsive */

@media (max-width: 900px) {
  .shell { flex-direction: column; }
  .sidebar {
    width: 100%; height: auto; position: static; flex-direction: row;
    overflow-x: auto; align-items: center; padding: 12px;
  }
  .logo { padding: 0 12px 0 4px; }
  .sidebar-footer { margin-top: 0; border: none; padding-top: 0; }
  .sidebar-user { display: none; }
  .nav-item.active::before { display: none; }
  .content { padding: 18px 14px 50px; }
}
