.admin {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 250px minmax(0, 1fr);
  background: #08080b;
}
.admin__sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 24px 16px 20px;
  background: #0b0b10;
  border-right: 1px solid var(--line);
}
.admin__brand { display: flex; align-items: center; gap: 10px; padding: 0 8px 18px; }
.admin__badge {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 9px; border-radius: 5px;
  background: rgba(229,9,20,.14); border: 1px solid rgba(229,9,20,.3);
  color: #ff8b91; font-size: 10px; font-weight: 700; letter-spacing: .14em;
  margin: 0 8px 14px;
  width: fit-content;
}
.admin__nav { display: grid; gap: 4px; }
.admin__nav-btn {
  display: flex; align-items: center; gap: 11px;
  padding: 10px 12px;
  border-radius: 8px;
  font-size: 13.5px;
  color: var(--text-dim);
  text-align: left;
  transition: background .15s, color .15s;
}
.admin__nav-btn svg { color: var(--text-faint); }
.admin__nav-btn:hover { background: rgba(255,255,255,.05); color: #fff; }
.admin__nav-btn.is-active { background: rgba(229,9,20,.13); color: #fff; font-weight: 600; }
.admin__nav-btn.is-active svg { color: var(--accent); }
.admin__nav-sep { height: 1px; background: var(--line); margin: 14px 8px; }
.admin__sidefoot { margin-top: auto; display: grid; gap: 8px; }
.admin__sidefoot a, .admin__sidefoot button {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; border-radius: 8px;
  font-size: 12.5px; color: var(--text-faint);
}
.admin__sidefoot a:hover, .admin__sidefoot button:hover { background: rgba(255,255,255,.05); color: #fff; }
.admin__user { display: flex; gap: 10px; align-items: center; padding: 10px 8px 0; border-top: 1px solid var(--line); }
.admin__user img { width: 34px; height: 34px; border-radius: 8px; object-fit: cover; }
.admin__user strong { display: block; font-size: 12.5px; }
.admin__user span { font-size: 10.5px; color: var(--text-faint); }

.admin__main { min-width: 0; padding-bottom: 60px; }
.admin__topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 16px;
  padding: 20px clamp(18px, 3vw, 36px);
  background: rgba(8,8,11,.82);
  backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--line);
}
.admin__topbar h1 { font-size: 18px; letter-spacing: -.02em; }
.admin__topbar p { font-size: 12px; color: var(--text-faint); margin-top: 2px; }
.admin__topbar .grow { flex: 1; }
.admin__body { padding: 26px clamp(18px, 3vw, 36px); display: grid; gap: 22px; min-width: 0; }
.admin__body > * { min-width: 0; }

.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 14px; min-width: 0; }
.kpi {
  position: relative;
  padding: 18px;
  border-radius: 12px;
  background: linear-gradient(165deg, #16161e, #101015);
  border: 1px solid var(--line);
  overflow: hidden;
}
.kpi::after {
  content: ''; position: absolute; right: -30px; top: -30px;
  width: 110px; height: 110px; border-radius: 50%;
  background: radial-gradient(circle, rgba(229,9,20,.18), transparent 70%);
}
.kpi__label { font-size: 11.5px; letter-spacing: .1em; text-transform: uppercase; color: var(--text-faint); font-weight: 600; display: flex; align-items: center; gap: 7px; min-width: 0; }
.kpi__value { font-size: 1.75rem; font-weight: 800; letter-spacing: -.035em; margin-top: 6px; }
.kpi__meta { font-size: 11.5px; color: var(--text-faint); margin-top: 2px; }
.kpi__meta b { color: #46d369; font-weight: 600; }

.admin-grid { display: grid; grid-template-columns: minmax(0, 1.55fr) minmax(0, 1fr); gap: 18px; align-items: start; }
.admin-card {
  border-radius: 12px;
  border: 1px solid var(--line);
  background: #101015;
  overflow: hidden;
}
.admin-card__head { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 15px 18px; border-bottom: 1px solid var(--line); }
.admin-card__head h3 { font-size: 13.5px; font-weight: 650; letter-spacing: -.01em; }
.admin-card__head span { font-size: 11.5px; color: var(--text-faint); }
.admin-card__body { padding: 18px; }

.chart { display: flex; align-items: flex-end; gap: 6px; height: 190px; padding-top: 10px; }
.chart__col { flex: 1 1 0; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; gap: 7px; min-width: 0; }
.chart__bar {
  width: 100%;
  min-height: 4px;
  border-radius: 4px 4px 2px 2px;
  background: linear-gradient(180deg, #ff3b46, #8b5cf6);
  transition: height .4s var(--ease);
  position: relative;
}
.chart__bar:hover { filter: brightness(1.2); }
.chart__bar[data-value]:hover::after {
  content: attr(data-value);
  position: absolute; left: 50%; top: -24px; transform: translateX(-50%);
  padding: 2px 6px; border-radius: 4px;
  background: #fff; color: #000; font-size: 10px; font-weight: 700;
  white-space: nowrap;
}
.chart__label { font-size: 9.5px; color: var(--text-faint); white-space: nowrap; }

.rank-list { display: grid; gap: 2px; }
.rank-item { display: flex; align-items: center; gap: 11px; padding: 8px; border-radius: 8px; transition: background .15s; }
.rank-item:hover { background: rgba(255,255,255,.04); }
.rank-item__num { width: 18px; font-size: 12px; font-weight: 700; color: var(--text-faint); text-align: center; }
.rank-item img { width: 34px; height: 50px; border-radius: 4px; object-fit: cover; background: var(--surface-3); }
.rank-item__title { font-size: 13px; font-weight: 600; min-width: 0; }
.rank-item__meta { font-size: 11px; color: var(--text-faint); }
.rank-item__plays { margin-left: auto; font-size: 12px; color: var(--text-dim); font-variant-numeric: tabular-nums; }

.legend { display: grid; gap: 8px; }
.legend__row { display: flex; align-items: center; gap: 9px; font-size: 12.5px; color: var(--text-dim); }
.legend__dot { width: 9px; height: 9px; border-radius: 3px; flex: none; }
.legend__val { margin-left: auto; font-weight: 600; color: #fff; }

.admin-toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-bottom: 16px; }
.admin-toolbar .input, .admin-toolbar .select { min-height: 38px; font-size: 13px; }
.admin-toolbar .input { max-width: 280px; }

.table-wrap { overflow-x: auto; border-radius: 12px; border: 1px solid var(--line); background: #101015; }
table.data { width: 100%; border-collapse: collapse; font-size: 13px; }
table.data th {
  text-align: left;
  padding: 11px 14px;
  font-size: 10.5px;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--text-faint);
  font-weight: 700;
  border-bottom: 1px solid var(--line);
  background: #0d0d12;
  white-space: nowrap;
}
table.data td { padding: 11px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; color: var(--text-dim); }
table.data tr:last-child td { border-bottom: 0; }
table.data tr:hover td { background: rgba(255,255,255,.025); }
table.data td.strong { color: #fff; font-weight: 600; }
.cell-title { display: flex; align-items: center; gap: 10px; min-width: 190px; }
.cell-title img { width: 30px; height: 45px; border-radius: 4px; object-fit: cover; background: var(--surface-3); flex: none; }
.cell-title div { min-width: 0; }
.cell-title strong { display: block; font-size: 13px; color: #fff; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 260px; }
.cell-title span { font-size: 11px; color: var(--text-faint); }
.pill {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 8px; border-radius: 999px;
  font-size: 10.5px; font-weight: 600;
  background: rgba(255,255,255,.06); border: 1px solid var(--line); color: var(--text-dim);
  white-space: nowrap;
}
.pill--green { background: rgba(70,211,105,.12); border-color: rgba(70,211,105,.28); color: #7ee29a; }
.pill--red { background: rgba(229,9,20,.12); border-color: rgba(229,9,20,.3); color: #ff8b91; }
.pill--violet { background: rgba(139,92,246,.14); border-color: rgba(139,92,246,.3); color: #c4b5fd; }
.table-actions { display: flex; gap: 4px; justify-content: flex-end; }

.admin-empty { padding: 50px 20px; text-align: center; color: var(--text-faint); font-size: 13px; }

/* forms in admin */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-grid .span-2 { grid-column: span 2; }
.form-section { display: grid; gap: 12px; padding-top: 6px; }
.form-section__title { font-size: 11px; letter-spacing: .14em; text-transform: uppercase; color: var(--text-faint); font-weight: 700; margin-top: 6px; }
.media-preview { display: flex; gap: 10px; align-items: flex-end; }
.media-preview__poster { width: 58px; height: 87px; border-radius: 5px; overflow: hidden; background: var(--surface-2); border: 1px solid var(--line); flex: none; }
.media-preview__backdrop { width: 120px; height: 68px; border-radius: 5px; overflow: hidden; background: var(--surface-2); border: 1px solid var(--line); flex: none; }
.media-preview img { width: 100%; height: 100%; object-fit: cover; }

.episodes-editor { display: grid; gap: 8px; }
.ep-edit {
  display: grid;
  grid-template-columns: 58px 58px 1fr 74px 1.4fr 32px;
  gap: 8px;
  align-items: center;
  padding: 8px;
  border-radius: 8px;
  background: rgba(255,255,255,.03);
  border: 1px solid var(--line);
}
.ep-edit .input { min-height: 34px; font-size: 12px; padding: 4px 8px; }
.ep-edit__del { width: 30px; height: 30px; border-radius: 6px; display: grid; place-items: center; color: var(--text-faint); }
.ep-edit__del:hover { background: rgba(229,9,20,.15); color: #ff6b73; }

.sub-title { font-size: 12px; color: var(--text-faint); }

.collection-card {
  display: grid;
  gap: 10px;
  padding: 16px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: #101015;
}
.collection-card__head { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.collection-card__head h3 { font-size: 14.5px; }
.collection-card__thumbs { display: flex; gap: 5px; }
.collection-card__thumbs img { width: 34px; height: 51px; border-radius: 4px; object-fit: cover; background: var(--surface-3); }
.collection-card__thumbs span { width: 34px; height: 51px; border-radius: 4px; background: rgba(255,255,255,.06); display: grid; place-items: center; font-size: 11px; color: var(--text-faint); }
.collections-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 14px; }

@media (max-width: 1080px) {
  .admin { grid-template-columns: minmax(0, 1fr); }
  .admin__sidebar {
    position: relative; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center;
    padding: 12px 16px; gap: 12px; border-right: 0; border-bottom: 1px solid var(--line);
  }
  .admin__brand { padding: 0; }
  .admin__badge { display: none; }
  .admin__nav { display: flex; flex-wrap: wrap; gap: 4px; width: 100%; }
  .admin__nav-btn { padding: 8px 10px; font-size: 12.5px; }
  .admin__nav-sep { display: none; }
  .admin__sidefoot { margin-top: 0; display: flex; width: 100%; }
  .admin__user { display: none; }
  .admin-grid { grid-template-columns: 1fr; }
}

@media (max-width: 700px) {
  .form-grid { grid-template-columns: 1fr; }
  .form-grid .span-2 { grid-column: auto; }
  .ep-edit { grid-template-columns: 1fr 1fr; }
  .ep-edit .input:nth-child(3) { grid-column: span 2; }
}

@media (max-width: 700px) {
  .admin__sidebar { padding: 12px; gap: 10px; }
  .admin__nav { flex-wrap: wrap; overflow-x: visible; padding-bottom: 2px; }
  .admin__nav-btn { flex: 0 0 auto; }
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .kpi { padding: 14px; }
  .kpi__value { font-size: 1.6rem; }
  .admin__body { padding: 14px 12px 28px; }
  .admin-card__body { overflow-x: auto; }
}

.collection-card__head { min-height: 42px; }
.collection-card__head h3 { line-height: 1.3; }

.chart-empty { height: 170px; display: grid; place-items: center; color: var(--text-faint); font-size: 12.5px; }


/* Subidas de archivos y pagos */
.upload-control { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin: 7px 0 2px; }
.upload-control .btn { flex: 0 0 auto; }
.upload-control__status { font-size: 11px; color: var(--text-faint); overflow-wrap: anywhere; }
.ep-upload-row { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 7px; }
.ep-upload-row .upload-control { margin: 0; }
.ep-edit { grid-template-columns: 52px 52px minmax(120px,1.2fr) 70px minmax(150px,1.4fr) minmax(130px,1fr) 34px; }
.pay-filters { display: flex; flex-wrap: wrap; gap: 6px; }
.pay-filters .chip b { font-size: 10px; opacity: .75; margin-left: 2px; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
.pill--amber { background: rgba(245,158,11,.12); border-color: rgba(245,158,11,.3); color: #ffd28a; }
@media (max-width: 1100px) {
  .ep-edit { grid-template-columns: 52px 52px 1fr 70px; }
  .ep-edit [data-ep=videoUrl], .ep-edit [data-ep=stillUrl] { grid-column: 1 / -2; }
  .ep-edit__del { grid-column: -2 / -1; }
}
