:root {
  --bg: #0b1222;
  --panel: #111a2f;
  --text: #f7fbff;
  --muted: #9fb0c9;
  --line: rgba(255,255,255,.12);
  --blue: #35a1ff;
  --violet: #8a57f7;
  --red: #ff5b6e;
  --green: #27d17f;
  --shadow: 0 18px 50px rgba(0,0,0,.35);
}
* { box-sizing: border-box; }
body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  background: radial-gradient(circle at 20% 0%, rgba(53,161,255,.2), transparent 30%), 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(7,13,24,.86);
  padding: 24px;
}
.brand { display: flex; align-items: center; gap: 12px; font-size: 20px; font-weight: 800; margin-bottom: 28px; }
.mark {
  width: 42px; height: 42px; display: grid; place-items: center; border-radius: 12px;
  background: linear-gradient(135deg, #15c8ff, var(--violet));
}
.nav { display: grid; gap: 8px; }
.nav a, .btn, button {
  border: 0; border-radius: 10px; padding: 12px 14px; color: var(--text);
  background: rgba(255,255,255,.08);
}
.nav a.active, .nav a:hover { background: linear-gradient(135deg, rgba(53,161,255,.32), rgba(138,87,247,.28)); }
.content { padding: 28px; max-width: 1280px; width: 100%; margin: 0 auto; }
.topbar { display: flex; justify-content: space-between; align-items: center; gap: 16px; margin-bottom: 24px; }
h1, h2 { margin: 0; }
.title p { margin: 7px 0 0; color: var(--muted); }
.grid { display: grid; gap: 16px; }
.stats { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.card, .surface, .login-box {
  background: rgba(17,26,47,.88);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: var(--shadow);
}
.card { padding: 20px; }
.card span { color: var(--muted); }
.card strong { display: block; font-size: 34px; margin-top: 8px; }
.surface { padding: 18px; margin-bottom: 18px; }
.surface h2 { font-size: 18px; margin-bottom: 14px; }
.section-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 14px; }
.section-head h2 { margin-bottom: 0; }
.form-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; align-items: end; }
.url-import { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 12px; align-items: end; }
.compact-help { margin: 10px 0 0; font-size: 13px; }
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, #15c8ff, var(--violet)); font-weight: 800; }
.danger { background: rgba(255,91,110,.18); color: #ffd8de; }
.success { background: rgba(39,209,127,.18); color: #b9ffd8; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; min-width: 850px; }
th, td { padding: 12px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
th { color: var(--muted); font-size: 13px; }
.badge { 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; }
.login-page { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.login-box { width: min(440px, 100%); padding: 28px; }
.login-box form { display: grid; gap: 12px; }
.alert { padding: 12px 14px; border-radius: 10px; margin-bottom: 14px; background: rgba(255,91,110,.16); color: #ffcbd2; }
.ok { background: rgba(39,209,127,.16); color: #b9ffd8; }
.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 { width: 60px; height: 60px; object-fit: cover; border-radius: 12px; border: 1px solid var(--line); background: rgba(255,255,255,.08); }
.public-title h1 { color: #5fa5ff; font-size: 30px; }
.code-search { display: flex; width: min(560px, 100%); gap: 10px; }
.saved-code {
  width: min(560px, 100%);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(255,255,255,.07);
}
.panel-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 18px; }
.iptv-card {
  width: 100%;
  color: #fff;
  text-align: left;
  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; }
body.light { --bg: #eef4fb; --panel: #fff; --text: #142033; --muted: #5d6f88; --line: rgba(20,32,51,.13); background: linear-gradient(180deg, #f7fbff, #e8f0fb); }
body.light .surface, body.light .card, body.light .login-box { background: rgba(255,255,255,.94); }
body.light input, body.light select { background: #fff; }
body.modal-open { overflow: hidden; }
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(3,7,15,.72);
  backdrop-filter: blur(8px);
}
.modal-backdrop[hidden] { display: none; }
.modal {
  width: min(620px, 100%);
  max-height: min(88vh, 820px);
  overflow: auto;
  background: #111a2f;
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: var(--shadow);
  padding: 18px;
}
.modal .btn { display: inline-flex; align-items: center; justify-content: center; }
body.light .modal { background: #fff; }
.modal-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 14px; }
.modal-form { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.modal-form .actions, .modal-form p { grid-column: 1 / -1; }
@media (max-width: 960px) {
  .shell, .client-layout, .stats, .panel-grid, .form-grid, .url-import { grid-template-columns: 1fr; }
  .content { padding: 18px; }
  .code-search, .topbar, .section-head, .saved-code { flex-direction: column; align-items: stretch; }
  .sidebar { padding: 16px; border-right: 0; border-bottom: 1px solid var(--line); }
  .brand { margin-bottom: 14px; }
  .nav { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .modal-form { grid-template-columns: 1fr; }
  .mobile-table { overflow: visible; }
  .mobile-table table, .mobile-table thead, .mobile-table tbody, .mobile-table tr, .mobile-table td { display: block; width: 100%; min-width: 0; }
  .mobile-table table { min-width: 0; }
  .mobile-table thead { display: none; }
  .mobile-table tr {
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: 14px;
    margin-bottom: 12px;
    background: rgba(255,255,255,.04);
  }
  .mobile-table td {
    display: grid;
    grid-template-columns: 110px 1fr;
    gap: 12px;
    padding: 9px 0;
    border-bottom: 1px solid var(--line);
  }
  .mobile-table td:last-child { border-bottom: 0; }
  .mobile-table td::before {
    content: attr(data-label);
    color: var(--muted);
    font-size: 12px;
    font-weight: 700;
  }
  .mobile-table td.actions { display: flex; }
  .mobile-table td.actions::before { display: none; }
}
