:root {
  --bg: #07100f;
  --panel: #0e1917;
  --panel-2: #12211e;
  --line: #243531;
  --muted: #91a19d;
  --text: #eef5f2;
  --accent: #d9ff45;
  --accent-dark: #1f2c00;
  --danger: #ff6b62;
  --radius: 16px;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at 85% 0%, rgba(130, 164, 33, .11), transparent 28rem),
    var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
a { color: inherit; }
.hidden { display: none !important; }

.login-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1.15fr .85fr;
}
.login-visual {
  padding: 48px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  background:
    linear-gradient(180deg, transparent 35%, rgba(5, 13, 11, .92)),
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='900' height='900'%3E%3Cdefs%3E%3Cpattern id='g' width='42' height='42' patternUnits='userSpaceOnUse'%3E%3Cpath d='M42 0H0V42' fill='none' stroke='%23253c36' stroke-width='1'/%3E%3C/pattern%3E%3CradialGradient id='r'%3E%3Cstop stop-color='%23384e45'/%3E%3Cstop offset='1' stop-color='%2307110f'/%3E%3C/radialGradient%3E%3C/defs%3E%3Crect width='900' height='900' fill='url(%23r)'/%3E%3Crect width='900' height='900' fill='url(%23g)'/%3E%3Cpath d='M0 680 Q180 530 350 650 T700 570 T950 650V900H0Z' fill='%230b1714'/%3E%3C/svg%3E");
  background-size: cover;
}
.brand { display: flex; align-items: center; gap: 12px; font-weight: 800; letter-spacing: .12em; }
.brand-mark {
  width: 35px; height: 35px; border: 1px solid var(--accent); border-radius: 50%;
  display: grid; place-items: center; color: var(--accent);
}
.hero-copy { max-width: 700px; }
.eyebrow { color: var(--accent); text-transform: uppercase; font-size: 12px; letter-spacing: .16em; font-weight: 750; }
h1 { margin: 16px 0; font-size: clamp(42px, 6vw, 78px); line-height: .98; letter-spacing: -.055em; }
.hero-copy p { max-width: 580px; color: #bdcbc6; font-size: 18px; line-height: 1.55; }
.login-panel { display: flex; flex-direction: column; justify-content: center; align-items: center; padding: 32px; overflow-y: auto; }
.login-card { width: min(410px, 100%); }
.login-card h2 { font-size: 30px; margin: 0 0 8px; }
.login-card > p { color: var(--muted); margin: 0 0 32px; }
.pin-login-card h2 { font-size: 22px; }
.pin-login-card > p { margin-bottom: 18px; }
.login-divider { width: min(410px, 100%); display: flex; align-items: center; gap: 12px; margin: 24px 0; color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .12em; }
.login-divider::before, .login-divider::after { content: ""; height: 1px; flex: 1; background: var(--line); }

.field { display: grid; gap: 8px; margin-bottom: 17px; }
.field label { color: #c5d0cc; font-size: 13px; font-weight: 650; }
input, select, textarea {
  width: 100%;
  color: var(--text);
  background: #0b1513;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px 13px;
  outline: none;
}
input:focus, select:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(217,255,69,.1); }
textarea { resize: vertical; min-height: 85px; }
.btn {
  border: 0; border-radius: 10px; padding: 11px 16px; font-weight: 750;
  background: var(--panel-2); color: var(--text); transition: .15s ease;
}
.btn:hover { transform: translateY(-1px); filter: brightness(1.12); }
.btn-primary { background: var(--accent); color: #111800; }
.btn-danger { color: var(--danger); border: 1px solid rgba(255,107,98,.28); background: rgba(255,107,98,.07); }
.btn-ghost { border: 1px solid var(--line); background: transparent; }
.btn-wide { width: 100%; }
.btn-compact { padding: 8px 11px; border-radius: 8px; font-size: 12px; }
.demo-note { margin-top: 25px; padding: 13px; border: 1px solid var(--line); border-radius: 10px; color: var(--muted); font-size: 12px; line-height: 1.6; }

.shell { min-height: 100vh; display: grid; grid-template-columns: 235px 1fr; }
.sidebar {
  border-right: 1px solid var(--line); padding: 28px 18px; display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh; background: rgba(7,16,15,.75); backdrop-filter: blur(16px);
}
.sidebar .brand { padding: 0 9px 35px; }
.nav { display: grid; gap: 6px; }
.nav button {
  border: 0; background: transparent; color: var(--muted); text-align: left;
  border-radius: 10px; padding: 11px 13px; font-weight: 650;
}
.nav button:hover, .nav button.active { background: var(--panel-2); color: var(--text); }
.nav button.active { box-shadow: inset 3px 0 var(--accent); }
.user-card { margin-top: auto; border-top: 1px solid var(--line); padding: 18px 8px 0; }
.user-card strong, .user-card span { display: block; }
.user-card span { color: var(--muted); font-size: 12px; margin: 4px 0 13px; }
.content { min-width: 0; padding: 34px clamp(20px, 4vw, 60px) 60px; }
.topbar { display: flex; justify-content: space-between; align-items: flex-end; gap: 20px; margin-bottom: 30px; }
.topbar h2 { margin: 5px 0 0; font-size: 32px; letter-spacing: -.03em; }
.topbar p { color: var(--muted); margin: 7px 0 0; }
.stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; margin-bottom: 24px; }
.stat, .card { background: rgba(14,25,23,.84); border: 1px solid var(--line); border-radius: var(--radius); }
.stat { padding: 18px; }
.stat span { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .08em; }
.stat strong { display: block; margin-top: 8px; font-size: 25px; }
.stream-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 18px; }
.stream-card { overflow: hidden; }
.stream-thumb {
  position: relative; aspect-ratio: 16/9; display: grid; place-items: center;
  background:
    linear-gradient(145deg, rgba(217,255,69,.07), transparent),
    repeating-linear-gradient(0deg, transparent 0 28px, rgba(255,255,255,.025) 29px),
    #081210;
}
.stream-thumb::after { content: "⌖"; font-size: 55px; color: rgba(217,255,69,.22); }
.stream-thumb-image { position: absolute; inset: 0; z-index: 0; width: 100%; height: 100%; object-fit: cover; }
.stream-thumb:has(.stream-thumb-image)::after { display: none; }
.stream-thumb > .live-badge, .stream-thumb > .viewer-badge, .stream-thumb > .standby-caption { z-index: 2; }
.stream-thumb.standby { background: linear-gradient(rgba(2,8,7,.2), rgba(2,8,7,.55)), url("/assets/stream-standby-web.webp?v=1") center/cover; }
.stream-thumb.standby::after { display: none; }
.standby-caption { position: absolute; inset: auto 12px 12px; padding: 7px 9px; border-radius: 7px; color: #d9e4df; background: rgba(2,8,7,.72); backdrop-filter: blur(5px); font-size: 11px; font-weight: 700; }
.thumbnail-capture { position: fixed; left: -10000px; top: 0; width: 360px; height: 640px; overflow: hidden; pointer-events: none; opacity: .01; }
.thumbnail-capture video { width: 100%; height: 100%; object-fit: contain; }
.live-badge, .viewer-badge {
  position: absolute; top: 12px; border-radius: 999px; padding: 5px 8px;
  font-size: 10px; text-transform: uppercase; font-weight: 800; letter-spacing: .08em;
}
.live-badge { left: 12px; background: var(--accent); color: #111800; }
.live-badge.offline { background: #58625f; color: white; }
.viewer-badge { right: 12px; color: white; background: rgba(0,0,0,.55); }
.stream-info { padding: 17px; }
.stream-info h3 { margin: 0 0 7px; font-size: 17px; }
.stream-title-row { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; margin-bottom: 7px; }
.stream-title-row h3 { margin: 0; }
.meta { color: var(--muted); font-size: 12px; display: flex; gap: 14px; }
.protocol-badge { flex: none; display: inline-block; border: 1px solid var(--line); border-radius: 999px; padding: 4px 8px; color: var(--muted); font-size: 10px; font-weight: 800; letter-spacing: .04em; text-transform: uppercase; }
.protocol-badge.low-latency { color: var(--accent); border-color: rgba(217,255,69,.35); background: rgba(217,255,69,.07); }
.protocol-preview { display: flex; align-items: center; gap: 9px; min-height: 28px; color: var(--muted); font-size: 12px; line-height: 1.4; }
.card-actions { display: flex; gap: 6px; padding: 0 17px 14px; }
.card-actions .btn:first-child { flex: 1; }

.empty { padding: 55px 25px; text-align: center; color: var(--muted); }
.empty strong { display: block; color: var(--text); font-size: 18px; margin-bottom: 6px; }
.section-card { padding: 20px; }
.section-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; }
.section-head h3 { margin: 0; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 14px 12px; text-align: left; border-top: 1px solid var(--line); font-size: 13px; }
th { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .08em; }
.pill { display: inline-block; padding: 4px 8px; background: var(--panel-2); border-radius: 999px; font-size: 11px; }
.pill.active { color: var(--accent); }
.row-actions { display: flex; gap: 7px; justify-content: flex-end; }

.modal-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,.72); display: grid; place-items: center; padding: 20px; z-index: 10; }
.modal { width: min(520px, 100%); max-height: 90vh; overflow-y: auto; background: var(--panel); border: 1px solid var(--line); border-radius: 18px; padding: 24px; box-shadow: 0 25px 80px #000; }
.modal-head { display: flex; justify-content: space-between; gap: 20px; margin-bottom: 22px; }
.modal-head h3 { margin: 0; font-size: 22px; }
.close-btn { border: 0; background: transparent; color: var(--muted); font-size: 24px; line-height: 1; }
.check-list { display: grid; gap: 8px; margin: 12px 0 20px; }
.check-item { display: flex; align-items: center; gap: 10px; padding: 10px; background: #0b1513; border-radius: 8px; }
.check-item input { width: auto; accent-color: var(--accent); }
.form-actions { display: flex; justify-content: flex-end; gap: 9px; margin-top: 22px; }

.player-page { width: 100%; height: 100vh; height: 100dvh; overflow: hidden; background: #030605; display: grid; grid-template-rows: auto minmax(0, 1fr) auto; }
.player-head { display: flex; justify-content: space-between; align-items: center; padding: 16px 22px; border-bottom: 1px solid #1b2724; background: #09100f; }
.player-title { display: flex; align-items: center; gap: 12px; }
.player-title h2 { font-size: 16px; margin: 0; }
.player-title span { display: block; color: var(--muted); font-size: 11px; margin-top: 3px; }
.video-wrap { position: relative; min-height: 0; display: grid; place-items: center; overflow: hidden; background: #030605 url("/assets/stream-standby-web.webp?v=1") center/cover no-repeat; }
.video-wrap::before { content: ""; position: absolute; inset: 0; background: linear-gradient(rgba(2,8,7,.16), rgba(2,8,7,.52)); pointer-events: none; z-index: 0; }
.video-wrap video, .video-wrap iframe { width: 100%; height: 100%; object-fit: contain; border: 0; background: #000; }
.video-wrap video::-webkit-media-controls { display: none !important; }
.video-wrap video { pointer-events: none; }
.mist-player-target { position: absolute !important; inset: 0; width: 100%; height: 100%; min-width: 0; min-height: 0; overflow: hidden; background: #000; }
.mist-player-target > *,
.mist-player-target .mistvideo,
.mist-player-target [class*="maincontainer"],
.mist-player-target [class*="videocontainer"] { width: 100% !important; height: 100% !important; max-width: none !important; max-height: none !important; }
.mist-player-target .mistvideo-controls,
.mist-player-target [class*="controls"],
.mist-player-target [class*="progress"],
.mist-player-target button { display: none !important; }
.mist-player-target video { width: 100% !important; height: 100% !important; max-width: none !important; max-height: none !important; object-fit: contain !important; pointer-events: none !important; background: #000 !important; }
.video-wrap > video, .video-wrap > iframe, .video-wrap > .mist-player-target { position: relative; z-index: 1; }
.video-loading { position: absolute; inset: 0; z-index: 5; display: grid; place-content: center; justify-items: center; gap: 9px; text-align: center; pointer-events: none; background: #030605 url("/assets/stream-standby-web.webp?v=1") center/cover no-repeat; color: var(--text); opacity: 1; transition: opacity .18s ease; }
.video-loading::before { content: ""; position: absolute; inset: 0; z-index: -1; background: rgba(2,8,7,.28); }
.video-loading.is-hiding { opacity: 0; }
.video-loading small { color: var(--muted); max-width: 470px; }
.spinner { width: 34px; height: 34px; margin-bottom: 8px; border: 3px solid #26332f; border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.video-placeholder { position: relative; z-index: 2; color: #b7c6c0; text-align: center; padding: 34px; max-width: 660px; border: 1px solid rgba(217,255,69,.16); border-radius: 16px; background: rgba(3,10,8,.72); backdrop-filter: blur(10px); }
.video-placeholder strong { display: block; color: var(--text); font-size: 20px; margin-bottom: 8px; }
.video-placeholder p { line-height: 1.5; }
.video-placeholder code { display: block; margin-top: 18px; padding: 10px; color: var(--accent); background: #09100f; border: 1px solid var(--line); border-radius: 8px; word-break: break-all; }
.video-placeholder small { display: block; line-height: 1.45; }
.standby-dot { display: block; width: 11px; height: 11px; margin: 0 auto 15px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 7px rgba(217,255,69,.08); animation: standbyPulse 2s ease-in-out infinite; }
@keyframes standbyPulse { 50% { opacity: .35; box-shadow: 0 0 0 13px rgba(217,255,69,0); } }
.player-foot { display: flex; justify-content: space-between; padding: 12px 22px; border-top: 1px solid #1b2724; color: var(--muted); font-size: 12px; background: #09100f; }
.player-live-badge { position: absolute; z-index: 4; top: 16px; left: 16px; display: none; padding: 7px 10px; border-radius: 999px; color: #101800; background: var(--accent); box-shadow: 0 3px 18px rgba(0,0,0,.4); font-size: 11px; font-weight: 900; letter-spacing: .08em; }
.player-live-badge.visible { display: block; }
#footer-live-status { color: var(--accent); }
.latency-badge { position: absolute; z-index: 4; top: 16px; right: 16px; padding: 7px 10px; border-radius: 999px; color: #eef5f2; background: rgba(3,10,8,.78); border: 1px solid var(--line); backdrop-filter: blur(7px); font-size: 11px; font-weight: 800; letter-spacing: .03em; }
.latency-badge.good, .latency-text.good { color: var(--accent); }
.latency-badge.medium, .latency-text.medium { color: #ffd85c; }
.latency-badge.high, .latency-text.high { color: var(--danger); }
.pin-shell { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.pin-card { width: min(430px, 100%); text-align: center; padding: 34px; }
.pin-icon { width: 58px; height: 58px; display: grid; place-items: center; margin: 0 auto 20px; border-radius: 50%; background: var(--accent-dark); color: var(--accent); font-size: 25px; }
.pin-card h1 { font-size: 28px; letter-spacing: -.03em; }
.pin-card p { color: var(--muted); line-height: 1.5; }
.pin-input { text-align: center; letter-spacing: .35em; font-size: 22px; margin: 15px 0; }
.toast { position: fixed; right: 22px; bottom: 22px; background: var(--text); color: #07100f; padding: 12px 16px; border-radius: 9px; font-weight: 700; transform: translateY(100px); opacity: 0; transition: .2s; z-index: 20; }
.toast.show { transform: translateY(0); opacity: 1; }
.error { color: var(--danger) !important; }

@media (max-width: 800px) {
  .login-shell { grid-template-columns: 1fr; }
  .login-visual { display: none; }
  .shell { grid-template-columns: 1fr; }
  .sidebar { height: auto; position: static; padding: 16px; border-right: 0; border-bottom: 1px solid var(--line); }
  .sidebar .brand { padding: 0 0 15px; }
  .nav { display: flex; overflow-x: auto; }
  .nav button { white-space: nowrap; }
  .user-card { display: none; }
  .content { padding: 24px 16px 45px; }
  .topbar { align-items: flex-start; flex-direction: column; }
  .stats { grid-template-columns: 1fr; }
  .stream-grid { grid-template-columns: 1fr; }
}
