:root {
  --bg: #0a0c10;
  --panel: #11141a;
  --panel-2: #161a21;
  --panel-3: #1c222b;
  --line: #242b35;
  --text: #e9eef5;
  --muted: #8b97a8;
  --accent: #53fc18;
  --accent-soft: rgba(83, 252, 24, 0.12);
  --violet: #8b6cff;
  --danger: #ff4d5e;
  --warn: #ffb020;
  --radius: 14px;
  --shadow: 0 18px 40px rgba(0, 0, 0, 0.45);
  color-scheme: dark;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  height: 100%;
}

body {
  background:
    radial-gradient(1200px 600px at 80% -10%, rgba(139, 108, 255, 0.14), transparent 60%),
    radial-gradient(900px 500px at 0% 0%, rgba(83, 252, 24, 0.08), transparent 55%),
    var(--bg);
  color: var(--text);
  font-family: 'Inter', 'Segoe UI', system-ui, -apple-system, sans-serif;
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
}

h1,
h2,
h3 {
  margin: 0;
  font-weight: 650;
  letter-spacing: -0.01em;
}

p {
  margin: 0;
}

button,
input,
select {
  font: inherit;
  color: inherit;
}

.hidden {
  display: none !important;
}

.muted {
  color: var(--muted);
}

/* ------------------------------------------------------------------ topbar */

.app {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 22px;
  border-bottom: 1px solid var(--line);
  background: rgba(10, 12, 16, 0.78);
  backdrop-filter: blur(14px);
  position: sticky;
  top: 0;
  z-index: 20;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.logo {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  background: linear-gradient(140deg, var(--accent), #1fa300 70%);
  box-shadow: 0 0 22px rgba(83, 252, 24, 0.35);
  position: relative;
}

.logo::after {
  content: '';
  position: absolute;
  inset: 10px;
  border-radius: 4px;
  background: #0a0c10;
  clip-path: polygon(0 0, 100% 50%, 0 100%);
}

.brand-text h1 {
  font-size: 16px;
  line-height: 1.2;
}

.brand-text p {
  font-size: 11.5px;
  color: var(--muted);
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.conn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 12px;
  color: var(--muted);
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
}

.conn i {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--warn);
  box-shadow: 0 0 0 3px rgba(255, 176, 32, 0.18);
}

.conn.is-live i {
  background: var(--accent);
  box-shadow: 0 0 0 3px rgba(83, 252, 24, 0.18);
}

.conn.is-down i {
  background: var(--danger);
  box-shadow: 0 0 0 3px rgba(255, 77, 94, 0.18);
}

/* ------------------------------------------------------------------ botones */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 9px 14px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--text);
  cursor: pointer;
  font-size: 13px;
  font-weight: 550;
  transition:
    background 0.15s ease,
    border-color 0.15s ease,
    transform 0.1s ease;
}

.btn:hover {
  background: var(--panel-3);
  border-color: #31394a;
}

.btn:active {
  transform: translateY(1px);
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--accent);
  border-color: transparent;
  color: #06120a;
  font-weight: 650;
}

.btn-primary:hover {
  background: #6dff3d;
  border-color: transparent;
}

.btn-ghost {
  background: transparent;
  border-color: transparent;
  color: var(--muted);
}

.btn-danger {
  background: rgba(255, 77, 94, 0.1);
  border-color: rgba(255, 77, 94, 0.35);
  color: #ff8a94;
}

.btn-danger:hover {
  background: rgba(255, 77, 94, 0.18);
}

.btn-sm {
  padding: 6px 10px;
  font-size: 12px;
}

/* ------------------------------------------------------------------ badges */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 9px;
  border-radius: 999px;
  font-size: 10.5px;
  font-weight: 750;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.badge-live {
  background: var(--accent-soft);
  color: var(--accent);
  border: 1px solid rgba(83, 252, 24, 0.3);
}

.badge-live i {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
  animation: pulse 1.6s infinite;
}

.badge-off {
  background: rgba(139, 151, 168, 0.1);
  color: var(--muted);
  border: 1px solid var(--line);
}

.badge-demo {
  background: rgba(139, 108, 255, 0.14);
  color: #b9a6ff;
  border: 1px solid rgba(139, 108, 255, 0.35);
}

