/* Lots 4 / 4.2: explicitly opted-in admin tabs and their two owned portals.
   No typography/color inheritance on #section-admin or unrelated applications.
   Specialized Assistant / Providers details live in their dedicated sheets. */

html[data-ps-theme="studio"][data-ps-window="hub"][data-ps-screen="app"]:has(#appContainer > main > #section-admin:not(.hidden)),
:where(html[data-ps-theme="studio"][data-ps-window="hub"][data-ps-screen="app"]) body:has(#appContainer > main > #section-admin:not(.hidden)) {
  background: var(--ps-bg);
}

:where(html[data-ps-theme="studio"][data-ps-window="hub"][data-ps-screen="app"]) #section-admin {
  background: var(--ps-bg);
  border-color: var(--ps-line);
  border-radius: 9px;
  box-shadow: var(--ps-shell-reflection), 0 8px 24px #0003;
}

:where(html[data-ps-theme="studio"][data-ps-window="hub"][data-ps-screen="app"]) #section-admin:has(> [data-ps-admin-core]:not(.hidden)) {
  min-width: 0;
  max-width: 100%;
  container-type: inline-size;
}

:where(html[data-ps-theme="studio"][data-ps-window="hub"][data-ps-screen="app"]) #section-admin > h2 {
  color: var(--ps-ink);
  font-family: var(--ps-font-ui);
  font-weight: 600;
  overflow-wrap: anywhere;
}

:where(html[data-ps-theme="studio"][data-ps-window="hub"][data-ps-screen="app"]) #adminInfoText {
  color: var(--ps-muted);
  font-family: var(--ps-font-ui);
  overflow-wrap: anywhere;
}

:where(html[data-ps-theme="studio"][data-ps-window="hub"][data-ps-screen="app"]) #section-admin > div:has(> #adminTabBtn_billing) > button {
  min-width: 0;
  max-width: 100%;
  border-color: var(--ps-line);
  border-radius: 6px;
  background: var(--ps-surface-soft);
  color: var(--ps-muted);
  font-family: var(--ps-font-ui);
  overflow-wrap: anywhere;
}

:where(html[data-ps-theme="studio"][data-ps-window="hub"][data-ps-screen="app"]) #section-admin > div:has(> #adminTabBtn_billing) > button:hover:not(:disabled) {
  background: var(--ps-bg-soft);
  color: var(--ps-ink);
  border-color: var(--ps-line-strong);
  box-shadow: none;
}

:where(html[data-ps-theme="studio"][data-ps-window="hub"][data-ps-screen="app"]) #section-admin > div:has(> #adminTabBtn_billing) > button.btn-primary {
  background: var(--ps-surface-solid);
  color: var(--ps-gold-light);
  border-color: var(--ps-gold);
  box-shadow: var(--ps-shell-reflection);
}

:where(html[data-ps-theme="studio"][data-ps-window="hub"][data-ps-screen="app"]) #section-admin > [data-ps-admin-core] {
  --ps-admin-card: var(--ps-bg-soft);
  --ps-admin-line: var(--ps-line);
  --ps-admin-track: var(--ps-line);
  --ps-admin-error: #fda4af;
  min-width: 0;
  max-width: 100%;
  color: var(--ps-text);
  font-family: var(--ps-font-ui);
  overflow-wrap: anywhere;
  overflow-anchor: none;
}

:where(html[data-ps-theme="studio"][data-ps-window="hub"][data-ps-screen="app"]) #section-admin > [data-ps-admin-core] :is(.admin-panel, .admin-tab-panel, .admin-subcard, .admin-preview-card) {
  min-width: 0;
  max-width: 100%;
  border-color: var(--ps-line);
  border-radius: 9px;
  background: var(--ps-surface-soft);
  box-shadow: var(--ps-shell-reflection);
}

:where(html[data-ps-theme="studio"][data-ps-window="hub"][data-ps-screen="app"]) #section-admin > [data-ps-admin-core] :is(.admin-panel-header, .admin-tab-panel-header) {
  border-color: var(--ps-line);
  background: var(--ps-surface-solid);
}

:where(html[data-ps-theme="studio"][data-ps-window="hub"][data-ps-screen="app"]) #section-admin > [data-ps-admin-core] :is(.admin-panel-title, .admin-tab-panel-title, .admin-subcard-heading h3) {
  color: var(--ps-ink);
  font-weight: 600;
}

:where(html[data-ps-theme="studio"][data-ps-window="hub"][data-ps-screen="app"]) :is(#section-admin > [data-ps-admin-core], #adminStudioEditModal, #adminCloneDeleteModal) :is(.muted, .admin-subcard-title, .admin-modal-section-title, label, .admin-studio-credits-cell strong, .admin-studio-credits-cell em) {
  color: var(--ps-muted);
}

