:root {
  color-scheme: dark;
  font-family: "Inter", ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --bg0: #070b14;
  --bg1: #0c1220;
  --bg2: #111827;
  --surface: rgba(17, 24, 39, 0.72);
  --surface-strong: rgba(23, 32, 51, 0.92);
  --card: rgba(255, 255, 255, 0.04);
  --card-hover: rgba(255, 255, 255, 0.07);
  --text: #f8fafc;
  --muted: #94a3b8;
  --dim: #64748b;
  --border: rgba(148, 163, 184, 0.14);
  --border-strong: rgba(148, 163, 184, 0.24);
  --primary: #0D4FDC;
  --primary-soft: rgba(13, 79, 220, 0.16);
  --cta: #0D4FDC;
  --cta-hover: #0A3FB8;
  --brand: #0D4FDC;
  --brand-soft: rgba(13, 79, 220, 0.14);
  --success: #22c55e;
  --success-soft: rgba(34, 197, 94, 0.14);
  --warning: #f59e0b;
  --warning-soft: rgba(245, 158, 11, 0.14);
  --danger: #ef4444;
  --danger-soft: rgba(239, 68, 68, 0.14);
  --ios: #0ea5e9;
  --android: #22c55e;
  --shadow: 0 24px 80px rgba(0, 0, 0, 0.45);
  --radius: 16px;
  --radius-sm: 10px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  background:
    radial-gradient(1200px 600px at 10% -10%, rgba(13, 79, 220, 0.24), transparent 55%),
    radial-gradient(900px 500px at 90% 0%, rgba(14, 165, 233, 0.14), transparent 50%),
    radial-gradient(700px 400px at 50% 100%, rgba(34, 197, 94, 0.08), transparent 55%),
    linear-gradient(180deg, var(--bg0), var(--bg1) 40%, var(--bg2));
  background-attachment: fixed;
}

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

.shell {
  width: min(1360px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 28px 0 48px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 24px;
  padding: 18px 20px;
  border: 1px solid var(--border);
  border-radius: calc(var(--radius) + 4px);
  background: var(--surface);
  backdrop-filter: blur(18px);
  box-shadow: var(--shadow);
}

.brand, .topActions {
  display: flex;
  align-items: center;
  gap: 14px;
}

.topActions form { margin: 0; }

.brandLogo {
  width: 54px;
  height: 54px;
  flex: 0 0 auto;
  border-radius: 14px;
  box-shadow: 0 12px 32px rgba(13, 79, 220, 0.28);
  object-fit: cover;
}

.healthBadge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 36px;
  padding: 0 12px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: rgba(255,255,255,0.03);
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.healthBadge::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: var(--dim);
}

.healthBadge.ok {
  color: #bbf7d0;
  border-color: rgba(34, 197, 94, 0.25);
  background: var(--success-soft);
}

.healthBadge.ok::before { background: var(--success); }

.healthBadge.bad {
  color: #fecaca;
  border-color: rgba(239, 68, 68, 0.25);
  background: var(--danger-soft);
}

.healthBadge.bad::before { background: var(--danger); }

.eyebrow {
  margin: 0 0 4px;
  color: var(--dim);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .08em;
}