@keyframes pulse {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.35;
  }
}

/* ------------------------------------------------------------------ layout */

.layout {
  display: grid;
  grid-template-columns: 252px minmax(0, 1fr);
  align-items: start;
  min-height: calc(100vh - 63px);
}

.sidebar {
  position: sticky;
  top: 63px;
  height: calc(100vh - 63px);
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 18px 14px;
  border-right: 1px solid var(--line);
  background: rgba(17, 20, 26, 0.55);
}

.sidebar-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 6px;
}

.sidebar-head h2 {
  font-size: 11px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
}

.channel-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
  overflow-y: auto;
}

.channel-item button {
  width: 100%;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 2px 8px;
  text-align: left;
  padding: 10px 12px;
  border-radius: 11px;
  border: 1px solid transparent;
  background: transparent;
  cursor: pointer;
}

.channel-item button:hover {
  background: var(--panel-2);
}

.channel-item button.is-active {
  background: var(--panel-2);
  border-color: var(--line);
}

.channel-item .name {
  font-weight: 600;
  font-size: 13px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.channel-item .meta {
  font-size: 11px;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #3a4351;
  align-self: center;
}

.dot.is-live {
  background: var(--accent);
  box-shadow: 0 0 8px rgba(83, 252, 24, 0.7);
}

.channel-item .paused {
  font-size: 10px;
  color: var(--warn);
}

.sidebar-empty {
  padding: 18px 10px;
  font-size: 12.5px;
  line-height: 1.5;
  color: var(--muted);
}

.sidebar-foot {
  margin-top: auto;
  padding: 10px 6px 0;
  border-top: 1px solid var(--line);
  font-size: 11px;
}

/* -------------------------------------------------------------------- main */

.main {
  padding: 22px 24px 60px;
  min-width: 0;
}

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  gap: 22px;
  padding: 20px 22px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background:
    linear-gradient(180deg, rgba(28, 34, 43, 0.55), rgba(17, 20, 26, 0.85)),
    var(--panel);
  box-shadow: var(--shadow);
}

.hero-title {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.hero-title h2 {
  font-size: 22px;
}

.stream-title {
  margin-top: 6px;
  font-size: 13px;
  min-height: 18px;
}

.stats {
  display: grid;
  grid-template-columns: minmax(180px, 1.6fr) repeat(3, minmax(90px, 1fr));
  gap: 18px;
  margin-top: 20px;
}

.stat {
  display: flex;
  flex-direction: column;
  gap: 5px;
  min-width: 0;
}

.stat-label {
  font-size: 10.5px;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--muted);
}

.stat-value {
  font-size: 21px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  line-height: 1;
}

.stat-value .unit {
  font-size: 11px;
  font-weight: 500;
  color: var(--muted);
  margin-left: 4px;
}

.stat-sub {
  font-size: 11px;
  color: var(--muted);
}

.score-bar {
  height: 8px;
  border-radius: 999px;
  background: #0b0e13;
  border: 1px solid var(--line);
  overflow: hidden;
}

.score-fill {
  height: 100%;
  width: 0%;
  border-radius: 999px;
  background: linear-gradient(90deg, #2f7bff, var(--violet) 45%, var(--accent) 100%);
  transition: width 0.4s ease;
}

.reasons {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  list-style: none;
  margin: 16px 0 0;
  padding: 0;
  min-height: 22px;
}

.reasons li {
  font-size: 11.5px;
  padding: 3px 9px;
  border-radius: 999px;
  background: rgba(139, 108, 255, 0.12);
  border: 1px solid rgba(139, 108, 255, 0.25);
  color: #c3b4ff;
}

.channel-error {
  margin-top: 12px;
  font-size: 12px;
  color: #ff9aa3;
  background: rgba(255, 77, 94, 0.08);
  border: 1px solid rgba(255, 77, 94, 0.25);
  padding: 8px 11px;
  border-radius: 9px;
  word-break: break-word;
}

.hero-side {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 14px;
  border-left: 1px solid var(--line);
  padding-left: 22px;
}

#sparkline {
  width: 100%;
  height: 96px;
  display: block;
}