:where(html[data-ps-theme="studio"][data-ps-window="hub"][data-ps-screen="app"]) #section-admin > [data-ps-admin-core] :is(.admin-panel-icon, .admin-tab-panel-icon, .admin-subcard-icon, .admin-preview-icon) {
  background: var(--ps-bg-soft);
  color: var(--ps-gold-light);
  box-shadow: none;
}

:where(html[data-ps-theme="studio"][data-ps-window="hub"][data-ps-screen="app"]) #section-admin > [data-ps-admin-core] .admin-subcard:hover {
  transform: none;
  box-shadow: var(--ps-shell-reflection), 0 4px 12px #0002;
}

:where(html[data-ps-theme="studio"][data-ps-window="hub"][data-ps-screen="app"]) :is(#section-admin > [data-ps-admin-core], #adminStudioEditModal, #adminCloneDeleteModal) :is(input, select, textarea) {
  min-width: 0;
  max-width: 100%;
  border-color: var(--ps-line-strong);
  background: var(--ps-bg-soft);
  color: var(--ps-text);
  font-family: var(--ps-font-ui);
  color-scheme: dark;
}

:where(html[data-ps-theme="studio"][data-ps-window="hub"][data-ps-screen="app"]) :is(#section-admin > [data-ps-admin-core], #adminStudioEditModal, #adminCloneDeleteModal) :is(input, textarea)::placeholder {
  color: var(--ps-muted);
  opacity: .75;
}

:where(html[data-ps-theme="studio"][data-ps-window="hub"][data-ps-screen="app"]) :is(#section-admin > [data-ps-admin-core], #adminStudioEditModal, #adminCloneDeleteModal) input[type="checkbox"] {
  accent-color: var(--ps-gold);
}

:where(html[data-ps-theme="studio"][data-ps-window="hub"][data-ps-screen="app"]) #section-admin > [data-ps-admin-core] .admin-field-studio {
  /* Historical .admin-field-studio sets min-width with !important. */
  min-width: 0 !important;
}

:where(html[data-ps-theme="studio"][data-ps-window="hub"][data-ps-screen="app"]) :is(#section-admin > [data-ps-admin-core], #adminStudioEditModal, #adminCloneDeleteModal) button {
  max-width: 100%;
  font-family: var(--ps-font-ui);
  border-radius: 6px;
  overflow-wrap: anywhere;
}

:where(html[data-ps-theme="studio"][data-ps-window="hub"][data-ps-screen="app"]) :is(#section-admin > [data-ps-admin-core], #adminStudioEditModal, #adminCloneDeleteModal) button:not(.btn-danger) {
  border-color: var(--ps-line-strong);
  background: var(--ps-surface-soft);
  color: var(--ps-text);
  box-shadow: var(--ps-shell-reflection);
}

:where(html[data-ps-theme="studio"][data-ps-window="hub"][data-ps-screen="app"]) :is(#section-admin > [data-ps-admin-core], #adminStudioEditModal, #adminCloneDeleteModal) button:not(.btn-danger):hover:not(:disabled) {
  border-color: var(--ps-gold);
  background: var(--ps-bg-soft);
  color: var(--ps-ink);
  box-shadow: var(--ps-shell-reflection);
}

:where(html[data-ps-theme="studio"][data-ps-window="hub"][data-ps-screen="app"]) :is(#section-admin > [data-ps-admin-core], #adminStudioEditModal, #adminCloneDeleteModal) button.btn-primary {
  border-color: var(--ps-button-border);
  background: var(--ps-button-bg);
  color: var(--ps-button-text);
  box-shadow: var(--ps-button-shadow);
}

:where(html[data-ps-theme="studio"][data-ps-window="hub"][data-ps-screen="app"]) :is(#section-admin > [data-ps-admin-core], #adminStudioEditModal, #adminCloneDeleteModal) button.btn-primary:hover:not(:disabled) {
  background: var(--ps-button-hover);
}

