.admin-shell {
  width: min(1180px, calc(100vw - 40px));
  margin: 0 auto;
  padding: 28px 0 52px;
}

.admin-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 20px;
}

.admin-heading h1 {
  margin: 4px 0 0;
  color: #10233d;
  font-size: clamp(2rem, 4vw, 3.5rem);
  line-height: 1;
  letter-spacing: 0;
}

.admin-heading-actions {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.admin-menu {
  position: relative;
}

.admin-menu-trigger {
  cursor: pointer;
  list-style: none;
}

.admin-menu-trigger::-webkit-details-marker {
  display: none;
}

.admin-menu-trigger::after {
  content: "";
  width: 8px;
  height: 8px;
  margin-left: 10px;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: translateY(-2px) rotate(45deg);
}

.admin-menu[open] .admin-menu-trigger::after {
  transform: translateY(2px) rotate(225deg);
}

.admin-menu-list {
  position: absolute;
  z-index: 20;
  right: 0;
  top: calc(100% + 8px);
  min-width: 210px;
  padding: 6px;
  border: 1px solid #d8e5f2;
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 16px 36px rgba(29, 72, 117, .16);
}

.admin-menu-item {
  display: block;
  padding: 10px 12px;
  border-radius: 6px;
  color: #29415f;
  font-size: 14px;
  font-weight: 800;
  text-decoration: none;
  white-space: nowrap;
}

button.admin-menu-item {
  width: 100%;
  border: 0;
  background: transparent;
  font-family: inherit;
  text-align: left;
  cursor: pointer;
}

.admin-menu-item:hover,
.admin-menu-item:focus-visible,
.admin-menu-item[aria-current="page"] {
  background: #eef6ff;
  color: #145ac9;
}

.admin-toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: #29415f;
  font-size: 14px;
  font-weight: 700;
  white-space: nowrap;
}

.admin-toggle input {
  width: 18px;
  height: 18px;
  accent-color: #145ac9;
}

.admin-stat-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin: 18px 0;
}

.admin-stat,
.admin-panel {
  border: 1px solid #d8e5f2;
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 10px 28px rgba(29, 72, 117, .08);
}

.admin-stat {
  padding: 16px;
}

.admin-stat span {
  display: block;
  color: #627b98;
  font-size: 13px;
  font-weight: 800;
  text-transform: uppercase;
}

.admin-stat strong {
  display: block;
  margin-top: 8px;
  color: #10233d;
  font-size: 2rem;
  line-height: 1;
}

.admin-panel {
  margin-top: 16px;
  overflow: hidden;
}

.admin-panel-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 18px;
  border-bottom: 1px solid #e2edf7;
}

.admin-panel-heading h2 {
  margin: 0;
  color: #10233d;
  font-size: 1.05rem;
  letter-spacing: 0;
}

.admin-range-buttons {
  display: inline-flex;
  overflow: hidden;
  border: 1px solid #cbdced;
  border-radius: 8px;
  background: #f7fbff;
}

.admin-range-buttons button {
  min-height: 34px;
  padding: 8px 12px;
  border: 0;
  border-left: 1px solid #cbdced;
  background: transparent;
  color: #315577;
  cursor: pointer;
  font: inherit;
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0;
}

.admin-range-buttons button:first-child {
  border-left: 0;
}

.admin-range-buttons button[aria-pressed="true"] {
  background: #12345c;
  color: #fff;
}

.admin-range-buttons button:hover {
  background: #e9f3ff;
}

.admin-range-buttons button[aria-pressed="true"]:hover {
  background: #12345c;
}

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

.admin-table-more {
  display: flex;
  justify-content: center;
  padding: 14px 18px;
  border-top: 1px solid #e2edf7;
}

.admin-table-more[hidden] {
  display: none;
}

