:root {
  --bg: #0b1222;
  --panel: #111a2f;
  --panel-2: #17243d;
  --text: #f7fbff;
  --muted: #9fb0c9;
  --line: rgba(255,255,255,.11);
  --blue: #35a1ff;
  --cyan: #15c8ff;
  --violet: #8a57f7;
  --green: #27d17f;
  --red: #ff5b6e;
  --shadow: 0 18px 50px rgba(0,0,0,.35);
}

* { box-sizing: border-box; }
html { min-height: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  background: radial-gradient(circle at 20% 0%, rgba(53,161,255,.18), transparent 28%), var(--bg);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
a { color: inherit; text-decoration: none; }
button, input, select { font: inherit; }
button { cursor: pointer; }
.muted { color: var(--muted); }

.shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 280px 1fr;
}
.sidebar {
  border-right: 1px solid var(--line);
  background: rgba(10,17,31,.82);
  padding: 24px;
  position: sticky;
  top: 0;
  height: 100vh;
}
.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 20px;
  font-weight: 800;
  margin-bottom: 28px;
}
.brand-mark {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--cyan), var(--violet));
  box-shadow: 0 0 30px rgba(53,161,255,.35);
}
.nav {
  display: grid;
  gap: 8px;
}
.nav button, .ghost, .primary, .danger, .small-btn {
  border: 0;
  color: var(--text);
  border-radius: 10px;
  padding: 12px 14px;
  background: rgba(255,255,255,.07);
  transition: transform .15s ease, background .15s ease, box-shadow .15s ease;
}
.nav button {
  text-align: left;
  color: var(--muted);
}
.nav button.active, .nav button:hover {
  color: var(--text);
  background: linear-gradient(135deg, rgba(53,161,255,.28), rgba(138,87,247,.22));
}
.content {
  padding: 28px;
  max-width: 1280px;
  width: 100%;
  margin: 0 auto;
}
.topbar {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
  margin-bottom: 24px;
}
.title h1 { margin: 0; font-size: 28px; }
.title p { margin: 6px 0 0; color: var(--muted); }
.grid { display: grid; gap: 16px; }
.stats { grid-template-columns: repeat(3, minmax(0, 1fr)); margin-bottom: 22px; }
.stat, .surface, .login-box {
  background: rgba(17,26,47,.86);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: var(--shadow);
}
.stat { padding: 20px; }
.stat span { color: var(--muted); font-size: 14px; }
.stat strong { display: block; font-size: 34px; margin-top: 8px; }
.surface { padding: 18px; margin-bottom: 18px; }
.surface h2 {
  margin: 0 0 14px;
  font-size: 18px;
}
.form-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  align-items: end;
}
label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 13px;
}
input, select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px;
  color: var(--text);
  background: rgba(5,10,20,.72);
  outline: none;
}
input:focus, select:focus { border-color: rgba(53,161,255,.8); }
.primary {
  background: linear-gradient(135deg, var(--cyan), var(--violet));
  font-weight: 800;
  box-shadow: 0 10px 26px rgba(53,161,255,.25);
}
.danger { background: rgba(255,91,110,.18); color: #ffd8de; }
.ghost { background: rgba(255,255,255,.08); color: var(--muted); }
.small-btn { padding: 8px 10px; border-radius: 8px; font-size: 13px; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; min-width: 800px; }
th, td {
  padding: 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: middle;
}
th { color: var(--muted); font-size: 13px; font-weight: 700; }
.badge {
  display: inline-flex;
  border-radius: 999px;
  padding: 5px 9px;
  font-size: 12px;
  background: rgba(39,209,127,.16);
  color: #98ffc8;
}
.badge.blocked, .badge.expired { background: rgba(255,91,110,.17); color: #ffc7cf; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; }
.login-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}
.login-box {
  width: min(440px, 100%);
  padding: 28px;
}
.login-box h1 { margin: 0 0 8px; }
.login-box p { margin: 0 0 20px; color: var(--muted); }
.login-box form { display: grid; gap: 12px; }
.tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 12px;
  margin-bottom: 16px;
  background: rgba(255,255,255,.04);
}
.tabs button {
  border: 0;
  border-radius: 9px;
  padding: 10px;
  background: transparent;
  color: var(--muted);
}
.tabs button.active { background: rgba(255,255,255,.1); color: var(--text); }
.notice {
  min-height: 22px;
  color: #ffc7cf;
  font-size: 14px;
}
.hidden { display: none !important; }

.public-page {
  min-height: 100vh;
  padding: 52px 20px;
}
.public-wrap {
  width: min(1100px, 100%);
  margin: 0 auto;
}
.public-head {
  display: grid;
  justify-items: center;
  gap: 16px;
  margin-bottom: 28px;
  text-align: center;
}
.public-title {
  display: flex;
  align-items: center;
  gap: 14px;
}
.public-title img, .logo-preview {
  width: 58px;
  height: 58px;
  object-fit: cover;
  border-radius: 13px;
  background: rgba(255,255,255,.08);
  border: 1px solid var(--line);
}
.public-title h1 {
  margin: 0;
  font-size: 30px;
  color: #5fa5ff;
}
.code-search {
  display: flex;
  width: min(520px, 100%);
  gap: 10px;
}
.code-search input { height: 48px; }
.theme-toggle {
  border: 0;
  border-radius: 10px;
  padding: 10px 16px;
  color: #fff;
  background: linear-gradient(135deg, #08b9e8, #995ff5);
  font-weight: 800;
}
.panel-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 18px;
}
.iptv-card {
  min-height: 104px;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 18px;
  border-radius: 16px;
  background: linear-gradient(135deg, #3aa0f7, #9356ed);
  box-shadow: 0 0 12px rgba(71,166,255,.7), 0 12px 32px rgba(0,0,0,.32);
  border: 1px solid rgba(255,255,255,.2);
}
.iptv-card:hover { transform: translateY(-2px); }
.iptv-card img {
  width: 66px;
  height: 66px;
  object-fit: cover;
  border-radius: 10px;
  border: 2px solid rgba(255,255,255,.7);
  background: #111;
}
.iptv-card strong { display: block; font-size: 17px; margin-bottom: 4px; }
.iptv-card span { color: rgba(255,255,255,.78); font-size: 13px; word-break: break-word; }
.empty {
  text-align: center;
  color: var(--muted);
  padding: 28px;
  border: 1px dashed var(--line);
  border-radius: 14px;
}
.client-layout {
  display: grid;
  grid-template-columns: 360px 1fr;
  gap: 18px;
}
.preview-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 8px 0 16px;
}

body.light {
  --bg: #eef4fb;
  --panel: #ffffff;
  --panel-2: #f5f8fd;
  --text: #142033;
  --muted: #5d6f88;
  --line: rgba(20,32,51,.13);
  background: linear-gradient(180deg, #f7fbff, #e8f0fb);
}
body.light .sidebar, body.light .surface, body.light .stat, body.light .login-box {
  background: rgba(255,255,255,.92);
}
body.light input, body.light select { background: #fff; }

@media (max-width: 960px) {
  .shell, .client-layout { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; }
  .form-grid, .stats, .panel-grid { grid-template-columns: 1fr; }
  .content { padding: 18px; }
  .topbar, .code-search { flex-direction: column; align-items: stretch; }
}
