:root {
  --bg: #0a0f18;
  --bg-elev: #121b2b;
  --bg-card: rgba(248, 250, 255, 0.95);
  --line: rgba(22, 36, 57, 0.15);
  --ink: #102036;
  --ink-soft: #5f748a;
  --accent: #f05b3f;
  --accent-dark: #cf452b;
  --blue: #2b77ff;
  --teal: #1c9d95;
  --danger: #d12e54;
  --ok: #1f9f61;
  --shadow: 0 22px 44px rgba(8, 12, 20, 0.2);
  --radius-xl: 20px;
  --radius-md: 12px;
  --editor-list-height: clamp(640px, 74vh, 980px);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  color: var(--ink);
  font-family: "Space Grotesk", "Segoe UI", sans-serif;
  background:
    radial-gradient(circle at 5% 0%, rgba(240, 91, 63, 0.22), transparent 28%),
    radial-gradient(circle at 95% 0%, rgba(43, 119, 255, 0.2), transparent 32%),
    linear-gradient(180deg, #eaf1f8, #f5f7fb 45%, #f3f3f6);
  min-height: 100vh;
}

.shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 280px 1fr;
}

.sidebar {
  background:
    radial-gradient(circle at 30% -20%, rgba(43, 119, 255, 0.2), transparent 50%),
    linear-gradient(180deg, #070b11, #101826 40%, #121a2b);
  color: #fff;
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  position: sticky;
  top: 0;
  height: 100vh;
}

.sidebar-brand h1 {
  margin: 0;
  letter-spacing: 0.08em;
}

.sidebar-brand p {
  margin: 0.25rem 0 0;
  color: rgba(255, 255, 255, 0.75);
  font-size: 0.9rem;
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.nav-item {
  border: 0;
  border-radius: 999px;
  text-align: left;
  background: transparent;
  color: rgba(255, 255, 255, 0.9);
  padding: 0.7rem 0.9rem;
  font: inherit;
  cursor: pointer;
}

.nav-item.active {
  background: linear-gradient(135deg, rgba(49, 76, 116, 0.95), rgba(25, 40, 65, 0.95));
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.08);
}

.sidebar-actions {
  margin-top: auto;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.content {
  padding: 1.35rem;
}

.topbar {
  display: flex;
  align-items: center;
  gap: 0.9rem;
  margin-bottom: 1.25rem;
}

.topbar h2 {
  margin: 0;
  letter-spacing: -0.02em;
}

.topbar p {
  margin: 0.2rem 0 0;
  color: var(--ink-soft);
}

.menu-btn {
  border: 0;
  border-radius: 10px;
  background: #13243c;
  color: #fff;
  padding: 0.55rem 0.7rem;
  display: none;
  cursor: pointer;
}

.sidebar-overlay {
  display: none;
}

.page-section.hidden {
  display: none;
}

.panel {
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow);
  padding: 1.3rem;
  margin-bottom: 1.25rem;
}

.panel h3 {
  margin: 0 0 0.35rem;
}

.panel p.lead {
  margin: 0;
  color: var(--ink-soft);
}

.grid {
  display: grid;
  gap: 1rem;
}

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

.stack {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

.row {
  display: flex;
  gap: 0.85rem;
  flex-wrap: wrap;
}

label {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  color: var(--ink-soft);
  font-size: 0.85rem;
  min-width: 210px;
  flex: 1;
}

input,
select,
textarea {
  width: 100%;
  padding: 0.62rem 0.75rem;
  border-radius: var(--radius-md);
  border: 1px solid rgba(16, 32, 54, 0.22);
  background: #fff;
  color: var(--ink);
  font: inherit;
}

input:focus,
select:focus,
textarea:focus {
  outline: 2px solid rgba(43, 119, 255, 0.26);
  border-color: rgba(43, 119, 255, 0.45);
}

.btn,
button {
  font: inherit;
}

.btn {
  border: 0;
  border-radius: 999px;
  text-decoration: none;
  cursor: pointer;
  padding: 0.62rem 1rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: 0.16s ease;
}

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

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

.btn.is-loading {
  position: relative;
  pointer-events: none;
}

.btn.is-loading::before {
  content: "";
  width: 0.85rem;
  height: 0.85rem;
  border-radius: 50%;
  border: 2px solid currentColor;
  border-right-color: transparent;
  display: inline-block;
  margin-right: 0.45rem;
  animation: spin 0.8s linear infinite;
}

.btn-primary {
  background: var(--accent);
  color: #fff;
}

.btn-primary:hover {
  background: var(--accent-dark);
}

.btn-secondary {
  background: #fff;
  color: var(--ink);
  border: 1px solid var(--line);
}

.btn-teal {
  background: var(--teal);
  color: #fff;
}

.btn-success {
  background: var(--ok);
  color: #fff;
}

.btn-success:hover {
  background: #198751;
}

.btn-apple {
  background: #111;
  color: #fff;
  border: 1px solid #111;
}

.btn-apple:hover {
  background: #000;
}

.btn-large {
  padding: 0.85rem 1.5rem;
  font-size: 1.1rem;
  font-weight: 700;
}

/* Auth Views */
.auth-view {
  display: flex;
  flex-direction: column;
  gap: 2rem;
  padding: 2rem 0;
}

.auth-grid {
  display: grid;
  grid-template-columns: 1.2fr 1fr;
  gap: 3rem;
  align-items: center;
}

.auth-branding {
  max-width: 500px;
}

.auth-logo {
  font-size: 4rem;
  color: var(--blue);
  margin-bottom: 0.5rem;
  letter-spacing: -0.04em;
}

.auth-tagline {
  font-size: 1.6rem;
  line-height: 1.2;
  font-weight: 500;
}

.auth-card {
  background: #fff;
  border-radius: var(--radius-xl);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1), 0 20px 40px rgba(0, 0, 0, 0.1);
  padding: 1.5rem;
  width: 100%;
  max-width: 400px;
}

.auth-card-center {
  margin: 0 auto;
}

.auth-card-header {
  text-align: center;
  margin-bottom: 1rem;
}

.auth-card-header h3 {
  font-size: 1.8rem;
  margin: 0;
}

.auth-card-header p {
  color: var(--ink-soft);
  margin: 0.25rem 0 0;
}

.auth-divider {
  border: 0;
  border-top: 1px solid var(--line);
  margin: 1.25rem 0;
}

.auth-link {
  color: var(--blue);
  text-decoration: none;
  font-size: 0.9rem;
  text-align: center;
  display: block;
}

.auth-link:hover {
  text-decoration: underline;
}

.auth-disclaimer {
  font-size: 0.75rem;
  color: var(--ink-soft);
  text-align: center;
  margin: 0.5rem 0;
}

.auth-info-box {
  background: rgba(255, 255, 255, 0.5);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: 1.5rem;
  max-width: 100%;
}

@media (max-width: 900px) {
  .auth-grid {
    grid-template-columns: 1fr;
    text-align: center;
    gap: 2rem;
  }

  .auth-branding {
    max-width: none;
    margin: 0 auto;
  }

  .auth-logo {
    font-size: 3rem;
  }

  .auth-tagline {
    font-size: 1.3rem;
  }

  .auth-card {
    margin: 0 auto;
  }
}

.hidden {
  display: none !important;
}

.pairing-card {
  margin-top: 0.9rem;
  border: 1px solid rgba(28, 157, 149, 0.25);
  border-radius: 14px;
  background: rgba(247, 255, 254, 0.92);
  padding: 0.85rem 0.95rem;
}

.pairing-card h4 {
  margin: 0 0 0.35rem;
}

.pairing-row {
  align-items: flex-end;
  margin-top: 0.55rem;
}

.pairing-code-field {
  flex: 0 1 220px;
  min-width: 180px;
  max-width: 250px;
}

[data-pair-code-input] {
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 700;
  text-align: center;
  font-family: "IBM Plex Mono", monospace;
}

[data-pair-code-status] {
  margin-top: 0.55rem;
}

.pairing-panel .pairing-card {
  margin-top: 0.65rem;
}

.hidden {
  display: none !important;
}

.app-banner {
  display: none;
  margin-bottom: 1rem;
  border-radius: var(--radius-md);
  padding: 0.8rem 1rem;
  border: 1px solid transparent;
  box-shadow: var(--shadow);
  background: #fff;
}

.app-banner.show {
  display: block;
}

.app-banner.error {
  color: #8d1f3a;
  border-color: rgba(209, 46, 84, 0.35);
  background: rgba(209, 46, 84, 0.09);
}

.app-banner.success {
  color: #0f643d;
  border-color: rgba(31, 159, 97, 0.35);
  background: rgba(31, 159, 97, 0.09);
}

.sandbox-banner {
  padding: 0.75rem 1rem;
  margin-bottom: 1rem;
  border-radius: var(--radius-md);
  background: #fff3cd;
  color: #664d03;
  border: 2px solid #ffc107;
  font-weight: 600;
  text-align: center;
  font-size: 0.95rem;
  letter-spacing: 0.02em;
}

.device-list {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.device-item {
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: #fff;
  padding: 0.7rem 0.8rem;
  text-align: left;
  cursor: pointer;
}

.device-item.active {
  border-color: rgba(43, 119, 255, 0.6);
  box-shadow: inset 0 0 0 1px rgba(43, 119, 255, 0.2);
}

.device-title {
  margin: 0;
  font-weight: 700;
}

.device-meta {
  margin: 0.2rem 0 0;
  color: var(--ink-soft);
  font-size: 0.8rem;
}

.metadata-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 0.6rem;
}

.meta-card {
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: 0.58rem 0.7rem;
  background: #fff;
}

.meta-key {
  margin: 0;
  color: var(--ink-soft);
  font-size: 0.75rem;
}

.meta-value {
  margin: 0.18rem 0 0;
  font-weight: 600;
}

.toggle-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 0.5rem;
}

