/* Management UI. Keep authored page blocks and their previews independent. */
:is(.app-shell, .auth-wrapper) {
  --color-text-soft: #596779;
  --color-text-muted: #526174;
  background: #f5f7fa;
  font-weight: 400;
}
.app-shell::before { display: none; }
.app-shell > main.container-fluid {
  max-width: 1440px;
  width: 100%;
  padding: 0 clamp(1rem, 3vw, 2.5rem) 3rem !important;
}
.app-shell.builder-shell > main { max-width: 1800px; }
.app-shell > main:focus { outline: none; }
.skip-link {
  position: fixed;
  top: .75rem;
  left: .75rem;
  z-index: 2000;
  padding: .75rem 1rem;
  background: #fff;
  border: 2px solid #2563eb;
  border-radius: 8px;
  transform: translateY(-160%);
}
.skip-link:focus { transform: translateY(0); }
.studio-header { background: #fff; border-bottom: 1px solid #dfe5ed; }
.studio-header-inner { max-width: 1440px; margin: auto; padding: 0 clamp(1rem, 3vw, 2.5rem); }
.studio-header-top { display: flex; align-items: center; justify-content: space-between; gap: 1rem; min-height: 80px; }
.studio-brand { display: inline-flex; align-items: center; gap: .8rem; color: #18283e; font-size: 1.1rem; letter-spacing: -.025em; }
.studio-brand strong { font-weight: 700; }
.studio-brand-mark { width: 38px; height: 38px; display: grid; place-items: center; background: #1d4ed8; color: #fff; border-radius: 10px; flex-shrink: 0; }
.studio-account { display: flex; align-items: center; gap: 1rem; }
.studio-account-name { font-size: .875rem; color: #526174; max-width: 180px; overflow: hidden; text-overflow: ellipsis; }
.studio-navigation { display: flex; gap: 1.5rem; overflow-x: auto; scrollbar-width: thin; }
.studio-nav-link { display: inline-flex; align-items: center; flex-shrink: 0; min-height: 48px; border-bottom: 3px solid transparent; color: #526174; font-size: .9rem; font-weight: 600; padding: .5rem .15rem; }
.studio-nav-link:hover { color: #1d4ed8; border-bottom-color: #b9cef9; }
.studio-nav-link.active { color: #1d4ed8; border-bottom-color: #2563eb; }
.studio-breadcrumbs { width: 100%; max-width: 1440px; margin: 0 auto; padding: 1.25rem clamp(1rem, 3vw, 2.5rem); font-size: .8rem; }
.studio-breadcrumbs .breadcrumb { row-gap: .35rem; }
.studio-breadcrumbs .breadcrumb-item { overflow-wrap: anywhere; color: #596779; }
.studio-breadcrumbs a { color: #526174; }
.studio-breadcrumbs a:hover { color: #1d4ed8; text-decoration: underline; }

/* :not() keeps editor previews faithful to the published page. */
:is(.app-shell, .auth-wrapper) :is(.surface-card, .card, .modal-content):not(:where(.preview-canvas *, .mwp-preview-wrap *)) {
  border: 1px solid #dfe5ed !important;
  border-radius: 12px;
  background: #fff;
  box-shadow: 0 2px 4px rgb(15 23 42 / 3%);
  transform: none;
}
.app-shell :is(.admin-hero-card, .admin-site-card)::before,
.app-shell :is(.admin-hero-card, .admin-site-card)::after,
.builder-shell > main > section.surface-card:first-child::before,
.builder-shell > main > section.surface-card:first-child::after { display: none; }
.app-shell :is(.surface-card, .admin-data-card).p-lg-5 { padding: clamp(1.25rem, 2.5vw, 2rem) !important; }
.app-shell .section-title { font-size: clamp(1.6rem, 2.5vw, 2rem); line-height: 1.25; font-weight: 700; letter-spacing: -.035em; overflow-wrap: anywhere; }
.app-shell .section-subtitle { max-width: 760px; color: #526174; font-size: .95rem; line-height: 1.65; }
.app-shell :is(.tag-neutral, .tag-muted) { border-radius: 6px; background: #edf2f8; color: #526174; font-size: .75rem; letter-spacing: 0; flex-wrap: wrap; overflow-wrap: anywhere; }
.app-shell .admin-site-card { display: flex; flex-direction: column; }
.app-shell .admin-site-card > :last-child { margin-top: auto; }
.app-shell .admin-site-card h2 { overflow-wrap: anywhere; }
.app-shell .admin-site-card:hover { border-color: #a9bfdf !important; box-shadow: 0 4px 12px rgb(15 23 42 / 5%); }
.app-shell .site-icon { display: grid; place-items: center; width: 40px; height: 40px; border-radius: 10px; background: #eff4ff; color: #1d4ed8; margin-bottom: 1.25rem; }
:is(.app-shell, .auth-wrapper) .btn:not(:where(.preview-canvas *, .mwp-preview-wrap *)) {
  border-radius: 8px !important;
  min-height: 42px;
  padding: .6rem 1rem;
  font-size: .875rem;
  font-weight: 600;
  letter-spacing: 0;
  box-shadow: none;
  transform: none;
}
.app-shell .btn-sm:not(:where(.preview-canvas *, .mwp-preview-wrap *)) { min-height: 36px; padding: .4rem .75rem; font-size: .8rem; }
.app-shell .btn-outline-secondary:not(:where(.preview-canvas *, .mwp-preview-wrap *)) { background: #fff; border-color: #cbd5e1; color: #40516a; }
.app-shell .btn-outline-secondary:hover:not(:where(.preview-canvas *, .mwp-preview-wrap *)) { background: #f1f5f9; border-color: #94a3b8; }
.app-shell .btn-success:not(:where(.preview-canvas *, .mwp-preview-wrap *)) { background: #167044; border-color: #167044; color: #fff; }
.app-shell .btn-success:hover:not(:where(.preview-canvas *, .mwp-preview-wrap *)) { background: #115a36; }
:is(.app-shell, .auth-wrapper) :is(.form-control, .form-select, .input-group-text):not(:where(.preview-canvas *, .mwp-preview-wrap *)) { border-radius: 8px; font-size: .9rem; min-height: 42px; }
:is(.app-shell, .auth-wrapper) :is(.form-control, .form-select):not(:where(.preview-canvas *, .mwp-preview-wrap *)) { background-color: #fff; border-color: #c2cddd; color: #18283e; }
:is(.app-shell, .auth-wrapper) :is(.form-control, .form-select):focus { border-color: #2563eb; box-shadow: 0 0 0 3px rgb(37 99 235 / 14%); }
.app-shell .form-label { font-size: .85rem; margin-bottom: .4rem; }
.app-shell .form-text { color: #596779; font-size: .8rem; }
.app-shell .card-header:not(:where(.preview-canvas *, .mwp-preview-wrap *)) { background: #f8fafc; border-bottom: 1px solid #e2e8f0; }
.app-shell .table-responsive { padding: 0; border: 1px solid #e2e8f0; border-radius: 8px; background: #fff; box-shadow: none; }
.app-shell table.table { border-radius: 0; }
.app-shell table.table th { background: #f8fafc; text-transform: none; letter-spacing: 0; font-size: .8rem; color: #526174; white-space: nowrap; }
.app-shell table.table :is(th, td) { padding: .9rem 1rem; border-bottom-color: #e8edf3; }
.app-shell table.table tbody tr:hover { transform: none; background: #f8fafc; }
.app-shell .table-actions { display: flex; flex-wrap: wrap; gap: .35rem; }
.app-shell .dataTables_wrapper { font-size: .875rem; }
.app-shell .dataTables_wrapper :is(.dataTables_filter input, .dataTables_length select) { border-radius: 8px; box-shadow: none; }
.app-shell .dataTables_wrapper .dataTables_filter input { min-width: 180px; }
.app-shell .dataTables_empty { padding: 2.5rem 1rem; color: #596779; }
.app-shell .filter-bar { border: 1px solid #e2e8f0; background: #f8fafc; }
.app-shell .stat-card:hover { transform: none; }
.app-shell .stat-label { text-transform: none; letter-spacing: 0; color: #596779; }
.app-shell .bar-fill { background: #2563eb; }
.builder-shell #autosave-status:empty { display: none; }
.builder-shell .builder-sidebar > .card:first-child { margin-top: 0 !important; }
.builder-shell #inspector-modal .modal-dialog { width: calc(100% - 2rem) !important; max-width: 1400px !important; }
.builder-shell #inspector-modal .inspector-modal-header { background: #f8fafc; padding: 1rem; }
.builder-shell #inspector-modal .inspector-modal-body { background: #f5f7fa; }
.app-shell .mwp-modal-dialog { max-width: calc(100vw - 2rem); }

.auth-wrapper { display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 2rem 1rem; min-height: 100svh; }
.auth-brand { display: flex; align-items: center; gap: .65rem; margin-bottom: 2rem; font-weight: 600; color: #18283e; }
.auth-wrapper .auth-card { width: min(460px, 100%); box-shadow: 0 12px 40px rgb(15 23 42 / 6%); }
.auth-card .card-header { padding: 2rem 2rem 1.5rem; }
.auth-card .card-body { padding: 0 2rem 2rem; }
.auth-card h1 { font-size: 1.75rem; letter-spacing: -.04em; }
.auth-card .form-label { font-size: .9rem; }
.auth-password { position: relative; }
.auth-password .form-control { padding-right: 4.5rem; }
.auth-password .password-toggle { position: absolute; inset: 1px 1px 1px auto; border: 0; border-radius: 0 8px 8px 0; background: transparent; color: #1d4ed8; padding: 0 1rem; font-size: .8rem; font-weight: 600; }
.auth-wrapper > p { max-width: 400px; }
:is(.app-shell, .auth-wrapper) :is(a, button, input, select, textarea, summary, [tabindex]):focus-visible { outline: 3px solid #2563eb; outline-offset: 3px; }
@media (max-width: 767.98px) {
  .studio-header-top { min-height: 72px; }
  .studio-brand { font-size: .95rem; gap: .6rem; }
  .studio-brand > span:last-child { display: flex; flex-direction: column; line-height: 1.3; }
  .studio-account-name { display: none; }
  .studio-navigation { gap: 1.1rem; }
  .studio-nav-link { min-height: 46px; font-size: .85rem; }
  .studio-breadcrumbs { padding-block: 1rem; }
  .app-shell :is(.surface-card, .admin-data-card).p-4 { padding: 1.25rem !important; }
  .app-shell .table-responsive { overflow-x: auto; }
  .app-shell .dataTables_wrapper .row { row-gap: .75rem; }
  .app-shell .filter-bar > div { max-width: 100%; flex-wrap: wrap; }
  .app-shell .filter-bar .form-select { min-width: 0 !important; max-width: 100%; }
  .auth-card .card-header { padding: 1.5rem 1.5rem 1.25rem; }
  .auth-card .card-body { padding: 0 1.5rem 1.5rem; }
}
@media print {
  .studio-header, .studio-breadcrumbs, .skip-link { display: none !important; }
}

/* Keep secondary page actions available without crowding the main task. */
.app-shell .admin-hero-card:has(.studio-tools) { overflow: visible; z-index: 2; }
.studio-page-actions { flex-shrink: 0; }
.studio-tools { position: relative; }
.studio-tools > summary { list-style: none; }
.studio-tools > summary::-webkit-details-marker { display: none; }
.studio-tools > summary span { margin-left: .5rem; }
.studio-tools-menu { position: absolute; top: calc(100% + .5rem); right: 0; width: 240px; padding: .5rem; border: 1px solid #dfe5ed; border-radius: 10px; background: #fff; box-shadow: 0 8px 24px rgb(15 23 42 / 12%); z-index: 10; }
.app-shell .studio-tools-menu .btn { width: 100%; text-align: left; border: 0; min-height: 44px; }
.app-shell .studio-tools-menu label:focus-within { outline: 3px solid #2563eb; outline-offset: -3px; }
.app-shell .col-12:has(> #cleanup-alert.d-none) { display: none; }
.app-shell .btn-outline-secondary:is(.active, [aria-pressed="true"]):not(:where(.preview-canvas *, .mwp-preview-wrap *)) { background: #eff4ff; color: #1d4ed8; border-color: #93b4ed; }
.builder-shell > main > section.surface-card:first-child { background: #fff; box-shadow: 0 2px 4px rgb(15 23 42 / 3%); }
.app-shell .mwp-modal-dialog { max-width: min(800px, calc(100vw - 2rem)); }
@media (max-width: 1199.98px) {
  .builder-shell .builder-layout > .builder-sidebar { width: 100%; max-width: none; flex-basis: 100%; }
}

.app-shell .mwp-block-label { border: 0; pointer-events: auto; min-height: 36px; }
.app-shell .mwp-preview-block:focus-within .mwp-block-label { opacity: 1; }
@media (hover: none) {
  .app-shell .mwp-block-label { opacity: 1; }
}

/* Searchable management lists: summaries first, settings on demand. */
.management-heading,
.management-list-heading { display: flex; align-items: center; justify-content: space-between; gap: 1.25rem; flex-wrap: wrap; }
.management-heading > .btn { flex-shrink: 0; }
.management-list-heading { margin-bottom: 1.25rem; }
.management-create { scroll-margin-top: 1rem; }
.management-create > summary,
.management-record > summary { list-style: none; cursor: pointer; }
.management-create > summary::-webkit-details-marker,
.management-record > summary::-webkit-details-marker { display: none; }
.management-create > summary { display: flex; justify-content: space-between; align-items: center; padding: 1.1rem 1.5rem; font-weight: 600; }
.management-expand { font-size: 1.4rem; line-height: 1; color: #526174; }
.management-create[open] > summary .management-expand { transform: rotate(45deg); }
.management-filters { display: flex; flex-wrap: wrap; align-items: end; gap: .75rem; padding: 1rem; margin-bottom: .75rem; background: #f8fafc; border: 1px solid #e2e8f0; border-radius: 10px; }
.management-filters > div { flex: 1 1 145px; min-width: 0; }
.management-filters > .management-search { flex: 2 1 240px; }
.management-filters .form-select { text-overflow: ellipsis; }
.management-records { display: grid; gap: .75rem; }
.management-record { border: 1px solid #dfe5ed; border-radius: 10px; background: #fff; min-width: 0; }
.management-record[open] { border-color: #b0c6e9; }
.management-record-summary { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 1rem; padding: 1rem 1.25rem; border-radius: 10px; }
.management-record-summary:hover { background: #f8fafc; }
.management-record-identity { display: flex; align-items: center; gap: .85rem; min-width: 0; flex: 1 1 240px; }
.management-record-identity > span:last-child { min-width: 0; overflow-wrap: anywhere; }
.management-record-identity strong { font-size: .95rem; }
.management-record-identity small { font-size: .8rem; margin-top: .2rem; }
.management-record-icon { display: grid; place-items: center; width: 38px; height: 38px; border-radius: 10px; background: #eff4ff; color: #1d4ed8; font-weight: 700; flex-shrink: 0; }
.management-record-meta { display: flex; align-items: center; flex-wrap: wrap; gap: .8rem; font-size: .8rem; }
.management-edit-label { color: #1d4ed8; font-weight: 600; white-space: nowrap; }
.management-chevron { display: inline-block; margin-left: .5rem; }
.management-record[open] > summary .management-chevron { transform: rotate(180deg); }
.management-status { display: inline-flex; align-items: center; gap: .35rem; font-size: .75rem; font-weight: 600; }
.management-status::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.management-status.is-active { color: #167044; }
.management-status.is-inactive { color: #596779; }
.management-detail-body { padding: 1.5rem; border-top: 1px solid #e2e8f0; }
.management-advanced { padding: 1rem; background: #f8fafc; border: 1px solid #e2e8f0; border-radius: 8px; }
.management-advanced > summary { font-size: .85rem; font-weight: 600; cursor: pointer; }
.management-form-actions { display: flex; align-items: center; flex-wrap: wrap; gap: .65rem; }
.management-danger-actions { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 1rem; padding-top: 1.25rem; border-top: 1px solid #e2e8f0; }
.management-danger-actions > p { flex: 1 1 260px; max-width: 680px; }
.management-empty { padding: 2.5rem 1rem; text-align: center; }
.assignment-picker { min-width: 0; }
.assignment-picker legend { float: none; width: auto; }
.assignment-toolbar { display: flex; align-items: center; flex-wrap: wrap; gap: .75rem; margin-bottom: .75rem; }
.assignment-toolbar .form-control { flex: 1 1 200px; max-width: 400px; }
.assignment-options { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 260px), 1fr)); gap: .5rem; max-height: 280px; overflow-y: auto; padding: .25rem; scrollbar-width: thin; }
.assignment-option { display: flex; align-items: start; gap: .65rem; padding: .8rem; border: 1px solid #dfe5ed; border-radius: 8px; font-size: .85rem; cursor: pointer; min-width: 0; }
.assignment-option:has(:checked) { background: #eff4ff; border-color: #9fbced; }
.assignment-option:focus-within { outline: 2px solid #2563eb; outline-offset: -2px; }
.assignment-option > span { min-width: 0; overflow-wrap: anywhere; }
.assignment-option .form-check-input { flex-shrink: 0; margin-top: .2rem; }
.management-page [hidden] { display: none !important; }
@media (max-width: 575.98px) {
  .management-record-summary { padding: 1rem; gap: .75rem; }
  .management-record-meta { width: 100%; justify-content: flex-start; }
  .management-edit-label { margin-left: auto; }
  .management-detail-body { padding: 1rem; }
  .management-create > summary { padding: 1rem; }
  .management-filters { padding: .75rem; }
  .assignment-toolbar .form-control { max-width: none; }
}