:where(html[data-ps-theme="studio"][data-ps-window="hub"][data-ps-screen="app"]) :is(#section-admin > [data-ps-admin-core], #adminStudioEditModal, #adminCloneDeleteModal) button:disabled {
  opacity: .55;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

:where(html[data-ps-theme="studio"][data-ps-window="hub"][data-ps-screen="app"]) :is(#section-admin > [data-ps-admin-core], #adminStudioEditModal, #adminCloneDeleteModal) button.btn-primary:disabled {
  border-color: var(--ps-line);
  background: var(--ps-surface-solid);
  color: var(--ps-muted);
}

:where(html[data-ps-theme="studio"][data-ps-window="hub"][data-ps-screen="app"]) :is(#section-admin > [data-ps-admin-core], #adminStudioEditModal, #adminCloneDeleteModal) :is(button, input, select, textarea):focus-visible,
:where(html[data-ps-theme="studio"][data-ps-window="hub"][data-ps-screen="app"]) #section-admin > div:has(> #adminTabBtn_billing) > button:focus-visible {
  outline: 2px solid var(--ps-focus);
  outline-offset: 2px;
}

:where(html[data-ps-theme="studio"][data-ps-window="hub"][data-ps-screen="app"]) #section-admin > [data-ps-admin-core] :is(#adminBillingUsageList, #adminBillingInvoicesList, #adminInvoiceProjectsList, #adminCreditUsageList, #adminStudios, #adminUsersList, #adminPermPanel, #adminPresenceOnlineUsers, #adminPresenceOfflineUsers, #adminUploads, .admin-subcard:has(> table)) {
  min-width: 0;
  max-width: 100%;
  overflow-x: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--ps-line-strong) var(--ps-surface-soft);
}

:where(html[data-ps-theme="studio"][data-ps-window="hub"][data-ps-screen="app"]) #section-admin > [data-ps-admin-core] table {
  color: var(--ps-text);
  font-family: var(--ps-font-ui);
}

/* One paint rule for the actual Lot 4.1 interface surfaces. Historical inline
   backgrounds stay available to Original, including already-rendered legacy
   nodes. The single priority is needed to outrank those inline declarations.
   Job selectors cover active/history cards, not their progress/drawing children. */
:where(html[data-ps-theme="studio"][data-ps-window="hub"][data-ps-screen="app"]) #section-admin :is(
  #adminBillingSummary > div,
  #adminCreditUsagePreview > div,
  #adminInvoiceCreatePreview > div,
  #adminPresenceSummary > div,
  #adminUploadsSummary > div,
  #adminJobsList > div,
  #adminJobsList > details[data-admin-jobs-history] > div > div,
  #adminTab_billing table,
  #adminTab_presence table,
  #adminTab_uploads table
) {
  background: var(--ps-bg-soft) !important;
}

:where(html[data-ps-theme="studio"][data-ps-window="hub"][data-ps-screen="app"]) #section-admin > [data-ps-admin-core] th {
  background: var(--ps-surface-solid);
  color: var(--ps-muted);
  border-color: var(--ps-line);
}

:where(html[data-ps-theme="studio"][data-ps-window="hub"][data-ps-screen="app"]) #section-admin > [data-ps-admin-core] td {
  color: var(--ps-text);
  border-color: var(--ps-line);
}

:where(html[data-ps-theme="studio"][data-ps-window="hub"][data-ps-screen="app"]) #section-admin > [data-ps-admin-core] :is(.admin-studio-credits-cell, .admin-studio-credits-cell .studio-credits-main, .admin-studio-credits-cell .studio-credits-title) {
  color: var(--ps-text);
}

:where(html[data-ps-theme="studio"][data-ps-window="hub"][data-ps-screen="app"]) #section-admin > [data-ps-admin-core] .status-pill {
  border-radius: 6px;
}

/* The historical --running alias has no rule. In Studio only, use the existing
   --in-progress semantic palette; status values and Original remain unchanged. */
:where(html[data-ps-theme="studio"][data-ps-window="hub"][data-ps-screen="app"]) #section-admin > [data-ps-admin-core] .status-pill--running {
  background: #fef3c7;
  color: #92400e;
  border-color: #fed7aa;
}

/* Preserve credit-family hue in existing grouping borders, and status palettes. */

:where(html[data-ps-theme="studio"][data-ps-window="hub"][data-ps-screen="app"]) #section-admin > [data-ps-admin-core] #adminCreditUsageList [data-billing-family] {
  background: var(--ps-surface-solid);
  border-color: var(--billing-family-border);
}

:where(html[data-ps-theme="studio"][data-ps-window="hub"][data-ps-screen="app"]) #section-admin > [data-ps-admin-core] #adminCreditUsageList [data-billing-family] > td {
  background: var(--ps-surface-soft);
  border-color: var(--billing-family-border);
}

:where(html[data-ps-theme="studio"][data-ps-window="hub"][data-ps-screen="app"]) #section-admin > [data-ps-admin-core] #adminCreditUsageList .billing-child-row > td:first-child {
  border-left-color: var(--billing-family-border);
}

:where(html[data-ps-theme="studio"][data-ps-window="hub"][data-ps-screen="app"]) #section-admin > [data-ps-admin-core] :is(.admin-preview-title, .admin-preview-price, .admin-preview-feature, .admin-preview-feature span) {
  color: var(--ps-ink);
}