.toggle {
  flex-direction: row;
  align-items: center;
  gap: 0.5rem;
}

.toggle input {
  width: 1rem;
  height: 1rem;
  margin: 0;
}

.playlists {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

.editor-grid {
  margin-top: 0.95rem;
}

.editor-panel {
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.86);
  padding: 0.8rem;
  min-height: 280px;
}

.editor-list {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  margin-top: 0.65rem;
  max-height: var(--editor-list-height);
  overflow-y: auto;
  padding-right: 0.3rem;
}

.editor-row {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  padding: 0.6rem;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 0.45rem;
}

.editor-row.selected {
  border-color: rgba(43, 119, 255, 0.6);
  box-shadow: inset 0 0 0 1px rgba(43, 119, 255, 0.18);
}

.editor-row.is-hidden {
  opacity: 0.65;
}

.editor-row.is-dragging {
  opacity: 0.45;
}

.editor-row.drag-over {
  border-color: rgba(43, 119, 255, 0.72);
  box-shadow: 0 0 0 2px rgba(43, 119, 255, 0.22);
}

.editor-drag-handle {
  width: 40px;
  height: 58px;
  border: 1px solid rgba(16, 32, 54, 0.2);
  border-radius: 10px;
  background: #f7f9ff;
  color: #1d2b44;
  font-size: 0.9rem;
  font-weight: 700;
  cursor: grab;
  line-height: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.18rem;
}

