/* Playlists — head/KPI/actions aligned with Deep Insights + Facebook Ads */

.plists-shell {
  position: relative;
  display: block;
  width: 100%;
  max-width: none;
  min-height: calc(100dvh - 2rem);
  padding: 0.25rem 0 3rem;
  box-sizing: border-box;
}

.plists-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.85rem;
  transition: padding-right 0.22s ease;
}

.plists-shell.filters-open .plists-head,
.plists-shell.filters-open .plists-main {
  padding-right: 332px;
}

.plists-shell.filters-collapsed .plists-head,
.plists-shell.filters-collapsed .plists-main {
  padding-right: 0;
}

@media (min-width: 769px) {
  .plists-head {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    align-items: center;
    gap: 0.65rem 0.75rem;
  }

  .plists-head-left {
    margin-bottom: 0;
  }

  .plists-kpis.plists-kpis-head,
  #plists-kpis.plists-kpis-head {
    min-width: 0;
    max-width: 100%;
    justify-self: stretch;
  }

  .plists-head-actions {
    justify-self: end;
    align-self: center;
  }
}

.plists-head-left {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  align-items: flex-start;
  min-width: 0;
  margin-bottom: 0.35rem;
}

.plists-page-title {
  margin: 0;
  font-size: 1.75rem;
  font-weight: 600;
  letter-spacing: -0.02em;
  color: #e2e8f0;
}

.plists-select,
.plists-head-left .app-select-wrap {
  min-width: 12rem;
  max-width: 22rem;
}

.plists-head-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-shrink: 0;
}

.plists-shell.filters-open .plists-head .deep-rail-toggle {
  display: none;
}

.plists-shell.filters-collapsed .deep-rail-toggle svg {
  transform: rotate(180deg);
}

.plists-main {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  transition: padding-right 0.22s ease;
}

/* Cover card — Release Map hero style */
.plists-hero {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.7rem 0.85rem;
  border-radius: 14px;
  border: 1px solid rgba(56, 189, 248, 0.14);
  background: linear-gradient(145deg, rgba(11, 28, 40, 0.95), rgba(6, 14, 22, 0.98));
  min-width: 0;
}
.plists-cover {
  width: 52px;
  height: 52px;
  border-radius: 10px;
  object-fit: cover;
  background: #1e293b;
  flex-shrink: 0;
}
.plists-cover.ph {
  display: grid;
  place-items: center;
  color: #64748b;
  font-size: 0.7rem;
}
.plists-hero-meta {
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-width: 0;
  flex: 1;
}
.plists-hero-name {
  margin: 0 0 0.12rem;
  font-size: 1.05rem;
  font-weight: 700;
  color: #e2e8f0;
  line-height: 1.2;
}
.plists-meta {
  margin: 0;
  font-size: 0.78rem;
  color: #94a3b8;
  line-height: 1.35;
}
.plists-meta a { color: #7dd3fc; }
.plists-desc {
  display: inline-block;
  margin-top: 0.2rem;
  color: #64748b;
}
.plists-filters-drawer .plists-periods {
  position: relative;
  z-index: 5;
}
.plists-filters-drawer .plists-calendar-block .range-picker-popover {
  position: static !important;
}

/* KPI rings — Facebook / Deep style */
.plists-kpis {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 0.5rem 0.4rem;
  align-items: start;
  justify-items: center;
}
.plists-kpis-head {
  flex: 1;
  margin: 0 0.5rem;
  min-width: 0;
}
.plists-kpi {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 0.35rem;
  width: 100%;
  max-width: 96px;
  min-width: 0;
}
.plists-kpi-label {
  font-size: 0.68rem;
  font-weight: 500;
  color: #94a3b8;
  text-align: center;
  line-height: 1.2;
  min-height: 1.45rem;
  margin: 0;
  width: 100%;
}
.plists-kpi-ring {
  width: clamp(48px, 4.5vw, 64px);
  height: clamp(48px, 4.5vw, 64px);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(circle at 30% 20%, rgba(56, 189, 248, 0.22), rgba(8, 20, 32, 0.95));
  border: 1px solid rgba(56, 189, 248, 0.25);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.04);
}
.plists-kpi-ring.spend {
  background: radial-gradient(circle at 30% 20%, rgba(167, 139, 250, 0.28), rgba(8, 20, 32, 0.95));
  border-color: rgba(167, 139, 250, 0.35);
}
.plists-kpi-value {
  font-size: clamp(0.56rem, 0.68vw, 0.72rem);
  font-weight: 600;
  color: #e2e8f0;
  text-align: center;
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
  padding: 0 0.2rem;
}
.plists-kpi-delta {
  font-size: 0.57rem;
  font-weight: 500;
  color: #94a3b8;
  min-height: 0.85rem;
}
.plists-kpi-delta.up { color: #4ade80; }
.plists-kpi-delta.down { color: #f87171; }

.plists-section {
  padding: 1rem 1.1rem;
  border-radius: 14px;
  border: 1px solid rgba(56, 189, 248, 0.12);
  background: rgba(6, 14, 22, 0.85);
}
.plists-section h3 {
  margin: 0 0 0.75rem;
  font-size: 0.95rem;
  color: #bae6fd;
  font-weight: 650;
}
.plists-chart-wrap {
  position: relative;
  width: 100%;
  min-height: 180px;
}
.plists-table-scroll {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-x: contain;
}
.plists-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.82rem;
}
.plists-table th,
.plists-table td {
  text-align: left;
  padding: 0.45rem 0.5rem;
  border-bottom: 1px solid rgba(148, 163, 184, 0.1);
}
.plists-table th {
  color: #64748b;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-weight: 600;
  white-space: nowrap;
  cursor: default;
}
.plists-table th[data-sort] { cursor: pointer; }
.plists-table th[data-sort]::after {
  content: '↕';
  opacity: 0.35;
  margin-left: 0.25rem;
  font-size: 0.65rem;
}
.plists-table th.sort-asc::after { content: '↑'; opacity: 0.9; color: #7dd3fc; }
.plists-table th.sort-desc::after { content: '↓'; opacity: 0.9; color: #7dd3fc; }
.plists-table td.num,
.plists-table th.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}
.plists-section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.5rem;
  width: 100%;
}
.plists-section-head h3 { margin: 0; }
.plists-kind-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  margin-left: auto;
  flex-shrink: 0;
  padding: 0.3rem 0.65rem;
  border-radius: 999px;
  border: 1px solid rgba(148, 163, 184, 0.25);
  background: transparent;
  color: #94a3b8;
  font: inherit;
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
}
.plists-kind-toggle.active {
  border-color: rgba(56, 189, 248, 0.45);
  color: #7dd3fc;
  background: rgba(56, 189, 248, 0.08);
}
.plists-kind-icon {
  font-size: 0.95rem;
  line-height: 1;
}
.plists-table .kind-col { display: none; }
.plists-table.show-kind .kind-col { display: table-cell; }

