:root {
  --bg: #0a0a0f;
  --ink: #e4e4e7;
  --strong: #ffffff;
  --muted: #a1a1aa;
  --dim: #71717a;
  --accent: #6366f1;
  --accent-soft: #a5b4fc;
  --ok: #22c55e;
  --warn: #f59e0b;
  --bad: #ef4444;
  --card: rgba(255, 255, 255, .03);
  --border: 1px solid rgba(255, 255, 255, .06);
}

* { box-sizing: border-box; }

/* Атрибут hidden должен побеждать авторские display: у .login-wrap и .modal
   задан display:flex, и без этого правила «скрытые» блоки оставались бы
   видимыми (форма логина и пустая модалка поверх дашборда). */
[hidden] { display: none !important; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 14px/1.5 Inter, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  background-image: linear-gradient(rgba(255,255,255,.03) 1px, transparent 1px),
                    linear-gradient(90deg, rgba(255,255,255,.03) 1px, transparent 1px);
  background-size: 60px 60px;
  pointer-events: none;
  z-index: 0;
}

h1, h2, h3 { color: var(--strong); margin: 0; }
h2 { font-size: 17px; letter-spacing: -.2px; }
h3 { font-size: 14px; margin-bottom: 10px; }
.muted { color: var(--muted); }
.dim { color: var(--dim); }
.error { color: var(--bad); font-size: 13px; margin-top: 8px; }

/* ---------- login ---------- */
.login-wrap {
  position: relative; z-index: 1;
  min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px;
}
.login-card {
  width: 100%; max-width: 360px; background: var(--card); border: var(--border);
  border-radius: 16px; padding: 28px; text-align: center; backdrop-filter: blur(8px);
}
.login-logo { width: 56px; height: 42px; object-fit: contain; }
.login-card h1 { font-size: 22px; margin: 10px 0 4px; }
.login-card .muted { font-size: 13px; margin: 0 0 18px; }
.login-card input { width: 100%; margin-bottom: 12px; }