.editor-drag-handle:active {
  cursor: grabbing;
}

.editor-drag-handle .drag-bars {
  font-size: 1.15rem;
}

.editor-drag-handle .drag-arrow {
  font-size: 0.62rem;
}

.editor-main {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.55rem;
  min-width: 0;
}

.editor-name-input {
  min-width: 0;
  width: 100%;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  font-weight: 600;
  padding: 0.5rem 0.65rem;
}

.editor-select-btn {
  flex-shrink: 0;
  border-radius: 10px;
  padding-inline: 0.55rem;
}

.editor-channel-name {
  margin: 0;
  font-weight: 600;
  color: var(--ink);
}

.editor-row-actions {
  display: flex;
  gap: 0.32rem;
  align-items: center;
}

.editor-row-btn {
  min-width: 58px;
  border-radius: 10px;
  padding-inline: 0.55rem;
}

.editor-count {
  font-size: 0.78rem;
  color: var(--ink-soft);
  white-space: nowrap;
}

.playlist-item {
  border: 1px solid var(--line);
  border-radius: 16px;
  background: #fff;
  padding: 1rem;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  flex-wrap: wrap;
  gap: 0.85rem;
}

.pill {
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 700;
  padding: 0.3rem 0.72rem;
  border: 1px solid transparent;
  line-height: 1.2;
}

.pill.type {
  background: rgba(43, 119, 255, 0.12);
  border-color: rgba(43, 119, 255, 0.24);
  color: #1f4fb4;
}

.pill.status-active {
  background: rgba(31, 159, 97, 0.17);
  border-color: rgba(31, 159, 97, 0.26);
  color: #0f643d;
}

