:root {
  --bg: #0b0d10;
  --panel: #161a20;
  --text: #e8eaed;
  --muted: #9aa3af;
  --input: #222831;
  --accent: #2ecc71;
  --accent-2: #58d68d;
  --danger: #e74c3c;
  --border: #2a313c;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  font-family: 'Roboto', sans-serif;
  background: var(--bg);
  color: var(--text);
}

.hidden {
  display: none !important;
}

/* —— Public fullscreen player —— */
body.player-page {
  height: 100%;
  overflow: hidden;
  background: #000;
}

html:has(body.player-page) {
  height: 100%;
}

.stage {
  position: relative;
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  background: #000;
  overflow: hidden;
}

#player,
#player .jwplayer {
  position: absolute !important;
  inset: 0 !important;
  width: 100% !important;
  height: 100% !important;
}

#player .jw-wrapper,
#player .jw-aspect {
  height: 100% !important;
}

.chrome {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  z-index: 2;
  padding: max(16px, env(safe-area-inset-top)) 20px 48px;
  background: linear-gradient(180deg, rgba(0, 0, 0, 0.72) 0%, rgba(0, 0, 0, 0.28) 55%, transparent 100%);
  pointer-events: none;
  transition: opacity 0.35s ease;
}

.chrome.is-dimmed {
  opacity: 0;
}

.chrome-inner {
  max-width: 920px;
}

.chrome-label {
  margin: 0 0 4px;
  font-size: 0.72rem;
  font-weight: 500;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--accent);
}

.chrome h1 {
  margin: 0;
  font-size: clamp(1.15rem, 2.4vw, 1.65rem);
  font-weight: 700;
  color: #fff;
  text-shadow: 0 2px 12px rgba(0, 0, 0, 0.55);
}

.error-panel {
  position: absolute;
  inset: 0;
  z-index: 3;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(ellipse at top, rgba(46, 204, 113, 0.08), transparent 45%),
    #0b0d10;
}

.error-panel::before {
  content: 'Stream unavailable';
  position: absolute;
  top: max(28px, env(safe-area-inset-top));
  left: 24px;
  font-size: 0.75rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
}

.error-panel p {
  margin: 0;
  max-width: 420px;
  text-align: center;
  font-size: 1.05rem;
  line-height: 1.5;
  color: #ffb4ae;
}

/* —— Admin dashboard —— */
body.admin-page {
  --bg: #0f1115;
  --panel: #171a21;
  --panel-2: #1c2029;
  --text: #eef1f6;
  --muted: #8b93a7;
  --input: #12151c;
  --accent: #3dd68c;
  --accent-2: #62e0a4;
  --danger: #f07178;
  --border: #2a3040;
  --line: #232836;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

.sub {
  margin: 0;
  color: var(--muted);
  font-size: 0.875rem;
  line-height: 1.45;
}

.sub code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.8rem;
  color: #c9d2e3;
}

.form-grid {
  display: grid;
  gap: 12px;
}

label {
  display: grid;
  gap: 6px;
  font-size: 0.8rem;
  color: var(--muted);
  font-weight: 500;
}

input,
textarea,
select,
button {
  font: inherit;
}

input,
textarea,
select {
  width: 100%;
  height: 40px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--input);
  color: var(--text);
  outline: none;
}

select {
  cursor: pointer;
}

input:focus,
textarea:focus,
select:focus {
  border-color: rgba(61, 214, 140, 0.7);
  box-shadow: 0 0 0 3px rgba(61, 214, 140, 0.12);
}

.btn-primary,
.btn-secondary,
.btn-ghost,
.btn-icon {
  border: none;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 600;
  height: 40px;
}

.btn-primary {
  padding: 0 16px;
  background: var(--accent);
  color: #08140f;
}

.btn-primary:hover {
  filter: brightness(1.05);
}

.btn-secondary {
  padding: 0 14px;
  background: var(--panel-2);
  color: var(--text);
  border: 1px solid var(--border);
}

.btn-ghost {
  width: 100%;
  padding: 0 14px;
  background: transparent;
  color: var(--text);
  border: 1px solid var(--border);
}

.btn-ghost:hover,
.btn-secondary:hover {
  background: #222836;
}

.btn-icon {
  width: 36px;
  height: 36px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  color: var(--text);
  font-size: 1.25rem;
  line-height: 1;
}

.msg {
  margin: 0;
  color: var(--muted);
  min-height: 1.2em;
  font-size: 0.875rem;
}

.msg.error {
  color: #ffb4ae;
}

.auth-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(700px 280px at 50% -10%, rgba(61, 214, 140, 0.12), transparent 60%),
    var(--bg);
}

.auth-card {
  width: min(400px, 100%);
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 28px;
}

.auth-card h1 {
  margin: 0 0 6px;
  font-size: 1.5rem;
  letter-spacing: -0.02em;
}