.hero-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.live-frame {
  margin-top: 16px;
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--line);
  background: #000;
  aspect-ratio: 16 / 9;
  max-height: 480px;
}

.live-frame iframe {
  width: 100%;
  height: 100%;
  border: 0;
  display: block;
}

/* ------------------------------------------------------------------- clips */

.clips-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  margin: 28px 0 14px;
}

.clips-title {
  display: flex;
  align-items: baseline;
  gap: 10px;
}

.clips-title h3 {
  font-size: 16px;
}

.filters {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.chip {
  padding: 6px 12px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 12px;
  font-weight: 550;
}

.chip:hover {
  color: var(--text);
  background: var(--panel-2);
}

.chip.is-active {
  background: var(--panel-3);
  border-color: #39424f;
  color: var(--text);
}

.clips {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(292px, 1fr));
  gap: 16px;
}

.clip {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--panel);
  display: flex;
  flex-direction: column;
  transition:
    border-color 0.15s ease,
    transform 0.15s ease;
}

.clip:hover {
  border-color: #333c4a;
}

.clip.is-new {
  animation: pop 0.5s ease;
}

@keyframes pop {
  from {
    transform: scale(0.98);
    border-color: var(--accent);
  }
  to {
    transform: scale(1);
  }
}

.clip-media {
  position: relative;
  aspect-ratio: 16 / 9;
  background:
    repeating-linear-gradient(135deg, #12151a 0 10px, #14181e 10px 20px);
  display: grid;
  place-items: center;
}

.clip-media video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  background: #000;
}

.clip-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 11.5px;
  text-align: center;
  padding: 12px;
}

.clip-placeholder strong {
  font-size: 13px;
  color: #b9c3d1;
}

.spinner {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.12);
  border-top-color: var(--accent);
  animation: spin 0.9s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.score-chip {
  position: absolute;
  top: 9px;
  left: 9px;
  padding: 4px 9px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 750;
  font-variant-numeric: tabular-nums;
  background: rgba(0, 0, 0, 0.62);
  backdrop-filter: blur(6px);
  border: 1px solid rgba(255, 255, 255, 0.14);
}

.score-chip.hot {
  color: var(--accent);
  border-color: rgba(83, 252, 24, 0.4);
}

.score-chip.warm {
  color: #d3c4ff;
  border-color: rgba(139, 108, 255, 0.4);
}

.score-chip.cool {
  color: #9fb0c4;
}

.clip-duration {
  position: absolute;
  bottom: 9px;
  right: 9px;
  padding: 3px 7px;
  border-radius: 6px;
  font-size: 11px;
  font-variant-numeric: tabular-nums;
  background: rgba(0, 0, 0, 0.66);
  color: #dfe7f1;
}

.clip-status {
  position: absolute;
  top: 9px;
  right: 9px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  padding: 4px 8px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.6);
  border: 1px solid rgba(255, 255, 255, 0.12);
}

.clip-status.approved {
  color: var(--accent);
  border-color: rgba(83, 252, 24, 0.35);
}

.clip-status.rejected {
  color: #ff8a94;
  border-color: rgba(255, 77, 94, 0.35);
}

.clip-status.failed {
  color: var(--warn);
  border-color: rgba(255, 176, 32, 0.35);
}

.clip-body {
  padding: 12px 13px 13px;
  display: flex;
  flex-direction: column;
  gap: 9px;
  flex: 1;
}

.clip-title {
  width: 100%;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 7px;
  padding: 4px 6px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}

.clip-title:hover {
  border-color: var(--line);
}

.clip-title:focus {
  outline: none;
  border-color: #3a4a63;
  background: var(--panel-2);
}

.clip-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 11px;
  color: var(--muted);
}

.clip-reasons {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  list-style: none;
  margin: 0;
  padding: 0;
}

.clip-reasons li {
  font-size: 10.5px;
  padding: 2px 7px;
  border-radius: 999px;
  background: rgba(139, 108, 255, 0.1);
  color: #b6a7f2;
}

.clip-error {
  font-size: 11px;
  color: #ff9aa3;
  word-break: break-word;
}