.pill.status-disabled {
  background: rgba(209, 46, 84, 0.14);
  border-color: rgba(209, 46, 84, 0.3);
  color: #8d1f3a;
}

.pill.expiry {
  background: rgba(16, 32, 54, 0.08);
  border-color: rgba(16, 32, 54, 0.18);
  color: #20354e;
}

.subhead {
  margin: 0;
}

.helper {
  margin: 0;
  color: var(--ink-soft);
}

.result-box {
  border: 1px dashed rgba(16, 32, 54, 0.25);
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.86);
  padding: 0.75rem 0.85rem;
  color: var(--ink);
  font-family: "IBM Plex Mono", monospace;
  white-space: pre-wrap;
  word-break: break-word;
}

.credit-wallet-card {
  border: 1px solid rgba(43, 119, 255, 0.22);
  border-radius: 16px;
  background: linear-gradient(140deg, rgba(255, 255, 255, 0.98), rgba(233, 242, 255, 0.95));
  padding: 0.95rem 1rem;
  margin-bottom: 0.85rem;
}

.credit-wallet-card .managed-kpi-value {
  margin: 0.2rem 0 0.35rem;
}

.credit-purchase-row {
  align-items: flex-end;
}

.credit-pack-field {
  flex: 0 1 430px;
  min-width: 250px;
  max-width: 430px;
}

.credit-quantity-field {
  flex: 0 1 140px;
  min-width: 120px;
  max-width: 160px;
}

.credit-hero {
  border: 1px solid rgba(43, 119, 255, 0.28);
  border-radius: 16px;
  padding: 1rem;
  margin-bottom: 0.85rem;
  background:
    linear-gradient(145deg, rgba(12, 28, 51, 0.95), rgba(18, 49, 84, 0.9)),
    radial-gradient(circle at 0% 0%, rgba(88, 163, 255, 0.35), transparent 55%);
  color: #f2f7ff;
}

.credit-hero h4 {
  margin: 0.3rem 0 0.35rem;
  font-size: 1.2rem;
  line-height: 1.25;
}

.credit-hero .lead {
  margin: 0;
  color: rgba(232, 241, 255, 0.9);
}

.credit-hero-badge {
  margin: 0;
  display: inline-flex;
  border-radius: 999px;
  border: 1px solid rgba(158, 201, 255, 0.45);
  background: rgba(140, 192, 255, 0.18);
  color: #dcecff;
  padding: 0.25rem 0.7rem;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.08em;
}

.credit-facts {
  margin-top: 0.8rem;
  display: grid;
  gap: 0.65rem;
  grid-template-columns: repeat(auto-fit, minmax(155px, 1fr));
}

.credit-fact {
  border-radius: 12px;
  border: 1px solid rgba(184, 216, 255, 0.32);
  background: rgba(255, 255, 255, 0.08);
  padding: 0.72rem 0.75rem;
}

.credit-fact .meta-key {
  color: rgba(225, 238, 255, 0.86);
}

.credit-fact-value {
  margin: 0.12rem 0 0.22rem;
  font-size: 1.3rem;
  font-weight: 700;
  line-height: 1.1;
  color: #ffffff;
}

.credit-fact .helper {
  color: rgba(233, 243, 255, 0.82);
}

.pro-features-card {
  border: 1px solid rgba(16, 32, 54, 0.14);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.92);
  padding: 0.85rem 0.9rem;
  margin-bottom: 0.85rem;
}

.pro-features-grid {
  margin-top: 0.55rem;
  display: grid;
  gap: 0.6rem;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
}

.pro-feature-item {
  border: 1px solid rgba(16, 32, 54, 0.12);
  border-radius: 12px;
  background: rgba(246, 250, 255, 0.95);
  padding: 0.7rem 0.72rem;
}

.pro-feature-item h5 {
  margin: 0;
  font-size: 0.97rem;
  font-weight: 700;
  color: #1a324e;
}

.pro-feature-item p {
  margin: 0.35rem 0 0;
  font-size: 0.88rem;
  color: var(--ink-soft);
  line-height: 1.42;
}

.credit-ledger-delta {
  font-weight: 700;
}

.credit-ledger-delta.in {
  color: #0f643d;
}

.credit-ledger-delta.out {
  color: #8d1f3a;
}

.paypal-buttons {
  border: 1px solid rgba(16, 32, 54, 0.15);
  border-radius: 14px;
  padding: 0.65rem;
  background: rgba(255, 255, 255, 0.9);
  margin: 0.75rem 0 0.45rem;
}