h1 {
  margin: 0;
  font-size: 28px;
  line-height: 1.1;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.subtitle {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 14px;
}

.button {
  min-height: 42px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: rgba(255,255,255,0.04);
  color: var(--text);
  padding: 9px 14px;
  cursor: pointer;
  font-weight: 700;
  transition: transform .15s ease, background .15s ease, border-color .15s ease;
}

.button:hover {
  background: rgba(255,255,255,0.08);
  transform: translateY(-1px);
}

.button:disabled {
  opacity: .55;
  cursor: not-allowed;
  transform: none;
}

.button.cta {
  border-color: rgba(13, 79, 220, 0.45);
  background: linear-gradient(135deg, var(--cta), #2563eb);
  color: #fff;
  box-shadow: 0 10px 30px rgba(13, 79, 220, 0.24);
}

.button.cta:hover { background: linear-gradient(135deg, var(--cta-hover), #1d4ed8); }

.button.ghost {
  background: transparent;
  border-color: var(--border);
}

.button.danger {
  border-color: rgba(239, 68, 68, 0.35);
  color: #fecaca;
  background: var(--danger-soft);
}

.button.sm {
  min-height: 34px;
  padding: 6px 10px;
  font-size: 13px;
}

.statsGrid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}

.statCard {
  position: relative;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  backdrop-filter: blur(16px);
  padding: 16px 18px;
  transition: transform .18s ease, border-color .18s ease;
}

.statCard:hover {
  transform: translateY(-2px);
  border-color: var(--border-strong);
}

.statCard::after {
  content: "";
  position: absolute;
  inset: auto -20px -20px auto;
  width: 80px;
  height: 80px;
  border-radius: 999px;
  background: var(--glow, rgba(59,130,246,0.12));
  filter: blur(8px);
}

.statLabel {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  margin-bottom: 8px;
}

.statValue {
  display: block;
  font-size: 30px;
  font-weight: 900;
  letter-spacing: -0.03em;
}

.statHint {
  display: block;
  margin-top: 4px;
  color: var(--dim);
  font-size: 12px;
}

.toolbar {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 12px;
  align-items: end;
  margin-bottom: 16px;
  padding: 16px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface);
  backdrop-filter: blur(16px);
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .04em;
}

select, input, textarea {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: rgba(2, 6, 23, 0.55);
  color: var(--text);
  padding: 0 12px;
  outline: 0;
}

textarea {
  min-height: 88px;
  padding: 10px 12px;
  resize: vertical;
}

select:focus, input:focus, textarea:focus {
  border-color: rgba(59, 130, 246, 0.65);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.16);
}

.tablePanel {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  backdrop-filter: blur(16px);
  overflow: hidden;
  box-shadow: var(--shadow);
}

.tableHead {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
}

.tableHead h2 {
  margin: 0;
  font-size: 16px;
  font-weight: 800;
}

.tableWrap { overflow-x: auto; }

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

th, td {
  padding: 14px 16px;
  text-align: left;
  border-bottom: 1px solid rgba(148, 163, 184, 0.08);
  vertical-align: middle;
}

th {
  color: var(--dim);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .06em;
  background: rgba(2, 6, 23, 0.35);
}

tbody tr {
  transition: background .15s ease;
}

tbody tr:hover { background: var(--card-hover); }
tr:last-child td { border-bottom: 0; }

.mono {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px;
}

.muted { color: var(--muted); }

.actions {
  display: flex;
  gap: 6px;
  justify-content: flex-end;
  align-items: center;
}

.iconBtn {
  display: inline-grid;
  place-items: center;
  width: 36px;
  height: 36px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: rgba(255,255,255,0.03);
  color: var(--muted);
  cursor: pointer;
  transition: background .15s ease, color .15s ease, border-color .15s ease;
}

.iconBtn:hover {
  color: var(--text);
  background: rgba(255,255,255,0.08);
  border-color: var(--border-strong);
}

.iconBtn svg {
  width: 18px;
  height: 18px;
}

.menuWrap {
  position: relative;
}

.actionMenu {
  position: absolute;
  right: 0;
  top: calc(100% + 6px);
  z-index: 20;
  min-width: 210px;
  padding: 6px;
  border: 1px solid var(--border-strong);
  border-radius: 12px;
  background: rgba(15, 23, 42, 0.98);
  box-shadow: var(--shadow);
}

.actionMenu[hidden] { display: none; }

.menuItem {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 38px;
  padding: 8px 10px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--text);
  text-align: left;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
}

.menuItem:hover { background: rgba(255,255,255,0.06); }

.menuItem svg {
  width: 16px;
  height: 16px;
  flex: 0 0 auto;
  opacity: .85;
}

.menuItem.danger { color: #fecaca; }
.menuItem.danger:hover { background: var(--danger-soft); }

.menuDivider {
  height: 1px;
  margin: 4px 6px;
  background: var(--border);
}

.quickRollout {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 6px;
}

.chipBtn {
  min-height: 32px;
  padding: 0 10px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: rgba(255,255,255,0.03);
  color: var(--muted);
  cursor: pointer;
  font-size: 12px;
  font-weight: 700;
}

.chipBtn:hover,
.chipBtn.active {
  color: #fff;
  border-color: rgba(226, 35, 26, 0.45);
  background: var(--brand-soft);
}

.bundleRow {
  cursor: pointer;
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 26px;
  border-radius: 999px;
  padding: 3px 10px;
  font-size: 12px;
  font-weight: 800;
  background: var(--primary-soft);
  color: #bfdbfe;
  border: 1px solid rgba(59, 130, 246, 0.22);
}

.pill.off {
  background: var(--danger-soft);
  color: #fecaca;
  border-color: rgba(239, 68, 68, 0.25);
}

.pill.success {
  background: var(--success-soft);
  color: #bbf7d0;
  border-color: rgba(34, 197, 94, 0.25);
}

.pill.warning {
  background: var(--warning-soft);
  color: #fde68a;
  border-color: rgba(245, 158, 11, 0.25);
}

.pill.ios {
  background: rgba(14, 165, 233, 0.14);
  color: #bae6fd;
  border-color: rgba(14, 165, 233, 0.25);
}

.pill.android {
  background: rgba(34, 197, 94, 0.14);
  color: #bbf7d0;
  border-color: rgba(34, 197, 94, 0.25);
}

.rolloutBar {
  width: 100%;
  max-width: 120px;
  height: 6px;
  border-radius: 999px;
  background: rgba(148, 163, 184, 0.18);
  overflow: hidden;
}

.rolloutBar span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #0D4FDC, #2563eb);
}