:where(html[data-ps-theme="studio"][data-ps-window="hub"][data-ps-screen="app"]) #section-admin > [data-ps-admin-core] :is(.admin-preview-subtitle, .admin-preview-price span, .admin-preview-feature small) {
  color: var(--ps-muted);
}

:where(html[data-ps-theme="studio"][data-ps-window="hub"][data-ps-screen="app"]) #section-admin > [data-ps-admin-core] .admin-preview-line {
  background: var(--ps-line);
}

:where(html[data-ps-theme="studio"][data-ps-window="hub"][data-ps-screen="app"]) #section-admin > [data-ps-admin-core] .admin-preview-feature {
  border-color: var(--ps-line);
}

:where(html[data-ps-theme="studio"][data-ps-window="hub"][data-ps-screen="app"]) #adminStudioEditModal {
  color: var(--ps-text);
  font-family: var(--ps-font-ui);
}

:where(html[data-ps-theme="studio"][data-ps-window="hub"][data-ps-screen="app"]) #adminStudioEditModal .admin-modal-backdrop {
  background: #0009;
}

:where(html[data-ps-theme="studio"][data-ps-window="hub"][data-ps-screen="app"]) #adminStudioEditModal .admin-modal-card {
  background: var(--ps-surface-soft);
  border-color: var(--ps-line-strong);
  border-radius: 9px;
  box-shadow: var(--ps-shell-reflection), 0 16px 48px #0006;
}

:where(html[data-ps-theme="studio"][data-ps-window="hub"][data-ps-screen="app"]) #adminStudioEditModal .admin-modal-header {
  background: var(--ps-surface-solid);
  border-color: var(--ps-line);
}

:where(html[data-ps-theme="studio"][data-ps-window="hub"][data-ps-screen="app"]) #adminStudioEditModal .admin-modal-header h3 {
  color: var(--ps-ink);
}

:where(html[data-ps-theme="studio"][data-ps-window="hub"][data-ps-screen="app"]) #adminStudioEditModal :is(.admin-modal-section-title, .admin-modal-actions) {
  border-color: var(--ps-line);
}

@container (max-width: 760px) {
  :where(html[data-ps-theme="studio"][data-ps-window="hub"][data-ps-screen="app"]) #section-admin > [data-ps-admin-core] :is(#adminUploads > table, #adminPresenceOnlineUsers > table, #adminPresenceOfflineUsers > table) {
    min-width: 900px;
  }
  
  :where(html[data-ps-theme="studio"][data-ps-window="hub"][data-ps-screen="app"]) #section-admin > [data-ps-admin-core] .admin-compact-table {
    min-width: 500px;
  }
}

@container (max-width: 520px) {
  :where(html[data-ps-theme="studio"][data-ps-window="hub"][data-ps-screen="app"]) #section-admin > [data-ps-admin-core] {
    --ps-admin-sender-columns: minmax(0, 1fr);
  }
  
  :where(html[data-ps-theme="studio"][data-ps-window="hub"][data-ps-screen="app"]) #section-admin > [data-ps-admin-core] :is(.admin-panel-body, .admin-tab-panel-body, .admin-subcard) {
    padding: 8px;
  }
  
  :where(html[data-ps-theme="studio"][data-ps-window="hub"][data-ps-screen="app"]) #section-admin > [data-ps-admin-core] .admin-preview-card-top {
    grid-template-columns: minmax(0, 1fr);
  }
  
  :where(html[data-ps-theme="studio"][data-ps-window="hub"][data-ps-screen="app"]) #section-admin > [data-ps-admin-core] .admin-preview-price {
    text-align: left;
  }
  
  :where(html[data-ps-theme="studio"][data-ps-window="hub"][data-ps-screen="app"]) #section-admin > [data-ps-admin-core] .ps-admin-job-card > div:first-child {
    flex-wrap: wrap;
  }
}

@container (max-width: 260px) {
  :where(html[data-ps-theme="studio"][data-ps-window="hub"][data-ps-screen="app"]) #section-admin > [data-ps-admin-core] :is(.admin-panel-body, .admin-tab-panel-body, .admin-subcard) {
    padding: 2px;
  }
}

@media (max-width: 760px) {
  :where(html[data-ps-theme="studio"][data-ps-window="hub"][data-ps-screen="app"]) #section-admin:has(> [data-ps-admin-core]:not(.hidden)) {
    padding: 8px;
  }
}

@media (prefers-reduced-motion: reduce) {
  :where(html[data-ps-theme="studio"][data-ps-window="hub"][data-ps-screen="app"]) :is(#section-admin > [data-ps-admin-core], #adminStudioEditModal, #adminCloneDeleteModal) :is(button, .admin-subcard) {
    transition: none;
  }
}