.paypal-buttons.is-busy {
  opacity: 0.66;
  pointer-events: none;
}

.paypal-status {
  margin: 0 0 0.75rem;
  font-size: 0.92rem;
  color: var(--ink-soft);
}

.paypal-status.loading {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
}

.paypal-status.loading::before {
  content: "";
  width: 0.82rem;
  height: 0.82rem;
  border-radius: 50%;
  border: 2px solid currentColor;
  border-right-color: transparent;
  animation: spin 0.8s linear infinite;
}

.paypal-status.success {
  color: #0f643d;
}

.paypal-status.error {
  color: #8d1f3a;
}

.managed-users-panel {
  background:
    linear-gradient(140deg, rgba(255, 255, 255, 0.94), rgba(241, 247, 255, 0.92)),
    radial-gradient(circle at 100% 0%, rgba(43, 119, 255, 0.12), transparent 42%);
}

.managed-users-header {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: flex-start;
  margin-bottom: 0.25rem;
}

.managed-users-dashboard,
.managed-users-editor {
  margin-top: 1rem;
}

.managed-kpi-grid {
  display: grid;
  gap: 0.85rem;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  margin-bottom: 1rem;
}

.managed-credit-card {
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 0.85rem 0.95rem;
  background: rgba(255, 255, 255, 0.94);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
}

.managed-credit-card .managed-kpi-value {
  margin: 0.2rem 0 0.35rem;
}

.table-wrap {
  overflow-x: auto;
}

.managed-users-table {
  width: 100%;
  min-width: 760px;
  border-collapse: collapse;
  font-size: 0.95rem;
  table-layout: fixed;
}

.managed-users-table thead th {
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 0.7rem;
  color: var(--ink-soft);
  text-align: left;
  padding: 0.65rem 0.75rem;
  border-bottom: 1px solid var(--line);
}

.managed-users-table tbody td {
  padding: 0.7rem 0.75rem;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}

.managed-users-table tbody tr:hover {
  background: rgba(43, 119, 255, 0.045);
}

.managed-col-user {
  width: 23%;
}

.managed-col-status {
  width: 9%;
}

.managed-col-expiry {
  width: 13%;
}

.managed-col-provider {
  width: 29%;
}

.managed-col-type {
  width: 8%;
}

.managed-col-actions {
  width: 18%;
}

.managed-user-cell {
  min-width: 0;
}

.managed-user-primary {
  font-weight: 600;
  color: var(--ink);
}

.managed-user-sub {
  margin-top: 0.15rem;
  font-size: 0.85rem;
  color: var(--ink-soft);
  overflow-wrap: anywhere;
}

.managed-provider-primary {
  font-weight: 600;
  color: var(--ink);
  overflow-wrap: anywhere;
}

.managed-provider-secondary {
  margin-top: 0.15rem;
  font-size: 0.84rem;
  color: var(--ink-soft);
  overflow-wrap: anywhere;
}

#managedKdtvUserResult {
  white-space: normal;
  font-family: "Space Grotesk", sans-serif;
}

.latest-action-card {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

.latest-action-title {
  margin: 0;
  font-size: 1rem;
  font-weight: 700;
  color: #1a324e;
}

.latest-action-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 0.55rem;
}

.latest-action-item {
  margin: 0;
  border: 1px solid rgba(16, 32, 54, 0.12);
  border-radius: 10px;
  background: rgba(245, 249, 255, 0.9);
  padding: 0.48rem 0.58rem;
  display: flex;
  flex-direction: column;
  gap: 0.18rem;
}

.latest-action-item span {
  font-size: 0.72rem;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: #5a6f88;
  font-weight: 600;
}

.latest-action-item strong {
  font-size: 0.9rem;
  color: #1f3047;
  overflow-wrap: anywhere;
}

.managed-kpi-card {
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 0.85rem 0.95rem;
  background: rgba(255, 255, 255, 0.94);
  min-height: 90px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.managed-kpi-value {
  margin: 0.25rem 0 0;
  font-size: 1.55rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.managed-users-toolbar {
  margin-bottom: 0.85rem;
}

.managed-users-form-wrap,
.managed-users-list-wrap {
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.9);
  padding: 0.85rem;
}

.managed-form-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.6rem;
}

.managed-user-item {
  border-left: 4px solid rgba(43, 119, 255, 0.45);
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: flex-start;
  column-gap: 0.95rem;
  row-gap: 0.7rem;
}

