:root {
  color-scheme: light dark;
  --bg: #f8fafc;
  --fg: #111827;
  --muted: #64748b;
  --panel: rgba(255, 255, 255, 0.8);
  --panel-strong: rgba(255, 255, 255, 0.95);
  --border: rgba(15, 23, 42, 0.12);
  --shadow: 0 18px 55px rgba(15, 23, 42, 0.16);
  --accent: #0ea5e9;
  --good: #16a34a;
  --warn: #f59e0b;
  --bad: #dc2626;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #090b10;
    --fg: #f8fafc;
    --muted: #94a3b8;
    --panel: rgba(15, 23, 42, 0.72);
    --panel-strong: rgba(17, 24, 39, 0.94);
    --border: rgba(148, 163, 184, 0.18);
    --shadow: 0 24px 70px rgba(0, 0, 0, 0.36);
    --accent: #38bdf8;
  }
}

* {
  box-sizing: border-box;
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--fg);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background:
    linear-gradient(145deg, rgba(14, 165, 233, 0.22), transparent 38%),
    linear-gradient(315deg, rgba(249, 115, 22, 0.16), transparent 34%),
    linear-gradient(90deg, rgba(132, 204, 22, 0.12), rgba(217, 70, 239, 0.12)),
    var(--bg);
}

button,
a {
  font: inherit;
}

.shell {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 42px 0;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding-bottom: 26px;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  font-size: clamp(2.2rem, 8vw, 5.8rem);
  line-height: 0.9;
  letter-spacing: 0;
}

.refresh-button {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  min-height: 44px;
  padding: 0 16px;
  color: #ffffff;
  font-weight: 800;
  background: linear-gradient(135deg, #2563eb, #d946ef 48%, #f97316);
  border: 0;
  border-radius: 8px;
  box-shadow: 0 12px 28px rgba(37, 99, 235, 0.28);
  cursor: pointer;
  transition:
    transform 160ms ease,
    box-shadow 160ms ease,
    filter 160ms ease;
}

.refresh-button:hover {
  transform: translateY(-1px);
  box-shadow: 0 16px 34px rgba(217, 70, 239, 0.26);
}

.refresh-button:disabled {
  cursor: wait;
  filter: grayscale(0.4);
  opacity: 0.75;
}

.refresh-button.is-loading .refresh-icon {
  animation: spin 900ms linear infinite;
}

.status-line {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 38px;
  margin-bottom: 20px;
  color: var(--muted);
}

.status-dot {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: var(--warn);
  box-shadow: 0 0 0 5px rgba(245, 158, 11, 0.14);
}

.status-dot.good {
  background: var(--good);
  box-shadow: 0 0 0 5px rgba(22, 163, 74, 0.14);
}

.status-dot.bad {
  background: var(--bad);
  box-shadow: 0 0 0 5px rgba(220, 38, 38, 0.14);
}

.apps-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 14px;
}

.app-card {
  position: relative;
  display: grid;
  grid-template-columns: 48px 1fr;
  gap: 14px;
  min-height: 132px;
  padding: 18px;
  overflow: hidden;
  color: inherit;
  text-decoration: none;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
  transform: translateY(0);
  transition:
    transform 180ms ease,
    border-color 180ms ease,
    background 180ms ease;
}

.app-card:hover {
  transform: translateY(-3px);
  background: var(--panel-strong);
  border-color: color-mix(in srgb, var(--card-accent, var(--accent)) 56%, var(--border));
}

.app-glow {
  position: absolute;
  inset: auto -40px -50px auto;
  width: 130px;
  height: 130px;
  background: color-mix(in srgb, var(--card-accent, var(--accent)) 28%, transparent);
  border-radius: 999px;
  filter: blur(8px);
  opacity: 0.75;
  pointer-events: none;
}

.app-icon {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  color: #ffffff;
  font-size: 1.2rem;
  font-weight: 900;
  background: var(--card-accent, var(--accent));
  border-radius: 8px;
  box-shadow: 0 14px 24px color-mix(in srgb, var(--card-accent, var(--accent)) 32%, transparent);
}

.app-copy {
  min-width: 0;
}

.app-name {
  display: block;
  overflow-wrap: anywhere;
  font-size: 1.05rem;
}

.app-host {
  display: block;
  margin-top: 6px;
  overflow-wrap: anywhere;
  color: var(--muted);
  font-size: 0.88rem;
}

.app-types {
  align-self: end;
  grid-column: 1 / -1;
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 800;
  letter-spacing: 0.08em;
}

.empty-state {
  padding: 34px;
  background: var(--panel);
  border: 1px dashed var(--border);
  border-radius: 8px;
  backdrop-filter: blur(18px);
}

.empty-state h2 {
  margin: 0 0 8px;
}

.empty-state p {
  margin: 0;
  color: var(--muted);
}

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

@media (max-width: 620px) {
  .shell {
    width: min(100% - 22px, 1180px);
    padding: 24px 0;
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .refresh-button {
    width: 100%;
    justify-content: center;
  }

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

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 1ms !important;
    scroll-behavior: auto !important;
    transition-duration: 1ms !important;
  }
}