/* ---------- layout ---------- */
.topbar {
  position: relative; z-index: 1;
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 22px; border-bottom: var(--border); background: rgba(10,10,15,.85);
  backdrop-filter: blur(10px); position: sticky; top: 0;
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand .logo { width: 40px; height: 30px; object-fit: contain; }
.brand span { display: block; font-size: 12px; }
.topbar-actions { display: flex; align-items: center; gap: 10px; }
.badge {
  font-size: 12px; padding: 3px 10px; border-radius: 100px;
  background: rgba(99,102,241,.12); border: 1px solid rgba(99,102,241,.2); color: var(--accent-soft);
}

main { position: relative; z-index: 1; max-width: 1400px; margin: 0 auto; padding: 22px; }

.cards {
  display: grid; gap: 12px; margin-bottom: 20px;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
}
.card { background: var(--card); border: var(--border); border-radius: 16px; padding: 14px 16px; }
.card-label { font-size: 12px; color: var(--muted); }
.card-value { font-size: 22px; font-weight: 700; color: var(--strong); margin-top: 4px; }

.panel {
  background: var(--card); border: var(--border); border-radius: 16px;
  padding: 18px; margin-bottom: 20px;
}
.panel-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.panel-head-actions { display: flex; gap: 8px; }

/* ---------- controls ---------- */
input, select, textarea {
  background: rgba(255,255,255,.04); border: var(--border); border-radius: 10px;
  color: var(--ink); padding: 8px 11px; font: inherit; outline: none; width: 100%;
}
input:focus, select:focus, textarea:focus { border-color: rgba(99,102,241,.55); }
textarea { resize: vertical; }
select option { background: #111118; color: var(--ink); }

.btn {
  border: 1px solid transparent; border-radius: 12px; padding: 8px 14px;
  font: inherit; font-weight: 500; cursor: pointer; white-space: nowrap;
}
.btn-primary { background: linear-gradient(135deg, #6366f1, #8b5cf6); color: #fff; }
.btn-primary:hover { filter: brightness(1.08); }
.btn-ghost { background: rgba(255,255,255,.05); border: var(--border); color: var(--ink); }
.btn-ghost:hover { background: rgba(255,255,255,.09); }
.btn:disabled { opacity: .45; cursor: not-allowed; }

.filters {
  display: grid; gap: 10px; margin-bottom: 14px;
  grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
  align-items: end;
}
.filters .inline { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); grid-column: span 2; }
.filters .inline input { width: 84px; }
.filters .btn { height: 36px; }

/* ---------- table ---------- */
.table-wrap { overflow-x: auto; border: var(--border); border-radius: 12px; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
thead th {
  text-align: left; padding: 10px 12px; color: var(--muted); font-weight: 500; font-size: 12px;
  background: rgba(255,255,255,.02); border-bottom: var(--border); white-space: nowrap;
}
tbody td { padding: 10px 12px; border-bottom: 1px solid rgba(255,255,255,.04); vertical-align: middle; }
tbody tr:hover { background: rgba(255,255,255,.02); }
tbody tr:last-child td { border-bottom: none; }
.col-check { width: 34px; }
.col-check input { width: auto; }

.tag {
  display: inline-block; font-size: 11px; padding: 2px 8px; border-radius: 100px;
  border: 1px solid rgba(255,255,255,.1); color: var(--muted); white-space: nowrap;
}
.tag-active { background: rgba(34,197,94,.12); border-color: rgba(34,197,94,.25); color: #86efac; }
.tag-expired { background: rgba(239,68,68,.12); border-color: rgba(239,68,68,.25); color: #fca5a5; }
.tag-none { background: rgba(255,255,255,.05); color: var(--dim); }
.tag-over { background: rgba(245,158,11,.12); border-color: rgba(245,158,11,.25); color: #fcd34d; }

.bar { width: 110px; height: 6px; border-radius: 3px; background: rgba(255,255,255,.08); overflow: hidden; margin-top: 4px; }
.bar span { display: block; height: 100%; background: linear-gradient(135deg, #6366f1, #8b5cf6); }
.bar span.over { background: linear-gradient(135deg, #f59e0b, #ef4444); }

.pager { display: flex; align-items: center; justify-content: center; gap: 14px; margin-top: 14px; font-size: 13px; }

/* ---------- broadcast ---------- */
.broadcast-grid { display: grid; gap: 20px; grid-template-columns: minmax(320px, 1fr) minmax(280px, 420px); }
.broadcast-form label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 10px; }
.broadcast-form input, .broadcast-form select, .broadcast-form textarea { margin-top: 5px; }
.channels { display: flex; gap: 18px; margin: 4px 0 14px; }
.check { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--ink); }
.check input { width: auto; }
.broadcast-actions { display: flex; gap: 10px; margin-bottom: 10px; }

.broadcast-log { border-left: var(--border); padding-left: 18px; }
.log-item { padding: 10px 0; border-bottom: 1px solid rgba(255,255,255,.05); font-size: 12px; }
.log-item:last-child { border-bottom: none; }
.log-head { display: flex; justify-content: space-between; gap: 10px; }
.log-sub { color: var(--dim); margin-top: 3px; }

/* ---------- modal ---------- */
.modal {
  position: fixed; inset: 0; z-index: 50; background: rgba(0,0,0,.7);
  display: flex; align-items: center; justify-content: center; padding: 24px;
}
.modal-card {
  width: 100%; max-width: 720px; max-height: 86vh; overflow: auto;
  background: #101017; border: var(--border); border-radius: 16px; padding: 20px;
}
.modal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.modal-body { font-size: 13px; }
.detail-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 10px; margin-bottom: 16px; }
.detail-grid div { background: rgba(255,255,255,.03); border: var(--border); border-radius: 10px; padding: 9px 11px; }
.detail-grid span { display: block; font-size: 11px; color: var(--muted); }
.detail-grid strong { color: var(--strong); font-weight: 600; word-break: break-word; }

.toast {
  position: fixed; right: 20px; bottom: 20px; z-index: 100;
  background: #1b1b25; border: var(--border); border-left: 3px solid var(--accent);
  border-radius: 12px; padding: 12px 16px; max-width: 380px; font-size: 13px;
}
.toast.bad { border-left-color: var(--bad); }
.toast.good { border-left-color: var(--ok); }

@media (max-width: 900px) {
  .broadcast-grid { grid-template-columns: 1fr; }
  .broadcast-log { border-left: none; border-top: var(--border); padding: 16px 0 0; }
}
