:root {
  --bg: #0b0e14;
  --bg2: #11151f;
  --card: #161b28;
  --card2: #1c2233;
  --border: #262d40;
  --text: #e8ecf4;
  --muted: #8b93a7;
  --accent: #4f8cff;
  --accent2: #7c5cff;
  --red: #ff4d5e;
  --green: #2fd27d;
  --yellow: #ffc24d;
  --radius: 14px;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  min-height: 100vh;
  line-height: 1.5;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
button { font: inherit; cursor: pointer; }
input, select, textarea {
  font: inherit;
  color: var(--text);
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
  width: 100%;
}
input:focus, select:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
label { display: block; font-size: 13px; color: var(--muted); margin: 12px 0 4px; }

/* header */
header {
  position: sticky; top: 0; z-index: 50;
  background: rgba(11, 14, 20, .92);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
}
.header-in {
  max-width: 1100px; margin: 0 auto; padding: 12px 16px;
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
}
.logo { font-weight: 800; font-size: 19px; letter-spacing: .5px; color: var(--text); }
.logo:hover { text-decoration: none; }
.logo b { color: var(--accent); }
.header-right { margin-left: auto; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.user-chip { color: var(--muted); font-size: 14px; }
.user-chip b { color: var(--text); }

/* buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  background: var(--card2); color: var(--text);
  border: 1px solid var(--border); border-radius: 10px;
  padding: 9px 16px; font-size: 14px; font-weight: 600;
  transition: filter .15s;
}
.btn:hover { filter: brightness(1.2); text-decoration: none; }
.btn.primary { background: linear-gradient(135deg, var(--accent), var(--accent2)); border: none; color: #fff; }
.btn.danger { background: transparent; border-color: var(--red); color: var(--red); }
.btn.success { background: var(--green); border: none; color: #04140b; }
.btn.small { padding: 5px 10px; font-size: 13px; border-radius: 8px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.block { width: 100%; }

/* layout */
main { max-width: 1100px; margin: 0 auto; padding: 20px 16px 60px; }
h1 { font-size: 24px; margin-bottom: 14px; }
h2 { font-size: 18px; margin: 26px 0 12px; }
.muted { color: var(--muted); }
.small-text { font-size: 13px; }
.card {
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 16px;
}
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(270px, 1fr)); gap: 14px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.spread { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; }
.mt { margin-top: 14px; }

/* badges */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 12px; font-weight: 700; border-radius: 999px;
  padding: 3px 10px; background: var(--card2); color: var(--muted);
  border: 1px solid var(--border); white-space: nowrap;
}
.badge.live { background: rgba(255, 77, 94, .15); color: var(--red); border-color: rgba(255, 77, 94, .4); }
.badge.live::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--red); animation: pulse 1.4s infinite; }
.badge.off { color: var(--muted); }
.badge.all { background: rgba(47, 210, 125, .12); color: var(--green); border-color: rgba(47, 210, 125, .35); }
.badge.group { background: rgba(124, 92, 255, .14); color: #b9a5ff; border-color: rgba(124, 92, 255, .4); }
.badge.main { background: rgba(255, 194, 77, .12); color: var(--yellow); border-color: rgba(255, 194, 77, .4); }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: .35; } }