.managed-user-main {
  min-width: 0;
}

.managed-user-main .device-title {
  margin: 0 0 0.38rem;
}

.managed-user-meta-line {
  margin: 0;
  color: var(--ink-soft);
  line-height: 1.45;
  font-size: 0.92rem;
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 0.18rem 0.45rem;
}

.managed-user-segment {
  min-width: 0;
}

.managed-user-segment strong {
  color: #314761;
  font-weight: 600;
}

.managed-user-segment-value {
  overflow-wrap: anywhere;
}

.managed-user-separator {
  color: rgba(95, 116, 138, 0.65);
}

.managed-user-actions {
  gap: 0.45rem;
  justify-content: flex-end;
  align-items: center;
  margin-left: auto;
}

.managed-user-actions .btn {
  min-width: 102px;
}

/* ========================================
   SLIDE-OVER PANEL
   ======================================== */

.slideover-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(6, 10, 16, 0.45);
  z-index: 50;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

.slideover-backdrop.open {
  opacity: 1;
  pointer-events: auto;
}

.slideover-panel {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: min(640px, 90vw);
  background: var(--bg-card);
  box-shadow: -8px 0 32px rgba(8, 12, 20, 0.18);
  z-index: 51;
  transform: translateX(100%);
  transition: transform 0.25s ease;
  overflow-y: auto;
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.slideover-panel.open {
  transform: translateX(0);
}

.slideover-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--line);
}

.slideover-header h4 {
  margin: 0;
}

.slideover-close-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: #fff;
  cursor: pointer;
  font-size: 1.2rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: 0.15s ease;
  flex-shrink: 0;
}

.slideover-close-btn:hover {
  background: #f5f5f5;
  border-color: var(--ink-soft);
}

/* ========================================
   WIZARD STEPS
   ======================================== */

.wizard-steps {
  display: flex;
  gap: 0;
}

.wizard-step-indicator {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.6rem 0.75rem;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink-soft);
  font-size: 0.82rem;
  font-weight: 600;
  cursor: default;
  transition: 0.15s ease;
}

.wizard-step-indicator:first-child {
  border-radius: var(--radius-md) 0 0 var(--radius-md);
}

.wizard-step-indicator:last-child {
  border-radius: 0 var(--radius-md) var(--radius-md) 0;
}

.wizard-step-indicator:not(:first-child) {
  border-left: 0;
}

.wizard-step-indicator.active {
  background: rgba(43, 119, 255, 0.08);
  border-color: rgba(43, 119, 255, 0.35);
  color: var(--blue);
}

.wizard-step-indicator.completed {
  background: rgba(31, 159, 97, 0.08);
  border-color: rgba(31, 159, 97, 0.3);
  color: var(--ok);
}

.wizard-step-number {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--line);
  color: var(--ink-soft);
  font-size: 0.72rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.wizard-step-indicator.active .wizard-step-number {
  background: var(--blue);
  color: #fff;
}

.wizard-step-indicator.completed .wizard-step-number {
  background: var(--ok);
  color: #fff;
}

.wizard-step-content {
  display: none;
}

.wizard-step-content.active {
  display: block;
}

.wizard-nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.85rem;
  padding-top: 1rem;
  border-top: 1px solid var(--line);
  margin-top: auto;
}

.wizard-nav-right {
  display: flex;
  gap: 0.65rem;
  margin-left: auto;
  flex-wrap: wrap;
}

/* ========================================
   COLLAPSIBLE USER CARDS
   ======================================== */

.user-card-list {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
}

.user-card {
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: #fff;
  overflow: hidden;
  transition: box-shadow 0.15s ease;
}

.user-card:hover {
  box-shadow: 0 2px 8px rgba(8, 12, 20, 0.06);
}

.user-card-summary {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.7rem 0.85rem;
  cursor: pointer;
  user-select: none;
}

.user-card-identity {
  flex: 1;
  min-width: 0;
}