.downloadCount {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-weight: 800;
}

.downloadCount svg {
  width: 14px;
  height: 14px;
  opacity: .75;
}

.pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  border-top: 1px solid var(--border);
}

.paginationMeta {
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
}

.paginationActions {
  display: flex;
  gap: 8px;
}

.error, .empty {
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-bottom: 16px;
}

.error {
  background: var(--danger-soft);
  color: #fecaca;
  border: 1px solid rgba(239, 68, 68, 0.25);
}

.empty {
  background: var(--surface);
  color: var(--muted);
  border: 1px solid var(--border);
}

.footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 18px;
  color: var(--dim);
  font-size: 12px;
  font-weight: 600;
}

.modalOverlay {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(2, 6, 23, 0.72);
  backdrop-filter: blur(8px);
}

.modalOverlay[hidden] { display: none; }

.modal {
  width: min(720px, 100%);
  max-height: min(88vh, 900px);
  overflow: auto;
  border: 1px solid var(--border-strong);
  border-radius: calc(var(--radius) + 2px);
  background: var(--surface-strong);
  box-shadow: var(--shadow);
}

.modalHeader, .modalFooter {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--border);
}

.modalFooter {
  border-bottom: 0;
  border-top: 1px solid var(--border);
  justify-content: flex-end;
}

.modalBody {
  padding: 18px;
  display: grid;
  gap: 14px;
}

.modalTitle {
  margin: 0;
  font-size: 18px;
  font-weight: 800;
}

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

.detailGrid {
  display: grid;
  grid-template-columns: 160px 1fr;
  gap: 10px 14px;
  font-size: 14px;
}

.detailGrid dt {
  margin: 0;
  color: var(--dim);
  font-weight: 700;
}

.detailGrid dd {
  margin: 0;
  word-break: break-word;
}

.toastHost {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 60;
  display: grid;
  gap: 10px;
}

.toast {
  min-width: 260px;
  max-width: 420px;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid var(--border-strong);
  background: rgba(15, 23, 42, 0.96);
  box-shadow: var(--shadow);
  animation: toastIn .22s ease;
}

.toast.success { border-color: rgba(34, 197, 94, 0.35); }
.toast.error { border-color: rgba(239, 68, 68, 0.35); }

@keyframes toastIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.loginBody {
  background: var(--bg0);
}

.loginShell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.loginPanel {
  width: min(440px, 100%);
  border: 1px solid var(--border);
  border-radius: calc(var(--radius) + 4px);
  background: var(--surface-strong);
  backdrop-filter: blur(18px);
  padding: 30px;
  box-shadow: var(--shadow);
}

.loginPanel .brandLogo {
  width: 68px;
  height: 68px;
  margin-bottom: 18px;
}

.loginLead {
  margin: 10px 0 22px;
  color: var(--muted);
  line-height: 1.5;
}

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

.loginForm .button {
  width: 100%;
  margin-top: 4px;
}

.loginError {
  margin: -2px 0 0;
  color: #fecaca;
  font-size: 14px;
  font-weight: 700;
}

@media (max-width: 1100px) {
  .statsGrid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .toolbar { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 720px) {
  .shell { width: min(100vw - 20px, 1360px); padding-top: 18px; }
  .topbar { align-items: stretch; flex-direction: column; }
  .brand { align-items: flex-start; }
  .topActions { display: grid; grid-template-columns: 1fr 1fr; }
  h1 { font-size: 24px; }
  .statsGrid, .toolbar, .modalGrid { grid-template-columns: 1fr; }
  .detailGrid { grid-template-columns: 1fr; }
  .pagination { flex-direction: column; align-items: stretch; }
}