.clip-actions {
  display: flex;
  gap: 6px;
  margin-top: auto;
  padding-top: 4px;
}

.icon-btn {
  flex: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  padding: 7px 8px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--muted);
  cursor: pointer;
  font-size: 11.5px;
  font-weight: 600;
  text-decoration: none;
}

.icon-btn:hover {
  color: var(--text);
  background: var(--panel-3);
}

.icon-btn.is-on {
  color: var(--accent);
  border-color: rgba(83, 252, 24, 0.35);
  background: rgba(83, 252, 24, 0.1);
}

.icon-btn.is-off {
  color: #ff8a94;
  border-color: rgba(255, 77, 94, 0.3);
  background: rgba(255, 77, 94, 0.08);
}

.icon-btn.danger:hover {
  color: #ff8a94;
  border-color: rgba(255, 77, 94, 0.35);
}

/* -------------------------------------------------------------- empty state */

.empty-state {
  margin: 60px auto;
  max-width: 420px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  color: var(--muted);
  line-height: 1.55;
  font-size: 13px;
}

.empty-state h2 {
  color: var(--text);
  font-size: 18px;
}

/* ------------------------------------------------------------------ drawer */

.drawer {
  position: fixed;
  top: 0;
  right: 0;
  height: 100vh;
  width: 390px;
  max-width: 92vw;
  background: var(--panel);
  border-left: 1px solid var(--line);
  box-shadow: -30px 0 60px rgba(0, 0, 0, 0.5);
  transform: translateX(102%);
  transition: transform 0.25s ease;
  z-index: 40;
  display: flex;
  flex-direction: column;
}

.drawer.is-open {
  transform: translateX(0);
}

.drawer-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 18px;
  border-bottom: 1px solid var(--line);
}

.drawer-head h2 {
  font-size: 15px;
}

.drawer-body {
  padding: 16px 18px 26px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

fieldset {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 14px;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

legend {
  padding: 0 6px;
  font-size: 10.5px;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--muted);
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 12.5px;
}

.field > span {
  color: #c7d1de;
  display: flex;
  justify-content: space-between;
  gap: 8px;
}

.field em {
  font-style: normal;
  font-size: 10.5px;
  color: var(--muted);
}

.field input,
.field select,
.dialog input {
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 9px 10px;
  font-size: 13px;
  width: 100%;
}

.field input:focus,
.field select:focus,
.dialog input:focus {
  outline: none;
  border-color: #3d4c63;
  box-shadow: 0 0 0 3px rgba(139, 108, 255, 0.14);
}

.weights {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.drawer-actions {
  display: flex;
  gap: 8px;
  justify-content: space-between;
}

/* ------------------------------------------------------------------ dialog */

.dialog {
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--panel);
  color: var(--text);
  padding: 22px;
  width: 380px;
  max-width: 92vw;
  box-shadow: var(--shadow);
}

.dialog::backdrop {
  background: rgba(4, 6, 9, 0.68);
  backdrop-filter: blur(3px);
}

.dialog form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.dialog h2 {
  font-size: 17px;
}

.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 6px;
}

/* ------------------------------------------------------------------ toasts */

.toasts {
  position: fixed;
  bottom: 18px;
  right: 18px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 60;
}

.toast {
  padding: 10px 14px;
  border-radius: 10px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  font-size: 12.5px;
  max-width: 330px;
  animation: toast-in 0.2s ease;
}

.toast.ok {
  border-color: rgba(83, 252, 24, 0.35);
}

.toast.err {
  border-color: rgba(255, 77, 94, 0.4);
  color: #ffb0b7;
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
}

/* ------------------------------------------------------------- responsive */

@media (max-width: 1100px) {
  .hero {
    grid-template-columns: 1fr;
  }

  .hero-side {
    border-left: 0;
    border-top: 1px solid var(--line);
    padding-left: 0;
    padding-top: 16px;
  }

  .stats {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 860px) {
  .layout {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    height: auto;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .channel-list {
    flex-direction: row;
    overflow-x: auto;
  }

  .channel-item {
    min-width: 170px;
  }

  .main {
    padding: 16px 14px 60px;
  }

  .brand-text p {
    display: none;
  }

  .stats {
    gap: 14px;
  }
}