.user-card-identity .managed-user-primary {
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-card-identity .managed-user-sub {
  font-size: 0.8rem;
  color: var(--ink-soft);
  margin-top: 0.1rem;
}

.user-card-pills {
  display: flex;
  gap: 0.35rem;
  flex-wrap: wrap;
  flex-shrink: 0;
}

.user-card-chevron {
  width: 20px;
  height: 20px;
  transition: transform 0.2s ease;
  color: var(--ink-soft);
  font-size: 0.65rem;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.user-card.expanded .user-card-chevron {
  transform: rotate(180deg);
}

.user-card-details {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.3s ease;
}

.user-card.expanded .user-card-details {
  max-height: 1200px;
}

.user-card-source {
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: rgba(246, 250, 255, 0.95);
  padding: 0.65rem 0.75rem;
  margin-bottom: 0.45rem;
}

.user-card-source:last-child {
  margin-bottom: 0;
}

.user-card-source-title {
  margin: 0 0 0.45rem;
  font-size: 0.88rem;
  display: flex;
  align-items: center;
  gap: 0.45rem;
  flex-wrap: wrap;
}

.user-card-source-title strong {
  color: var(--ink);
}

.user-card-source .user-card-detail-inner {
  border-top: 0;
  padding: 0;
}

.user-card-detail-inner {
  padding: 0.75rem 0.85rem;
  border-top: 1px solid var(--line);
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 0.55rem;
}

.user-card-actions {
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
  padding: 0 0.85rem 0.75rem;
}

.user-card-actions .btn {
  font-size: 0.82rem;
  padding: 0.45rem 0.75rem;
}

/* ========================================
   ONBOARDING BANNER
   ======================================== */

.onboarding-banner {
  border: 2px dashed rgba(43, 119, 255, 0.3);
  border-radius: var(--radius-xl);
  background: linear-gradient(145deg, rgba(236, 244, 255, 0.95), rgba(255, 255, 255, 0.98));
  padding: 1.75rem 1.5rem;
  text-align: center;
  margin-bottom: 1.25rem;
}

.onboarding-banner h3 {
  margin: 0 0 0.4rem;
  font-size: 1.25rem;
}

.onboarding-banner > p {
  color: var(--ink-soft);
  margin: 0 0 1.25rem;
  max-width: 520px;
  margin-left: auto;
  margin-right: auto;
  font-size: 0.92rem;
  line-height: 1.45;
}

.onboarding-steps {
  display: flex;
  gap: 0.85rem;
  justify-content: center;
  flex-wrap: wrap;
  margin-bottom: 1.5rem;
}

.onboarding-step {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.4rem;
  padding: 0.85rem 1rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--line);
  background: #fff;
  min-width: 145px;
}

.onboarding-step-number {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--blue);
  color: #fff;
  font-weight: 700;
  font-size: 0.85rem;
  display: flex;
  align-items: center;
  justify-content: center;
}

.onboarding-step strong {
  font-size: 0.9rem;
}

.onboarding-step .helper {
  margin: 0;
  font-size: 0.78rem;
}

/* ========================================
   TOPBAR CREDIT BADGE
   ======================================== */

.topbar-credit-badge {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.4rem 0.85rem;
  border-radius: 999px;
  border: 1px solid rgba(43, 119, 255, 0.22);
  background: linear-gradient(140deg, rgba(255, 255, 255, 0.98), rgba(233, 242, 255, 0.95));
  cursor: pointer;
  white-space: nowrap;
  transition: 0.15s ease;
  flex-shrink: 0;
}

.topbar-credit-badge:hover {
  border-color: rgba(43, 119, 255, 0.45);
  box-shadow: 0 2px 8px rgba(43, 119, 255, 0.12);
}

.topbar-credit-value {
  font-weight: 700;
  font-size: 1rem;
  color: var(--ink);
}

.topbar-credit-label {
  font-size: 0.78rem;
  color: var(--ink-soft);
}

/* ========================================
   REVIEW / SUMMARY CARDS
   ======================================== */

.review-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 0.55rem;
}

.review-item {
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: rgba(246, 250, 255, 0.95);
  padding: 0.55rem 0.7rem;
}

.review-item .meta-key {
  margin-bottom: 0.1rem;
}

.review-item .meta-value {
  font-weight: 600;
  font-size: 0.92rem;
  color: var(--ink);
  word-break: break-word;
}

/* ========================================
   SECTION DESCRIPTION HERO
   ======================================== */

.section-intro {
  margin-bottom: 1.25rem;
  padding: 1.25rem;
  border-radius: var(--radius-xl);
  background: linear-gradient(145deg, rgba(248, 250, 255, 0.98), rgba(236, 244, 255, 0.5));
  border: 1px solid var(--line);
}

