:root{
  --bg: #101820;
  --panel: #16212B;
  --panel-raised: #1C2933;
  --line: #253440;
  --amber: #FFB238;
  --red: #E8503A;
  --green: #4FD1A5;
  --text: #EDEFEF;
  --muted: #8B98A3;
  --mono: 'IBM Plex Mono', monospace;
  --sans: 'IBM Plex Sans', sans-serif;
  --display: 'Space Grotesk', sans-serif;
}
*{ box-sizing: border-box; }
body{
  margin:0;
  background: radial-gradient(120% 140% at 15% -10%, #16232D 0%, var(--bg) 55%);
  color: var(--text);
  font-family: var(--sans);
  min-height: 100vh;
}
.wrap{ max-width: 880px; margin: 0 auto; padding: 32px 20px 60px; }

/* dot */
.dot{
  width:9px; height:9px; border-radius:50%;
  background: var(--green);
  display:inline-block;
  box-shadow: 0 0 0 0 rgba(79,209,165,0.6);
  animation: pulse 2.2s infinite;
}
@keyframes pulse{
  0%{ box-shadow: 0 0 0 0 rgba(79,209,165,0.55); }
  70%{ box-shadow: 0 0 0 8px rgba(79,209,165,0); }
  100%{ box-shadow: 0 0 0 0 rgba(79,209,165,0); }
}

/* header */
header{ margin-bottom: 22px; }
.header-top{
  display:flex; align-items:center; justify-content:space-between;
  gap: 16px; flex-wrap: wrap;
}
.header-top h1{
  font-family: var(--display); font-size: 26px; font-weight: 700;
  margin: 0; display:flex; align-items:center; gap:10px;
}
.header-subtitle{
  margin: 8px 0 0; color: var(--muted); font-size: 13.5px; max-width: none;
}
@media (min-width: 820px){
  .header-subtitle{ white-space: nowrap; }
}

/* buttons & inputs */
button, .btn-amber, .btn-ghost, .btn-red{
  font-family: var(--sans); font-weight: 600; font-size: 13px;
  border: none; border-radius: 6px; padding: 9px 16px; cursor: pointer;
  transition: transform 0.08s ease;
  text-decoration: none; display:inline-block;
}
button:active, .btn-amber:active, .btn-ghost:active, .btn-red:active{ transform: scale(0.97); }
.btn-amber{ background: var(--amber); color: #1A1305; }
.btn-ghost{ background: transparent; color: var(--muted); border: 1px solid var(--line); }
.btn-ghost:hover{ color: var(--text); border-color: var(--muted); }

input[type="text"], input[type="password"], input[type="url"], select{
  background: var(--panel-raised);
  border: 1px solid var(--line);
  color: var(--text);
  border-radius: 6px;
  padding: 9px 11px;
  font-family: var(--sans);
  font-size: 13.5px;
  width: 100%;
}
input:focus, select:focus, button:focus{
  outline: 2px solid var(--amber);
  outline-offset: 1px;
}
label{ font-size: 11px; color: var(--muted); display:block; margin-bottom: 4px; text-transform: uppercase; letter-spacing:0.05em; }

/* notice / alert */
.notice{
  background: rgba(79,209,165,0.1); border: 1px solid rgba(79,209,165,0.3);
  color: var(--green); font-size: 13px; padding: 10px 14px; border-radius: 8px;
  margin-bottom: 18px;
}
.alert{
  background: rgba(232,80,58,0.12); border: 1px solid rgba(232,80,58,0.35);
  color: #FF9C87; font-size: 13px; padding: 10px 14px; border-radius: 8px;
  margin-bottom: 16px;
}

/* panels */
.panel, .add-panel{
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  margin-bottom: 20px;
}
.add-panel{ padding: 18px; }
.add-panel h2{
  font-family: var(--display); font-size: 15px; margin: 0 0 14px;
  color: var(--amber); letter-spacing: 0.02em;
}
.panel-head{
  display:flex; align-items:center; justify-content:space-between;
  padding: 14px 18px; border-bottom: 1px solid var(--line);
}
.panel-head h2{
  font-family: var(--display); font-size: 13px; margin:0;
  color: var(--muted); letter-spacing: 0.08em; text-transform: uppercase;
}

.btn-red{ background: rgba(232,80,58,0.14); color: #FF9C87; border: 1px solid rgba(232,80,58,0.35); }
.btn-red:hover{ background: rgba(232,80,58,0.22); }

.playlist-tabs{
  display:flex; flex-wrap:wrap; gap:8px;
  padding: 16px 18px 4px;
}
.playlist-tab{
  font-family: var(--mono); font-size: 12.5px;
  color: var(--muted); text-decoration:none;
  background: var(--panel-raised); border: 1px solid var(--line);
  border-radius: 999px; padding: 7px 14px;
  display:flex; align-items:center; gap:8px;
}
.playlist-tab:hover{ color: var(--text); border-color: var(--muted); }
.playlist-tab.active{ color: #1A1305; background: var(--amber); border-color: var(--amber); font-weight:600; }
.playlist-tab .tab-count{
  font-size: 10.5px; opacity: 0.75;
}

.inline-form{
  display:flex; gap:8px; padding: 14px 18px 18px; flex-wrap: wrap;
}
.inline-form input[type="text"]{ flex:1; min-width: 180px; }

.file-path{
  font-family: var(--mono); font-size: 11px; color: var(--muted);
}

.playlist-tools{
  display:flex; gap:8px; flex-wrap:wrap;
  padding: 0 18px 18px;
}
.playlist-tools form{ display:flex; gap:8px; flex: 1; min-width: 220px; }
.playlist-tools input[type="text"]{ flex:1; }

.url-panel .url-row{ display:flex; gap:8px; padding: 14px 18px 6px; }

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

.link-row{
  display:flex; align-items:flex-start; gap: 14px;
  padding: 14px 18px;
  border-top: 1px solid var(--line);
}
.link-row:first-of-type{ border-top: none; }
.link-row .row-live{ margin-top: 6px; }
.link-row.editing{ background: rgba(255,178,56,0.06); border-left: 2px solid var(--amber); }

.row-logo{
  width: 34px; height: 34px; border-radius: 6px; object-fit: cover;
  flex-shrink: 0; background: var(--panel-raised); border: 1px solid var(--line);
  margin-top: 2px;
}
.logo-placeholder{
  width: 34px; height: 34px; border-radius: 6px; flex-shrink: 0;
  background: var(--panel-raised); border: 1px dashed var(--line);
  margin-top: 2px;
}

.logo-field .logo-input-row{ display:flex; align-items:center; gap: 10px; }
.logo-field input{ flex: 1; }
.logo-preview{
  width: 38px; height: 38px; border-radius: 6px; object-fit: cover;
  flex-shrink: 0; background: var(--panel-raised); border: 1px solid var(--line);
  visibility: hidden;
}

.row-actions{ display:flex; align-items:center; gap: 4px; flex-shrink:0; }
.row-edit{
  color: var(--muted); text-decoration:none; font-size: 15px;
  padding: 4px 8px; border-radius: 4px;
}
.row-edit:hover{ color: var(--amber); background: rgba(255,178,56,0.08); }

.row-check{
  background: transparent; border:none; color: var(--muted);
  font-size: 15px; cursor:pointer; padding: 4px 8px; border-radius:4px;
}
.row-check:hover{ color: var(--green); background: rgba(79,209,165,0.08); }

.panel-head-actions{ display:flex; align-items:center; gap: 12px; }
.small-btn{ padding: 6px 12px; font-size: 12px; }

.health-dot{
  display:inline-block; width:7px; height:7px; border-radius:50%;
  margin-right: 6px; vertical-align: middle;
}
.health-dot.health-active{ background: var(--green); box-shadow: 0 0 0 2px rgba(79,209,165,0.15); }
.health-dot.health-dead{ background: var(--red); box-shadow: 0 0 0 2px rgba(232,80,58,0.15); }
.health-dot.health-unknown{ background: var(--muted); }

.health-label{
  font-family: var(--mono); font-size: 10.5px; color: var(--muted);
  font-weight: 400; margin-left: 8px;
}

.library-toolbar{
  display:flex; align-items:center; gap:12px; flex-wrap:wrap;
  padding: 14px 18px; border-top: 1px solid var(--line);
}
#linkSearch{ max-width: 240px; }
#linkMatchCount{ font-family: var(--mono); font-size: 12px; color: var(--muted); margin-left:auto; }

.playlist-check-row{ display:flex; flex-wrap:wrap; gap: 12px; padding-top: 4px; }
.playlist-check{
  display:flex; align-items:center; gap:6px;
  font-size: 12.5px; color: var(--muted); cursor:pointer;
}
.playlist-check input{ width:15px; height:15px; accent-color: var(--amber); }
.playlist-check:hover{ color: var(--text); }

.membership-pills{
  display:flex; flex-wrap:wrap; gap:6px; margin-top: 10px;
}
.pill-form{ display:inline-block; }
.membership-pill{
  font-family: var(--mono); font-size: 11px;
  background: transparent; color: var(--muted);
  border: 1px solid var(--line); border-radius: 999px;
  padding: 5px 12px; cursor:pointer;
}
.membership-pill:hover{ border-color: var(--muted); color: var(--text); }
.membership-pill.in{
  background: rgba(79,209,165,0.12); color: var(--green); border-color: rgba(79,209,165,0.4);
}
.membership-pill.in:hover{ background: rgba(79,209,165,0.2); }

/* channels page */
.toolbar-panel{ padding: 16px 18px; }
.toolbar{ display:flex; align-items:center; gap:12px; flex-wrap:wrap; }
.toolbar + .toolbar{ margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--line); }
#searchBox{ max-width: 260px; }

.group-filters{ display:flex; gap:6px; flex-wrap:wrap; }
.chip{
  font-family: var(--mono); font-size: 11.5px;
  background: var(--panel-raised); color: var(--muted);
  border: 1px solid var(--line); border-radius: 999px;
  padding: 6px 13px; cursor:pointer;
}
.chip:hover{ color: var(--text); }
.chip.active{ background: var(--amber); color: #1A1305; border-color: var(--amber); font-weight:600; }
.chip-offline{ color: #FF9C87; border-color: rgba(232,80,58,0.3); }
.chip-offline:hover{ color: #FF9C87; border-color: rgba(232,80,58,0.5); }
.chip-offline.active{ background: var(--red); color: #fff; border-color: var(--red); }

.bulk-row{ }
.bulk-label{ font-size: 12.5px; color: var(--muted); white-space: nowrap; }
.bulk-row select{ width:auto; min-width: 180px; }
.selected-count{ font-family: var(--mono); font-size: 12px; color: var(--muted); margin-left: auto; }

.select-all{
  font-size: 12px; color: var(--muted); display:flex; align-items:center; gap:6px; cursor:pointer;
}

.chan-row{
  display:flex; align-items:flex-start; gap: 12px;
  padding: 12px 18px;
  border-top: 1px solid var(--line);
  cursor:pointer;
}
.chan-row:first-of-type{ border-top:none; }
.chan-row:hover{ background: rgba(255,255,255,0.015); }
.chan-row input[type="checkbox"]{
  width: 16px; height:16px; margin-top: 3px; accent-color: var(--amber); flex-shrink:0;
}

.badge-row{ display:flex; flex-wrap:wrap; gap:6px; margin-top: 8px; }
.badge{
  font-family: var(--mono); font-size: 10.5px;
  background: rgba(255,178,56,0.1); color: var(--amber);
  border: 1px solid rgba(255,178,56,0.3);
  border-radius: 999px; padding: 3px 9px;
}

.xtream-grid{
  display:grid; grid-template-columns: 1.4fr 1fr 1fr;
  gap: 10px; padding: 14px 18px 6px;
}
.xtream-grid input[readonly]{ font-family: var(--mono); font-size: 12.5px; color: var(--text); cursor:pointer; }
@media (max-width: 640px){ .xtream-grid{ grid-template-columns: 1fr; } }

.account-row{
  display:flex; align-items:center; justify-content:space-between; gap: 12px;
  padding: 12px 18px; border-top: 1px solid var(--line); flex-wrap: wrap;
}
.account-label{ font-size: 13.5px; font-weight: 500; margin-bottom: 3px; }
.account-creds{
  font-family: var(--mono); font-size: 11.5px; color: var(--muted);
  display:flex; gap: 14px; flex-wrap: wrap;
}
.account-creds strong{ color: var(--text); font-weight: 500; }
.account-actions{ display:flex; align-items:center; gap: 8px; flex-shrink:0; }

.diag-row{
  display:flex; align-items:center; gap: 12px;
  padding: 12px 18px; border-top: 1px solid var(--line);
}
.diag-row:first-of-type{ border-top: none; }
.diag-dot{ width:9px; height:9px; border-radius:50%; flex-shrink:0; }
.diag-dot.diag-ok{ background: var(--green); }
.diag-dot.diag-fail{ background: var(--red); }
.diag-main{ flex:1; }
.diag-label{ font-size: 13.5px; }
.diag-detail{ font-family: var(--mono); font-size: 11px; color: var(--muted); margin-top: 2px; }
.diag-status{
  font-family: var(--mono); font-size: 11px; font-weight: 600;
  padding: 3px 10px; border-radius: 999px;
}
.diag-row:has(.diag-ok) .diag-status{ background: rgba(79,209,165,0.12); color: var(--green); }
.diag-row:has(.diag-fail) .diag-status{ background: rgba(232,80,58,0.12); color: #FF9C87; }
.diag-help{ padding: 14px 18px; font-size: 13px; color: var(--muted); line-height: 1.7; }
.diag-help code{ background: var(--panel-raised); padding: 2px 6px; border-radius: 4px; color: var(--text); font-family: var(--mono); font-size: 12px; }

.tested-row{
  display:flex; align-items:center; gap: 14px;
  padding: 12px 18px; border-top: 1px solid var(--line);
}
.tested-row:first-of-type{ border-top: none; }
.type-badge{
  font-family: var(--mono); font-size: 10px; font-weight: 600;
  border-radius: 6px; padding: 4px 8px; flex-shrink: 0; min-width: 44px; text-align: center;
}
.type-hls{ background: rgba(255,178,56,0.14); color: var(--amber); }
.type-dash{ background: rgba(79,209,165,0.14); color: var(--green); }
.type-mp4{ background: rgba(79,150,209,0.14); color: #7EC3E8; }
.type-unknown{ background: rgba(139,152,163,0.14); color: var(--muted); }
.tested-meta{ font-family: var(--mono); font-size: 11px; color: var(--muted); margin-top: 3px; }

/* stream tester */
.tester-wrap{ max-width: 1180px; }

.tester-input-panel{ padding: 16px 18px; margin-bottom: 20px; }
.tester-tabs{ display:flex; gap:8px; margin-bottom: 12px; }
.tab-btn{
  font-family: var(--mono); font-size: 12.5px;
  background: var(--panel-raised); color: var(--muted);
  border: 1px solid var(--line); border-radius: 8px;
  padding: 9px 16px; cursor:pointer;
}
.tab-btn:hover{ color: var(--text); }
.tab-btn.active{ background: rgba(79,209,165,0.12); color: var(--green); border-color: rgba(79,209,165,0.4); font-weight:600; }

.tester-url-row{ display:flex; gap:10px; }
.tester-url-row input{ flex:1; font-family: var(--mono); font-size: 13px; }

.tester-layout{
  display:grid; grid-template-columns: 1.6fr 1fr; gap: 20px;
  align-items: start;
}
@media (max-width: 900px){ .tester-layout{ grid-template-columns: 1fr; } }

.video-shell{
  position: relative; width: 100%; aspect-ratio: 16 / 9;
  background: #000; border-radius: 12px; overflow: hidden;
  border: 1px solid var(--line);
}
.video-shell video{ width:100%; height:100%; object-fit: contain; background:#000; }
.video-placeholder{
  position:absolute; inset:0; display:flex; align-items:center; justify-content:center;
  color: var(--muted); font-size: 13px; padding: 20px; text-align:center;
  pointer-events: none;
}

.mute-note{
  font-size: 11px; color: var(--muted); margin: 8px 0 0; text-align: center;
}

.brand-logo{
  max-height: 28px; max-width: 220px; object-fit: contain; vertical-align: middle;
}

.logo-current{
  display:flex; align-items:center; gap: 14px;
  padding: 14px 18px; border-bottom: 1px solid var(--line);
}
.logo-current img{
  max-height: 48px; max-width: 160px; object-fit: contain;
  background: var(--panel-raised); border: 1px solid var(--line);
  border-radius: 8px; padding: 8px;
}
.logo-current > div{ flex: 1; }
.logo-current form{ flex-shrink: 0; }

.share-row{
  display:flex; align-items:center; gap:10px;
  margin-top: 12px;
}
.share-label{ font-size: 11.5px; color: var(--muted); white-space: nowrap; min-width: 110px; }
.share-row input{ flex:1; font-family: var(--mono); font-size: 11.5px; color: var(--muted); }

.info-panel .panel-head{ align-items:center; }
.live-badge{
  display:inline-flex; align-items:center; gap:5px;
  background: rgba(232,80,58,0.14); color: #FF9C87;
  border: 1px solid rgba(232,80,58,0.35);
  border-radius: 999px; padding: 3px 10px; font-family: var(--mono); font-size: 10.5px; font-weight:600;
}
.info-row{
  padding: 12px 18px; border-top: 1px solid var(--line);
  display:grid; grid-template-columns: 1fr auto; align-items:center; gap: 2px 12px;
}
.info-row:first-of-type{ border-top: none; }
.info-label{ font-size: 13px; font-weight:500; }
.info-sub{ font-size: 11px; color: var(--muted); grid-column: 1; }
.info-value{
  grid-column: 2; grid-row: 1 / 3; align-self:center;
  font-family: var(--mono); font-size: 12px; color: var(--green);
  background: rgba(79,209,165,0.1); border: 1px solid rgba(79,209,165,0.25);
  border-radius: 6px; padding: 4px 10px; white-space: nowrap;
}
.url-panel input[readonly]{ font-family: var(--mono); font-size: 12.5px; color: var(--muted); cursor: pointer; }
.small-note{ font-size: 11.5px; color: var(--muted); padding: 0 18px 16px; line-height:1.5; }

.grid{
  display:grid;
  grid-template-columns: 1.2fr 0.8fr 1.6fr;
  gap: 10px;
  align-items: end;
}
.grid-submit{ grid-column: 1 / -1; margin-top: 4px; display:flex; gap:10px; align-items:center; }
.grid-full{ grid-column: 1 / -1; }
@media (max-width: 640px){ .grid{ grid-template-columns: 1fr; } }

.group-label{
  font-family: var(--mono); font-size: 11px; color: var(--muted);
  text-transform: uppercase; letter-spacing: 0.08em;
  padding: 10px 18px 6px; background: rgba(255,255,255,0.015);
}
.dead-section-label{
  display:flex; align-items:center; gap:10px; flex-wrap:wrap;
  color: var(--red); border-top: 1px solid var(--line); margin-top: 6px;
  padding-top: 16px;
}
.dead-count{
  background: rgba(232,80,58,0.15); color: #FF9C87;
  border-radius: 999px; padding: 2px 8px; font-size: 10px;
}
.dead-note{
  color: var(--muted); text-transform: none; letter-spacing: 0; font-size: 10.5px;
}
.dead-subgroup-label{
  color: #FF9C87; font-size: 10px; padding: 8px 18px 4px 28px;
  background: transparent;
}

.pagination-row{
  display:none; align-items:center; justify-content:center; gap: 16px;
  padding: 16px 18px; border-top: 1px solid var(--line);
}
.page-btn{
  background: var(--panel-raised); border: 1px solid var(--line); color: var(--text);
  border-radius: 6px; padding: 7px 14px; font-size: 12.5px; cursor:pointer;
}
.page-btn:hover:not(:disabled){ border-color: var(--amber); color: var(--amber); }
.page-btn:disabled{ opacity: 0.35; cursor: default; }
.page-info{ font-family: var(--mono); font-size: 12px; color: var(--muted); }
.row{
  display:flex; align-items:center; gap: 14px;
  padding: 12px 18px;
  border-top: 1px solid var(--line);
}
.ch-num{ font-family: var(--mono); font-size: 13px; color: var(--amber); min-width: 42px; flex-shrink:0; }
.row-live{ width:6px; height:6px; border-radius:50%; background:var(--green); flex-shrink:0; }
.row-main{ flex:1; min-width:0; }
.row-name{ font-size: 14px; font-weight:500; }
.row-url{
  font-family: var(--mono); font-size: 11.5px; color: var(--muted);
  white-space: nowrap; overflow:hidden; text-overflow: ellipsis; margin-top: 2px;
}
.row-del{
  background: transparent; border:none; color: var(--muted);
  font-size: 16px; cursor:pointer; padding: 4px 8px; flex-shrink:0;
}
.row-del:hover{ color: var(--red); }
.empty{ padding: 40px 18px; text-align:center; color: var(--muted); font-size: 13.5px; }

footer{
  display:flex; justify-content:space-between; align-items:center;
  gap: 12px; margin-top: 4px; flex-wrap: wrap;
}
footer .count{ font-family: var(--mono); font-size: 12px; color: var(--muted); }

/* login page */
.login-body{ display:flex; align-items:center; justify-content:center; min-height:100vh; padding: 20px; }
.login-card{
  background: var(--panel); border: 1px solid var(--line); border-radius: 14px;
  padding: 36px 32px; width: 100%; max-width: 360px;
}
.login-mark{
  font-family: var(--mono); font-size: 11px; color: var(--muted);
  letter-spacing: 0.12em; display:flex; align-items:center; gap:8px; margin-bottom: 20px;
  text-transform: uppercase;
}
.login-mark .brand-logo{ max-height: 18px; text-transform: none; }
.login-card h1{ font-family: var(--display); font-size: 24px; margin: 0 0 6px; }
.login-card .sub{ color: var(--muted); font-size: 13px; margin: 0 0 22px; }
.login-card form{ display:flex; flex-direction:column; gap: 14px; }
.login-card .btn-amber{ margin-top: 4px; text-align:center; }
.login-card .hint{ margin-top: 18px; font-size: 11.5px; color: var(--muted); }
.login-card .hint code{ color: var(--text); background: var(--panel-raised); padding: 1px 5px; border-radius: 4px; }