.admin-day-link {
  padding: 0;
  border: 0;
  background: transparent;
  color: #145ac9;
  cursor: pointer;
  font: inherit;
  font-weight: 800;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.admin-report-heading p {
  margin: 4px 0 0;
  color: #627b98;
  font-size: 13px;
}

.admin-report-date-controls {
  display: flex;
  align-items: center;
  gap: 8px;
}

.admin-report-date-controls input {
  min-height: 40px;
  border: 1px solid #cbdced;
  border-radius: 8px;
  padding: 7px 10px;
  background: #fff;
  color: #173556;
  font: inherit;
}

.admin-report-note {
  margin: 16px 18px 0;
  padding: 12px 14px;
  border: 1px solid #e9c979;
  border-radius: 8px;
  background: #fff9e8;
  color: #694d08;
}

.admin-visitor-report > .admin-stat-grid {
  margin: 16px 18px;
  grid-template-columns: repeat(5, minmax(0, 1fr));
}

.admin-report-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  border-top: 1px solid #e2edf7;
}

.admin-report-grid > section {
  min-width: 0;
  border-right: 1px solid #e2edf7;
  border-bottom: 1px solid #e2edf7;
}

.admin-report-grid h3,
.admin-report-detail h3 {
  margin: 0;
  padding: 14px 18px;
  color: #173556;
  font-size: 15px;
}

.admin-report-detail {
  border-top: 1px solid #e2edf7;
}

.admin-report-review {
  background: #fff9e8;
}

.admin-report-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  min-width: 150px;
}

.admin-user-agent {
  max-width: 360px;
  white-space: normal;
  overflow-wrap: anywhere;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px;
}

@media (max-width: 900px) {
  .admin-visitor-report > .admin-stat-grid,
  .admin-report-grid {
    grid-template-columns: 1fr;
  }

  .admin-report-heading,
  .admin-report-date-controls {
    align-items: stretch;
  }

  .admin-report-date-controls {
    flex-wrap: wrap;
  }
}

.admin-popular-video {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  min-width: 0;
}

.admin-popular-video > div {
  min-width: 0;
}

.admin-table td.admin-popular-main,
.admin-popular-video a,
.admin-popular-video span {
  overflow-wrap: anywhere;
  white-space: normal;
}

.admin-popular-video img {
  width: 8rem;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  border-radius: 0.5rem;
}

.admin-popular-mobile-label {
  display: none;
}

.admin-popular-region-field {
  display: grid;
  gap: 4px;
  color: #627b98;
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.admin-popular-region-field select {
  min-height: 38px;
  padding: 7px 32px 7px 10px;
  border: 1px solid #cbdced;
  border-radius: 8px;
  background: #fff;
  color: #12233b;
  font: inherit;
  font-size: 14px;
  text-transform: none;
}

@media (max-width: 720px) {
  .admin-shell {
    width: min(100vw - 16px, 1180px);
  }

  .admin-popular-videos-wrap {
    overflow-x: visible;
  }

  .admin-table.admin-popular-videos-table,
  .admin-popular-videos-table tbody,
  .admin-popular-videos-table tr,
  .admin-table.admin-popular-videos-table td {
    display: block;
    width: 100%;
  }

  .admin-table.admin-popular-videos-table td[colspan] {
    grid-column: 1 / -1;
  }

  .admin-popular-videos-table thead {
    display: none;
  }

  .admin-popular-videos-table tbody {
    display: grid;
  }

  .admin-popular-videos-table tr {
    display: grid;
    grid-template-areas:
      "select rank status"
      "video video video"
      "details details details";
    grid-template-columns: auto auto minmax(0, 1fr);
    gap: 10px 12px;
    padding: 14px;
    border-top: 1px solid #e2edf7;
  }

  .admin-table.admin-popular-videos-table td {
    padding: 0;
    border: 0;
    white-space: normal;
  }

  .admin-popular-select {
    grid-area: select;
  }

  .admin-popular-rank {
    grid-area: rank;
    color: #627b98;
    font-size: 13px;
    font-weight: 800;
  }

  .admin-popular-main {
    grid-area: video;
    min-width: 0;
  }

  .admin-popular-details {
    grid-area: details;
    color: #627b98;
    line-height: 1.5;
  }

  .admin-popular-status {
    grid-area: status;
    justify-self: end;
    text-align: right;
  }

  .admin-popular-mobile-label {
    display: inline;
    margin-right: 4px;
  }

  .admin-popular-video {
    display: grid;
    grid-template-columns: 112px minmax(0, 1fr);
    min-width: 0;
    width: 100%;
  }

  .admin-popular-video img {
    width: 112px;
  }

  .admin-popular-video a,
  .admin-popular-video span {
    overflow-wrap: anywhere;
    white-space: normal;
  }

  #popular-videos-refresh,
  #popular-videos-queue {
    width: 100%;
    justify-content: center;
  }

  .admin-popular-heading-actions,
  .admin-popular-region-field,
  .admin-popular-region-field select {
    width: 100%;
  }

  #popular-videos-queue {
    margin-top: 14px;
  }
}

