:root {
  color-scheme: light;
  --bg: #f5f7fb;
  --panel: #ffffff;
  --text: #172033;
  --muted: #667085;
  --line: #d9e0ea;
  --accent: #1769aa;
  --accent-strong: #0f4f85;
  --danger: #b42318;
  --danger-bg: #fff1f0;
  --success: #067647;
  --success-bg: #ecfdf3;
  --shadow: 0 14px 34px rgba(29, 41, 57, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  display: grid;
  grid-template-columns: 320px minmax(0, 1fr);
  background: var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input,
textarea,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

button:disabled,
a[disabled] {
  cursor: not-allowed;
  opacity: 0.62;
}

.login-view {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 24px;
  background: #111827;
  color: #f8fafc;
}

.is-authenticated .login-view {
  display: none;
}

body:not(.is-authenticated) .sidebar,
body:not(.is-authenticated) .main,
body:not(.is-authenticated) .admin-shell,
body:not(.is-authenticated) .review-dialog {
  visibility: hidden;
}

.login-panel {
  width: min(420px, 100%);
  display: grid;
  gap: 18px;
  padding: 24px;
  border: 1px solid #344054;
  border-radius: 8px;
  background: #1f2937;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.28);
}

.login-panel input {
  border-color: #344054;
  background: #111827;
  color: #f8fafc;
}

.login-error {
  min-height: 18px;
  margin: 0;
  color: #fda29b;
  font-size: 13px;
  font-weight: 800;
}

.sidebar {
  min-height: 100vh;
  padding: 22px;
  background: #111827;
  color: #f8fafc;
  display: flex;
  flex-direction: column;
  gap: 22px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-mark {
  width: 44px;
  height: 44px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  background: #2f9e8f;
  font-weight: 800;
}

.brand h1,
.brand p,
.topbar h2,
.topbar p,
.stats p,
.empty-state h3,
.empty-state p {
  margin: 0;
}

.brand h1 {
  font-size: 18px;
}

.brand p {
  color: #aab4c4;
  font-size: 13px;
  margin-top: 2px;
}

.filters {
  display: grid;
  gap: 14px;
}

label {
  display: grid;
  gap: 7px;
  color: inherit;
  font-size: 13px;
  font-weight: 700;
}

input,
textarea,
select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  background: #fff;
  color: var(--text);
}

.sidebar input {
  border-color: #344054;
  background: #1f2937;
  color: #f8fafc;
}

.segment {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 1fr;
  gap: 4px;
  padding: 4px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.06);
}

.topbar .segment {
  min-width: 260px;
  border-color: var(--line);
  background: #eef3f8;
}

.segment button {
  min-height: 34px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: inherit;
  font-weight: 700;
  font-size: 13px;
}

.segment button.active {
  background: #fff;
  color: var(--accent-strong);
  box-shadow: 0 1px 3px rgba(16, 24, 40, 0.12);
}

.product-list {
  display: grid;
  gap: 7px;
  overflow: auto;
  padding-right: 4px;
}

.product-button {
  min-height: 50px;
  width: 100%;
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 10px;
  text-align: left;
  display: grid;
  gap: 3px;
  background: transparent;
  color: inherit;
}

.product-button:hover,
.product-button.active {
  background: #243244;
  border-color: #3d4f66;
}

.product-button strong {
  font-size: 14px;
}

.product-button span {
  color: #aab4c4;
  font-size: 12px;
}

.product-skeleton {
  min-height: 50px;
  border-radius: 8px;
  padding: 10px;
  background: #243244;
  display: grid;
  gap: 8px;
}

.product-skeleton span,
.product-skeleton small,
.skeleton-tile {
  position: relative;
  overflow: hidden;
}

.product-skeleton span,
.product-skeleton small {
  display: block;
  height: 12px;
  border-radius: 999px;
  background: #344054;
}

.product-skeleton span {
  width: 62%;
}

.product-skeleton small {
  width: 86%;
}

.product-skeleton span::after,
.product-skeleton small::after,
.skeleton-tile::after {
  position: absolute;
  inset: 0;
  content: "";
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.14), transparent);
  transform: translateX(-100%);
  animation: shimmer 1.2s infinite;
}