/* stream cards */
.stream-card { display: flex; flex-direction: column; gap: 10px; }
.stream-card .title { font-weight: 700; font-size: 16px; color: var(--text); }
.stream-card .title:hover { color: var(--accent); text-decoration: none; }
.stream-card .meta { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.stream-card .actions { display: flex; gap: 6px; flex-wrap: wrap; margin-top: auto; }

/* video */
.video-wrap {
  position: relative; background: #000; border-radius: var(--radius);
  overflow: hidden; aspect-ratio: 16 / 9; border: 1px solid var(--border);
}
.video-wrap video { width: 100%; height: 100%; object-fit: contain; display: block; background: #000; }
.video-overlay {
  position: absolute; inset: 0; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 12px;
  background: rgba(5, 8, 14, .72); text-align: center; padding: 16px;
}
.video-overlay.hidden { display: none; }
.play-btn {
  width: 84px; height: 84px; border-radius: 50%; border: none;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  color: #fff; font-size: 30px; display: flex; align-items: center; justify-content: center;
  box-shadow: 0 8px 30px rgba(79, 140, 255, .45);
}
.play-btn:hover { filter: brightness(1.15); }
.video-controls { position: absolute; right: 10px; bottom: 10px; display: flex; gap: 8px; }
.video-controls .btn { background: rgba(10, 14, 22, .75); }
.status-line { font-size: 14px; color: var(--muted); margin-top: 8px; min-height: 21px; }
.status-line.err { color: var(--red); }
.status-line.ok { color: var(--green); }

/* tabs */
.tabs { display: flex; gap: 8px; flex-wrap: wrap; margin: 18px 0 14px; }
.tab {
  background: var(--card); border: 1px solid var(--border); color: var(--muted);
  padding: 8px 18px; border-radius: 999px; font-weight: 600; font-size: 14px;
}
.tab.active { background: linear-gradient(135deg, var(--accent), var(--accent2)); color: #fff; border-color: transparent; }

/* tables */
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 10px 8px; border-bottom: 1px solid var(--border); vertical-align: middle; }
th { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .4px; }
tr:last-child td { border-bottom: none; }
.table-wrap { overflow-x: auto; }

/* modal */
.modal-back {
  position: fixed; inset: 0; z-index: 100; background: rgba(4, 6, 10, .7);
  display: flex; align-items: center; justify-content: center; padding: 16px;
}
.modal {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 22px; width: 100%; max-width: 440px; max-height: 90vh; overflow-y: auto;
}
.modal h3 { margin-bottom: 6px; }
.modal .actions { display: flex; gap: 10px; margin-top: 18px; justify-content: flex-end; }

/* toast */
#toasts { position: fixed; bottom: 16px; left: 50%; transform: translateX(-50%); z-index: 200; display: flex; flex-direction: column; gap: 8px; width: min(92vw, 420px); }
.toast {
  background: var(--card2); border: 1px solid var(--border); border-left: 4px solid var(--accent);
  padding: 12px 14px; border-radius: 10px; font-size: 14px; box-shadow: 0 6px 24px rgba(0,0,0,.5);
}
.toast.err { border-left-color: var(--red); }
.toast.ok { border-left-color: var(--green); }

/* login */
.login-box { max-width: 400px; margin: 8vh auto 0; }
.login-box h1 { text-align: center; }

/* misc */
.empty { padding: 26px; text-align: center; color: var(--muted); border: 1px dashed var(--border); border-radius: var(--radius); }
.check-list { display: flex; flex-direction: column; gap: 6px; max-height: 260px; overflow-y: auto; margin-top: 8px; }
.check-list label { display: flex; gap: 8px; align-items: center; margin: 0; color: var(--text); font-size: 14px; }
.check-list input { width: auto; }
.alert { padding: 12px 14px; border-radius: 10px; font-size: 14px; margin: 10px 0; border: 1px solid; }
.alert.err { background: rgba(255,77,94,.1); border-color: rgba(255,77,94,.4); color: #ffb3ba; }
.alert.info { background: rgba(79,140,255,.08); border-color: rgba(79,140,255,.35); color: #bcd2ff; }
code { background: var(--bg2); border: 1px solid var(--border); border-radius: 6px; padding: 1px 6px; font-size: 13px; }
@media (max-width: 640px) {
  h1 { font-size: 20px; }
  .header-in { padding: 10px 12px; }
  main { padding: 14px 12px 50px; }
}


/* === МОБИЛЬНЫЙ ПОЛНОЭКРАННЫЙ РЕЖИМ ДЛЯ СТРИМА === */
@media (max-width: 896px) and (orientation: landscape) {
  .video-wrap {
    position: fixed;
    top: 0;
    left: 0;
    width: 100dvw;
    height: 100dvh;
    z-index: 1000;
    border-radius: 0;
    border: none;
    aspect-ratio: unset;
    margin: 0;
  }
  
  .video-wrap video {
    object-fit: cover;
  }

  #stream-controls {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 1001;
    justify-content: center;
    background: linear-gradient(to top, rgba(0,0,0,0.85) 0%, rgba(0,0,0,0) 100%);
    padding: 12px 8px 16px;
    margin-top: 0;
    transition: opacity 0.3s ease, transform 0.3s ease;
  }

  #stream-controls.controls-hidden {
    opacity: 0;
    pointer-events: none;
    transform: translateY(20px);
  }
  
  .status-line,
  .card.mt {
    display: none;
  }
}

.video-wrap.force-fullscreen {
  position: fixed;
  top: 0;
  left: 0;
  width: 100dvw;
  height: 100dvh;
  z-index: 1000;
  border-radius: 0;
  border: none;
  aspect-ratio: unset;
  margin: 0;
}
.video-wrap.force-fullscreen video {
  object-fit: cover;
}
.video-wrap.force-fullscreen ~ #stream-controls {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 1001;
  justify-content: center;
  background: linear-gradient(to top, rgba(0,0,0,0.85) 0%, rgba(0,0,0,0) 100%);
  padding: 12px 8px 16px;
  margin-top: 0;
  transition: opacity 0.3s ease, transform 0.3s ease;
}
.video-wrap.force-fullscreen ~ #stream-controls.controls-hidden {
  opacity: 0;
  pointer-events: none;
  transform: translateY(20px);
}
.video-wrap.force-fullscreen ~ .status-line,
.video-wrap.force-fullscreen ~ .card.mt {
  display: none;
}