.section-intro h3 {
  margin: 0 0 0.35rem;
  font-size: 1.15rem;
}

.section-intro .lead {
  margin: 0;
  font-size: 0.9rem;
  line-height: 1.5;
  color: var(--ink-soft);
}

/* ========================================
   PLAYLIST TYPE CARDS (dashboard)
   ======================================== */

.playlist-type-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 0.5rem;
  margin-bottom: 0.85rem;
}

.playlist-type-card {
  border: 2px solid var(--line);
  border-radius: var(--radius-md);
  padding: 0.65rem 0.5rem;
  text-align: center;
  cursor: pointer;
  transition: 0.15s ease;
  background: #fff;
}

.playlist-type-card:hover {
  border-color: rgba(43, 119, 255, 0.3);
}

.playlist-type-card.selected {
  border-color: var(--blue);
  background: rgba(43, 119, 255, 0.05);
}

.playlist-type-card strong {
  display: block;
  font-size: 0.9rem;
  margin-bottom: 0.15rem;
}

.playlist-type-card span {
  font-size: 0.75rem;
  color: var(--ink-soft);
}

/* ========================================
   EMPTY STATE
   ======================================== */

.empty-state {
  text-align: center;
  padding: 2rem 1rem;
  color: var(--ink-soft);
}

.empty-state-icon {
  font-size: 2.5rem;
  margin-bottom: 0.5rem;
  opacity: 0.4;
}

.empty-state h4 {
  margin: 0 0 0.35rem;
  color: var(--ink);
  font-size: 1rem;
}

.empty-state p {
  margin: 0 0 1rem;
  font-size: 0.88rem;
  max-width: 380px;
  margin-left: auto;
  margin-right: auto;
}

/* ========================================
   RESPONSIVE: NEW COMPONENTS
   ======================================== */

@media (max-width: 1080px) {
  :root {
    --editor-list-height: clamp(500px, 64vh, 760px);
  }

  .grid.two-col {
    grid-template-columns: 1fr;
  }

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

  .managed-user-item {
    grid-template-columns: 1fr;
  }

  .managed-user-actions {
    justify-content: flex-start;
    margin-left: 0;
  }

  .managed-users-table {
    min-width: 920px;
  }

  .user-card-summary {
    flex-wrap: wrap;
  }

  .user-card-detail-inner {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .wizard-step-indicator {
    font-size: 0.75rem;
    padding: 0.5rem 0.55rem;
  }
}

@media (max-width: 620px) {
  :root {
    --editor-list-height: clamp(360px, 56vh, 560px);
  }

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

  .managed-credit-card {
    flex-direction: column;
    align-items: flex-start;
  }

  .credit-pack-field,
  .credit-quantity-field {
    min-width: 0;
    max-width: none;
    flex: 1 1 100%;
  }

  .pro-features-grid {
    grid-template-columns: 1fr;
  }

  .editor-row {
    grid-template-columns: 1fr;
    align-items: flex-start;
  }

  .editor-row-actions {
    justify-content: flex-start;
    flex-wrap: wrap;
  }

  .user-card-detail-inner {
    grid-template-columns: 1fr;
  }

  .onboarding-steps {
    flex-direction: column;
    align-items: center;
  }

  .wizard-steps {
    flex-direction: column;
  }

  .wizard-step-indicator:first-child {
    border-radius: var(--radius-md) var(--radius-md) 0 0;
  }

  .wizard-step-indicator:last-child {
    border-radius: 0 0 var(--radius-md) var(--radius-md);
  }

  .wizard-step-indicator:not(:first-child) {
    border-left: 1px solid var(--line);
    border-top: 0;
  }

  .wizard-nav {
    flex-direction: column;
  }

  .wizard-nav-right {
    margin-left: 0;
    width: 100%;
  }

  .review-grid {
    grid-template-columns: 1fr;
  }
}

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

  .menu-btn {
    display: inline-flex;
  }

  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: min(300px, 82vw);
    z-index: 40;
    transform: translateX(-100%);
    transition: transform 0.2s ease;
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .sidebar-overlay {
    position: fixed;
    inset: 0;
    background: rgba(6, 10, 16, 0.45);
    z-index: 30;
  }

  .sidebar-overlay.show {
    display: block;
  }

  .content {
    padding: 1rem;
  }
}

@media (max-width: 480px) {
  .managed-kpi-grid {
    grid-template-columns: 1fr;
  }
}

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