/* Shared column grid so Track avatars line up across spend + SubmitHub.
   min-width keeps columns readable — wrap scrolls horizontally like FB tables. */
.plists-cols-aligned {
  table-layout: fixed;
  width: 100%;
  min-width: 720px;
}
.plists-cols-aligned.show-kind {
  min-width: 820px;
}
.plists-cols-aligned col.col-pos { width: 2.5rem; }
.plists-cols-aligned col.col-track { width: 30%; }
.plists-cols-aligned col.col-kind { width: 0; }
.plists-cols-aligned.show-kind col.col-kind { width: 12%; }
.plists-cols-aligned col.col-m1 { width: 15%; }
.plists-cols-aligned col.col-m2 { width: 12%; }
.plists-cols-aligned col.col-m3 { width: 12%; }
.plists-cols-aligned col.col-m4 { width: 14%; }
.plists-cols-aligned:not(.show-kind) col.col-m1 { width: 18%; }
.plists-cols-aligned:not(.show-kind) col.col-m4 { width: 16%; }

.plists-table th.pos-col,
.plists-table td.pos-col {
  width: 2.5rem;
  text-align: center;
  color: #64748b;
  font-variant-numeric: tabular-nums;
}
.plists-table th.tail-col,
.plists-table td.tail-col {
  white-space: nowrap;
}
/* Spend spacer matches SubmitHub "Added" width; keep empty */
.plists-cols-spend th.tail-col,
.plists-cols-spend td.tail-col {
  padding: 0;
  border-bottom-color: transparent;
  font-size: 0;
  line-height: 0;
}
/* Added — flush to the right edge */
.plists-cols-sh th.tail-col,
.plists-cols-sh td.tail-col {
  text-align: right;
  padding-right: 0;
}
.plists-track-cell {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  min-width: 0;
}
.plists-track-cover {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  object-fit: cover;
  background: #1e293b;
  flex-shrink: 0;
}
.plists-track-cover.ph {
  display: grid;
  place-items: center;
  font-size: 0.55rem;
  color: #64748b;
}
.plists-track-name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.plists-spent-cell {
  display: block;
  padding: 0.45rem 0.5rem;
}
.plists-spent-val {
  display: block;
  margin-bottom: 0.25rem;
}
.plists-bar-track {
  height: 4px;
  border-radius: 999px;
  background: rgba(148, 163, 184, 0.15);
  overflow: hidden;
}
.plists-bar-fill {
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #38bdf8, #a78bfa);
}
.plists-status {
  margin: 0;
  font-size: 0.85rem;
  color: #94a3b8;
  min-height: 0;
}
.plists-status:empty { display: none; }
.plists-status.err { color: #f87171; }
.plists-status.ok { color: #4ade80; }
.plists-empty {
  margin: 0.5rem 0 0;
  font-size: 0.85rem;
}

/* Same drawer chrome as Deep / Release Map / Facebook */
.plists-filters-drawer {
  position: fixed;
  top: 1rem;
  right: 0;
  bottom: 0;
  width: 320px;
  z-index: 40;
  overflow: auto;
  padding: 0.6rem 0.85rem 1.25rem;
  box-sizing: border-box;
  transform: translateX(0);
  transition: transform 0.22s ease;
  background: rgba(4, 10, 18, 0.96);
  border-left: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 14px 0 0 0;
}
.plists-filters-drawer.collapsed {
  transform: translateX(110%);
}
.plists-filters-panel {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}
.plists-filters-panel .drawer-collapse-btn {
  padding: 0.6rem;
  margin-bottom: 0.15rem;
}
.plists-filter-block {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  margin-bottom: 0;
}
.plists-filter-label-sm {
  font-size: 0.72rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: #94a3b8;
}
.plists-calendar-block .range-picker-popover {
  position: static;
  width: 100%;
  max-width: none;
  border: 1px solid rgba(148, 163, 184, 0.18);
  box-shadow: none;
}

@media (max-width: 1280px) {
  .plists-head {
    flex-wrap: wrap;
  }
  .plists-kpis-head {
    order: 3;
    flex-basis: 100%;
    margin: 0.4rem 0 0;
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 900px) {
  .plists-shell.filters-open .plists-head,
  .plists-shell.filters-open .plists-main {
    padding-right: 0;
  }
  .plists-filters-drawer:not(.collapsed) ~ #plists-drawer-backdrop,
  #plists-drawer-backdrop[aria-hidden="false"] {
    display: block;
  }
}

@media (max-width: 768px) {
  .plists-shell {
    padding-top: 0.15rem;
    padding-bottom: 1.25rem;
  }

  .plists-head {
    flex-wrap: wrap;
    gap: 0.55rem;
    margin-bottom: 0.65rem;
  }

  .plists-page-title {
    display: none;
  }

  .plists-head-left {
    width: 100%;
    flex: 1 1 100%;
    order: 1;
    align-items: stretch;
    margin-bottom: 0;
    gap: 0;
  }

  .plists-head-left .app-select-wrap,
  .plists-select {
    width: 100%;
    min-width: 0;
    max-width: none;
    display: block;
  }

  .plists-head-actions {
    display: none;
  }

  .plists-shell.filters-open .plists-head .deep-rail-toggle {
    display: none;
  }

  .plists-kpis.plists-kpis-head {
    display: flex;
    flex-wrap: nowrap;
    overflow-x: auto;
    width: 100%;
    flex: 1 1 100%;
    order: 2;
    margin: 0.35rem 0 0;
    padding-bottom: 0.35rem;
    gap: 0;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
    scroll-snap-type: x mandatory;
  }
  .plists-kpis.plists-kpis-head::-webkit-scrollbar {
    display: none;
  }
  .plists-kpis.plists-kpis-head .plists-kpi {
    flex: 0 0 25%;
    max-width: none;
    scroll-snap-align: start;
  }
  .plists-kpi-ring {
    width: min(20vw, 74px);
    height: min(20vw, 74px);
  }
  .plists-kpi-value { font-size: 0.67rem; }
  .plists-kpi-label {
    font-size: 0.57rem;
    min-height: 1.1rem;
  }
  .plists-kpi-delta { font-size: 0.57rem; }

  .plists-cover {
    width: 56px;
    height: 56px;
  }
  .plists-hero-name {
    font-size: 1.15rem;
    margin-bottom: 0.35rem;
    line-height: 1.35;
  }
  .plists-meta {
    line-height: 1.55;
  }
  /* Dates live in the filter drawer — hide from hero on phone */
  .plists-range-meta {
    display: none;
  }

  /* Hide # without display:none — under table-layout:fixed that remaps
     col widths onto the next visible column and collapses Track names. */
  .plists-table th.pos-col,
  .plists-table td.pos-col {
    width: 0 !important;
    max-width: 0;
    padding: 0 !important;
    border: none;
    overflow: hidden;
    font-size: 0;
    line-height: 0;
    color: transparent;
  }
  .plists-cols-aligned col.col-pos {
    width: 0;
  }
  .plists-table th:nth-child(2),
  .plists-table td:nth-child(2) {
    min-width: 10.5rem;
  }

  .plists-filters-drawer {
    transform: translateX(110%);
    top: 1rem;
    height: calc(100dvh - 1rem);
    width: 100%;
    border-radius: 18px 18px 0 0;
    background: #060d16;
    border-top: 1px solid rgba(255, 255, 255, 0.12);
    border-left: none;
    padding: 0.6rem 7% 1.25rem 0.85rem;
  }
  body.plists-filters-open .plists-filters-drawer {
    transform: translateX(0);
  }
  .plists-filters-drawer.collapsed {
    transform: translateX(110%);
  }
  .plists-filters-panel .drawer-collapse-btn {
    padding: 0.6rem;
    margin-bottom: 0.15rem;
  }
  .plists-filters-panel .drawer-collapse-btn svg {
    width: 20px;
    height: 20px;
  }
}