.brand-mark {
  margin: 0 0 14px;
  color: var(--accent);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.dashboard {
  display: grid;
  grid-template-columns: 220px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding: 20px 14px;
  border-right: 1px solid var(--line);
  background: #12151b;
}

.sidebar-brand {
  display: grid;
  gap: 2px;
  padding: 2px 8px 10px;
  border-bottom: 1px solid var(--line);
}

.sidebar-brand strong {
  font-size: 0.98rem;
  letter-spacing: -0.01em;
}

.sidebar-brand span {
  color: var(--muted);
  font-size: 0.75rem;
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.nav-item {
  display: flex;
  align-items: center;
  height: 38px;
  padding: 0 12px;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  text-align: left;
}

.nav-item:hover {
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
}

.nav-item.is-active {
  background: rgba(61, 214, 140, 0.12);
  color: var(--accent-2);
  box-shadow: inset 2px 0 0 var(--accent);
}

.sidebar-spacer {
  flex: 1;
}

.sidebar-user {
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel);
  display: grid;
  gap: 2px;
}

.sidebar-user-label {
  color: var(--muted);
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.sidebar-user strong {
  font-size: 0.9rem;
}

.account-card {
  max-width: 480px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px;
}

.main {
  padding: 22px 24px 32px;
  display: grid;
  gap: 16px;
  align-content: start;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.015), transparent 120px),
    var(--bg);
}

.page-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
}

.page-header h1 {
  margin: 0 0 4px;
  font-size: 1.45rem;
  letter-spacing: -0.02em;
}

.stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

.stat-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 14px;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
}

.stat-card span {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 500;
}

.stat-card strong {
  font-size: 1.25rem;
  letter-spacing: -0.02em;
}

.toolbar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 130px 130px auto;
  gap: 8px;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--panel);
}

.search-box,
.search-box input {
  min-width: 0;
}

.table-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
}

.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}

th,
td {
  text-align: left;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}

th {
  color: var(--muted);
  font-size: 0.7rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  font-weight: 600;
  background: #141820;
}

tbody tr:last-child td {
  border-bottom: none;
}

tbody tr:hover {
  background: rgba(255, 255, 255, 0.02);
}

.col-actions {
  width: 1%;
  white-space: nowrap;
}

.stream-name {
  font-weight: 600;
  color: #fff;
}

.stream-meta {
  margin-top: 3px;
  color: var(--muted);
  font-size: 0.75rem;
  max-width: 360px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.badge {
  display: inline-flex;
  align-items: center;
  height: 22px;
  padding: 0 8px;
  border-radius: 6px;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.badge-hls {
  background: rgba(74, 144, 226, 0.16);
  color: #8fc1ff;
}

.badge-dash {
  background: rgba(167, 112, 239, 0.16);
  color: #d2b0ff;
}

.badge-drm {
  background: rgba(61, 214, 140, 0.14);
  color: #7ee2b0;
}

.badge-none {
  background: rgba(255, 255, 255, 0.05);
  color: var(--muted);
}

.link-cell {
  display: grid;
  gap: 3px;
}

.link-cell code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.78rem;
  color: #d5dceb;
}

.link-cell a {
  color: var(--accent-2);
  text-decoration: none;
  font-size: 0.78rem;
  max-width: 220px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.link-cell a:hover {
  text-decoration: underline;
}

.actions {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #12161e;
}

.actions button {
  height: 30px;
  padding: 0 9px;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: #d7deea;
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}

.actions button:hover {
  background: rgba(255, 255, 255, 0.06);
  color: #fff;
}

.actions button.danger {
  color: #ffb0aa;
}

.actions button.danger:hover {
  background: rgba(240, 113, 120, 0.14);
}

.table-msg {
  padding: 10px 14px 12px;
  border-top: 1px solid var(--line);
}

.drawer {
  position: fixed;
  inset: 0;
  z-index: 40;
}

.drawer-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(5, 7, 10, 0.62);
}

.drawer-panel {
  position: absolute;
  top: 0;
  right: 0;
  width: min(440px, 100%);
  height: 100%;
  background: #141820;
  border-left: 1px solid var(--border);
  padding: 18px;
  overflow-y: auto;
}

.drawer-header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.drawer-header h2 {
  margin: 0 0 4px;
  font-size: 1.15rem;
}

.form-section {
  display: grid;
  gap: 12px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel);
}

.form-section h3 {
  margin: 0;
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.drawer-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 50;
  padding: 11px 14px;
  border-radius: 9px;
  background: #1a2030;
  border: 1px solid var(--border);
  color: #fff;
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.35);
}

@media (max-width: 980px) {
  .dashboard {
    grid-template-columns: 1fr;
  }

  .sidebar {
    border-right: none;
    border-bottom: 1px solid var(--line);
  }

  .sidebar-spacer {
    display: none;
  }

  .stats {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .toolbar {
    grid-template-columns: 1fr;
  }

  .col-actions,
  .actions {
    white-space: normal;
  }

  .actions {
    flex-wrap: wrap;
  }
}