.admin-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.admin-table th,
.admin-table td {
  padding: 11px 18px;
  border-top: 1px solid #eef4fa;
  text-align: left;
  vertical-align: top;
  white-space: nowrap;
}

.admin-table th {
  color: #627b98;
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.admin-sort-header {
  min-height: 0;
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  cursor: pointer;
  font: inherit;
  font-weight: inherit;
  letter-spacing: 0;
  text-transform: inherit;
}

.admin-sort-header[aria-pressed="true"] {
  color: #12345c;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.admin-sort-header:hover {
  color: #12345c;
}

.admin-table td:first-child {
  white-space: normal;
}

.admin-table a {
  color: #12345c;
  font-weight: 800;
  text-decoration: none;
}

.admin-table a:hover {
  text-decoration: underline;
}

.admin-tool-jobs-table strong {
  color: #9f1d31;
}

.admin-status-badge {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 4px 9px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 800;
}

.admin-status-badge-ok {
  background: #e7f6ed;
  color: #17643b;
}

.admin-status-badge-warn {
  background: #fff4dc;
  color: #85520e;
}

.admin-form {
  display: grid;
  grid-template-columns: minmax(220px, 2fr) minmax(160px, 1fr) minmax(140px, 1fr) minmax(160px, 1fr) minmax(140px, 1fr) auto;
  gap: 12px;
  align-items: end;
  padding: 16px 18px;
  border-bottom: 1px solid #e2edf7;
}

.admin-form label {
  display: grid;
  gap: 6px;
  color: #29415f;
  font-size: 13px;
  font-weight: 800;
}

.admin-form input,
.admin-form select {
  width: 100%;
  min-height: 38px;
  border: 1px solid #cbdced;
  border-radius: 8px;
  background: #fff;
  color: #12233b;
  font: inherit;
  font-size: 14px;
  letter-spacing: 0;
  padding: 8px 10px;
}

.admin-retry-button {
  min-height: 34px;
  padding: 8px 12px;
  white-space: nowrap;
}

.admin-muted {
  color: #627b98;
  font-size: 12px;
}

.admin-inline-actions {
  display: inline-flex;
  gap: 8px;
  align-items: center;
}

.admin-inline-actions select {
  min-height: 34px;
  min-width: 112px;
  border: 1px solid #cbdced;
  border-radius: 8px;
  background: #fff;
  color: #12233b;
  font: inherit;
  font-size: 14px;
  letter-spacing: 0;
  padding: 6px 8px;
}

.admin-sync-videos {
  border-top: 1px solid #e2edf7;
}

.admin-playlist-sync-table span {
  color: #627b98;
  font-size: 12px;
}

.admin-sync-filter-editor {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
}

.admin-sync-filter-editor input,
.admin-sync-filter-editor select {
  min-height: 34px;
  width: 142px;
  border: 1px solid #cbdced;
  border-radius: 8px;
  color: #12233b;
  font: inherit;
  font-size: 13px;
  letter-spacing: 0;
  padding: 6px 8px;
}

@media (max-width: 720px) {
  .admin-heading {
    align-items: start;
    flex-direction: column;
  }

  .admin-heading-actions {
    justify-content: flex-start;
  }

  .admin-menu-list {
    left: 0;
    right: auto;
  }

  .admin-stat-grid {
    grid-template-columns: 1fr;
  }

  .admin-panel-heading {
    align-items: start;
    flex-direction: column;
  }

  .admin-form {
    grid-template-columns: 1fr;
  }
}

:root[data-theme="dark"] .admin-heading h1,
:root[data-theme="dark"] .admin-panel-heading h2,
:root[data-theme="dark"] .admin-stat strong {
  color: #f3f8ff;
}

:root[data-theme="dark"] .admin-toggle {
  color: #d9e6f5;
}

:root[data-theme="dark"] .admin-toggle input {
  accent-color: #8fc7ff;
}

:root[data-theme="dark"] .admin-menu-list {
  border-color: rgba(126, 179, 232, 0.24);
  background: #162334;
  box-shadow: 0 22px 64px rgba(0, 0, 0, 0.32);
}

:root[data-theme="dark"] .admin-menu-item {
  color: #d9e6f5;
}

:root[data-theme="dark"] .admin-menu-item:hover,
:root[data-theme="dark"] .admin-menu-item:focus-visible,
:root[data-theme="dark"] .admin-menu-item[aria-current="page"] {
  background: rgba(143, 199, 255, 0.14);
  color: #8fc7ff;
}

:root[data-theme="dark"] .admin-stat,
:root[data-theme="dark"] .admin-panel {
  border-color: rgba(126, 179, 232, 0.24);
  background: #162334;
  box-shadow: 0 22px 64px rgba(0, 0, 0, 0.32);
}

:root[data-theme="dark"] .admin-stat span,
:root[data-theme="dark"] .admin-table th {
  color: #a9b9cc;
}

:root[data-theme="dark"] .admin-panel-heading,
:root[data-theme="dark"] .admin-table-more,
:root[data-theme="dark"] .admin-form,
:root[data-theme="dark"] .admin-sync-videos,
:root[data-theme="dark"] .admin-table th,
:root[data-theme="dark"] .admin-table td {
  border-color: #2b4058;
}

:root[data-theme="dark"] .admin-table {
  color: #d9e6f5;
}

:root[data-theme="dark"] .admin-table tbody tr:hover {
  background: #1a2a3d;
}

:root[data-theme="dark"] .admin-table a {
  color: #8fc7ff;
}

:root[data-theme="dark"] .admin-table a:hover {
  color: #b8ddff;
}

:root[data-theme="dark"] .admin-sort-header[aria-pressed="true"],
:root[data-theme="dark"] .admin-sort-header:hover {
  color: #8fc7ff;
}

:root[data-theme="dark"] .admin-tool-jobs-table strong {
  color: #ff9aad;
}

:root[data-theme="dark"] .admin-form label,
:root[data-theme="dark"] .admin-playlist-sync-table span {
  color: #a9b9cc;
}

:root[data-theme="dark"] .admin-form input,
:root[data-theme="dark"] .admin-form select,
:root[data-theme="dark"] .admin-inline-actions select,
:root[data-theme="dark"] .admin-sync-filter-editor input,
:root[data-theme="dark"] .admin-sync-filter-editor select {
  border-color: #2b4058;
  background: #111d2b;
  color: #edf4ff;
}

:root[data-theme="dark"] .admin-muted {
  color: #a9b9cc;
}

:root[data-theme="dark"] .admin-range-buttons {
  border-color: #2b4058;
  background: #111d2b;
}

:root[data-theme="dark"] .admin-range-buttons button {
  border-color: #2b4058;
  color: #d9e6f5;
}

:root[data-theme="dark"] .admin-range-buttons button[aria-pressed="true"] {
  background: #8fc7ff;
  color: #10233d;
}

:root[data-theme="dark"] .admin-range-buttons button:hover {
  background: #22364d;
}

:root[data-theme="dark"] .admin-range-buttons button[aria-pressed="true"]:hover {
  background: #8fc7ff;
}