.main {
  min-width: 0;
  padding: 26px;
  display: grid;
  grid-template-rows: auto auto auto 1fr;
  gap: 18px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.eyebrow {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

.topbar h2 {
  margin-top: 3px;
  font-size: 28px;
}

.toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
}

.icon-button,
.primary,
.danger,
.close-button {
  min-height: 40px;
  border-radius: 8px;
  border: 1px solid var(--line);
  padding: 0 14px;
  background: #fff;
  color: var(--text);
  font-weight: 800;
}

.link-button {
  display: inline-grid;
  place-items: center;
  text-decoration: none;
}

.icon-button.is-loading,
.primary.is-loading,
.danger.is-loading {
  position: relative;
  padding-left: 34px;
}

.icon-button.is-loading::before,
.primary.is-loading::before,
.danger.is-loading::before {
  position: absolute;
  left: 12px;
  top: 50%;
  width: 14px;
  height: 14px;
  margin-top: -7px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 999px;
  content: "";
  animation: spin 0.8s linear infinite;
}

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

.danger {
  background: var(--danger-bg);
  color: var(--danger);
  border-color: #f4b8b1;
}

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

.stats div {
  min-height: 82px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.stats span {
  display: block;
  font-size: 24px;
  font-weight: 850;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.stats p {
  margin-top: 5px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.status-banner {
  padding: 12px 14px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--muted);
  font-weight: 700;
}

.status-banner.error {
  background: var(--danger-bg);
  border-color: #f4b8b1;
  color: var(--danger);
}

.status-banner a {
  color: inherit;
  font-weight: 850;
  text-decoration: underline;
}

.status-banner.success {
  background: var(--success-bg);
  border-color: #abefc6;
  color: var(--success);
}

.hidden {
  display: none;
}

.submission-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
  align-content: start;
  gap: 10px;
}

.submission-groups {
  display: grid;
  align-content: start;
  gap: 18px;
}

.submission-grid.empty {
  display: grid;
  place-items: center;
  min-height: 340px;
}

.package-group {
  display: grid;
  gap: 10px;
}

.package-group-header {
  min-height: 58px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.package-group-header h3,
.package-group-header p {
  margin: 0;
}

.package-group-header h3 {
  font-size: 16px;
  word-break: break-word;
}

.package-group-header p {
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.package-group-header span {
  min-width: 42px;
  min-height: 32px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: #eef3f8;
  color: var(--accent-strong);
  font-weight: 850;
}

.empty-state {
  text-align: center;
  max-width: 420px;
}

.empty-state h3 {
  font-size: 20px;
}

.empty-state p {
  margin-top: 8px;
  color: var(--muted);
}

.screenshot-tile {
  width: 100%;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  overflow: hidden;
  box-shadow: var(--shadow);
  transition: transform 120ms ease, box-shadow 120ms ease, border-color 120ms ease;
}

.screenshot-tile:disabled {
  transform: none;
}

.screenshot-tile:hover,
.screenshot-tile:focus-visible {
  border-color: var(--accent);
  box-shadow: 0 16px 38px rgba(23, 105, 170, 0.18);
  transform: translateY(-1px);
  outline: none;
}

.screenshot-tile img,
.image-missing {
  width: 100%;
  aspect-ratio: 9 / 16;
  display: block;
  object-fit: cover;
  background: #e7edf3;
}

.image-missing {
  display: grid;
  place-items: center;
  color: var(--muted);
  font-weight: 800;
}

.image-loading {
  position: relative;
  overflow: hidden;
}

.image-loading::after {
  position: absolute;
  inset: 0;
  content: "";
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.34), transparent);
  transform: translateX(-100%);
  animation: shimmer 1.2s infinite;
}

.skeleton-tile {
  aspect-ratio: 9 / 16;
  background: #dfe7f0;
}

.review-dialog {
  width: min(1120px, calc(100vw - 32px));
  border: 0;
  border-radius: 8px;
  padding: 0;
  box-shadow: 0 24px 60px rgba(16, 24, 40, 0.28);
}

.review-dialog::backdrop {
  background: rgba(12, 18, 30, 0.58);
}

.review-dialog form {
  margin: 0;
  padding: 18px;
  display: grid;
  gap: 16px;
}

.review-dialog header,
.review-dialog footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.review-dialog h3 {
  margin: 0;
}

.close-button {
  width: 38px;
  padding: 0;
}

.detail-layout {
  display: grid;
  grid-template-columns: minmax(280px, 1fr) 360px;
  gap: 16px;
  align-items: start;
}

.review-dialog img {
  width: 100%;
  max-height: 70vh;
  object-fit: contain;
  border-radius: 8px;
  background: #101828;
}

.detail-panel {
  display: grid;
  gap: 12px;
}

.review-dialog dl {
  margin: 0;
  display: grid;
  grid-template-columns: max-content minmax(0, 1fr);
  gap: 10px 14px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfe;
  color: var(--muted);
  font-size: 13px;
}

.review-dialog dt {
  font-weight: 850;
  color: var(--text);
}

.review-dialog dd {
  margin: 0;
  word-break: break-word;
}

.review-dialog dd span {
  display: block;
  margin-top: 2px;
  color: #8a94a6;
  font-size: 12px;
}

.review-dialog .rejected-count-label,
.review-dialog .rejected-count-value {
  align-self: center;
  padding: 10px 12px;
}

.review-dialog .rejected-count-label {
  border: 1px solid #fecdca;
  border-right: 0;
  border-radius: 8px 0 0 8px;
  text-transform: uppercase;
  letter-spacing: 0;
}

.review-dialog .rejected-count-value {
  border: 1px solid #fecdca;
  border-left: 0;
  border-radius: 0 8px 8px 0;
  font-size: 22px;
  font-weight: 900;
  line-height: 1;
}

.review-dialog .rejected-count-zero {
  color: var(--success);
  background: var(--success-bg);
  border-color: #abefc6;
}

.review-dialog .rejected-count-one {
  color: var(--accent-strong);
  background: #eff8ff;
  border-color: #b2ddff;
}

.review-dialog .rejected-count-two {
  color: var(--danger);
  background: var(--danger-bg);
  border-color: #fecdca;
}

.installed-app-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: var(--shadow);
}

.installed-app-card p,
.installed-app-card strong,
.installed-app-card span {
  display: block;
  margin: 0;
}

.installed-app-card p {
  color: var(--muted);
  font-size: 12px;
  font-weight: 850;
  text-transform: uppercase;
}

.installed-app-card strong {
  margin-top: 4px;
  font-size: 16px;
}

.installed-app-card span {
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
  word-break: break-word;
}

.app-link {
  flex: 0 0 auto;
  display: inline-grid;
  min-width: 96px;
  place-items: center;
  text-decoration: none;
}

.app-link:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.flappy-toggle {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 12;
  width: 52px;
  height: 52px;
  border: 1px solid #facc15;
  border-radius: 999px;
  background: #fef9c3;
  box-shadow: 0 16px 34px rgba(113, 63, 18, 0.2);
  font-size: 26px;
  line-height: 1;
}

.flappy-toggle:hover,
.flappy-toggle:focus-visible {
  outline: none;
  transform: translateY(-1px);
}

.flappy-panel {
  position: fixed;
  right: 22px;
  bottom: 86px;
  z-index: 13;
  width: min(352px, calc(100vw - 32px));
  padding: 14px;
  display: grid;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 24px 60px rgba(16, 24, 40, 0.24);
}

.flappy-panel.hidden {
  display: none;
}

.flappy-panel header,
.flappy-panel footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.flappy-panel strong {
  font-size: 15px;
}

.flappy-panel canvas {
  width: 100%;
  height: 420px;
  display: block;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #dff6ff;
  touch-action: none;
}

.flappy-panel footer span {
  min-width: 48px;
  color: var(--text);
  font-size: 24px;
  font-weight: 900;
}

.admin-page {
  display: block;
  background: var(--bg);
}

.admin-shell {
  width: min(1180px, calc(100vw - 40px));
  min-height: 100vh;
  margin: 0 auto;
  padding: 28px 0;
  display: grid;
  align-content: start;
  gap: 18px;
}

.admin-layout {
  display: grid;
  grid-template-columns: minmax(280px, 380px) minmax(0, 1fr);
  gap: 18px;
  align-items: start;
}

.admin-panel {
  display: grid;
  gap: 14px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.admin-panel header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.admin-panel h3 {
  margin: 0;
  font-size: 18px;
}

.data-list {
  display: grid;
  gap: 10px;
}

.data-row,
.empty-row {
  min-height: 58px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfe;
}

.data-row strong,
.data-row span {
  display: block;
}

.data-row span,
.empty-row {
  margin-top: 3px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.table-wrap {
  width: 100%;
  overflow: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 640px;
}

th,
td {
  padding: 12px 10px;
  border-bottom: 1px solid var(--line);
  text-align: left;
}

th {
  color: var(--muted);
  font-size: 12px;
  font-weight: 850;
  text-transform: uppercase;
}

td {
  font-size: 14px;
  font-weight: 700;
}

@keyframes shimmer {
  to {
    transform: translateX(100%);
  }
}

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

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

  .sidebar {
    min-height: auto;
  }

  .product-list {
    max-height: 260px;
  }

  .topbar,
  .toolbar {
    align-items: stretch;
    flex-direction: column;
  }

  .topbar .segment {
    min-width: 0;
  }

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

  .admin-shell {
    width: min(100% - 24px, 1180px);
  }

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

  .detail-layout {
    grid-template-columns: 1fr;
  }

  .installed-app-card {
    align-items: stretch;
    flex-direction: column;
  }

  .flappy-toggle {
    right: 16px;
    bottom: 16px;
  }

  .flappy-panel {
    right: 16px;
    bottom: 78px;
  }
}
