:root {
  color-scheme: dark;
  --bg: #0a0b0f;
  --surface: #11131a;
  --surface-raised: #171a23;
  --line: #282c38;
  --line-soft: #1c202a;
  --text: #f2f4f8;
  --muted: #9198aa;
  --muted-strong: #b7bdca;
  --blue: #8294ff;
  --green: #66d9a4;
  --red: #ff7d87;
  --amber: #e4b765;
  --sidebar-width: 248px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
  background: var(--bg);
}

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-size: 1rem;
  line-height: 1.5;
}

button,
input {
  font: inherit;
}

a {
  color: inherit;
}

.shell {
  min-height: 100vh;
}

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 10;
  display: flex;
  width: var(--sidebar-width);
  flex-direction: column;
  padding: 28px 20px 22px;
  border-right: 1px solid var(--line-soft);
  background: #0d0f14;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--text);
  text-decoration: none;
}

.brand-mark {
  display: grid;
  width: 42px;
  height: 42px;
  flex: 0 0 42px;
  place-items: center;
  border: 1px solid #5e6ac2;
  border-radius: 12px;
  background: #20274b;
  color: #d9deff;
  font-size: 1.05rem;
  font-weight: 800;
  box-shadow: inset 0 0 0 4px #171b32;
}

.brand strong,
.brand small {
  display: block;
}

.brand strong {
  letter-spacing: -0.02em;
}

.brand small {
  margin-top: 1px;
  color: var(--muted);
  font-size: 0.78rem;
}

.sidebar-nav {
  display: grid;
  gap: 6px;
  margin-top: 52px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 42px;
  padding: 0 12px;
  border: 1px solid transparent;
  border-radius: 10px;
  color: var(--muted-strong);
  font-size: 0.9rem;
  text-decoration: none;
  transition: background 150ms ease, color 150ms ease, border-color 150ms ease;
}

.nav-item:hover,
.nav-item:focus-visible,
.nav-item.active {
  border-color: var(--line);
  background: #161923;
  color: var(--text);
  outline: none;
}

.nav-glyph {
  display: grid;
  width: 20px;
  place-items: center;
  color: var(--blue);
  font-size: 1.15rem;
}

.sidebar-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: auto;
  color: var(--muted);
  font-size: 0.78rem;
}

.quiet-button {
  padding: 5px 8px;
  border: 0;
  background: transparent;
  color: var(--muted-strong);
  cursor: pointer;
}

.quiet-button:hover {
  color: var(--text);
}

.content {
  width: min(1320px, calc(100% - var(--sidebar-width)));
  min-height: 100vh;
  margin-left: var(--sidebar-width);
  padding: 52px clamp(28px, 5vw, 76px) 80px;
}

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

.eyebrow {
  margin: 0 0 8px;
  color: var(--blue);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.14em;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: clamp(2.2rem, 5vw, 4.2rem);
  font-weight: 670;
  letter-spacing: -0.06em;
  line-height: 0.96;
}

.refresh-button,
.login-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  min-height: 42px;
  padding: 0 16px;
  border: 1px solid #3a4050;
  border-radius: 10px;
  background: var(--surface-raised);
  color: var(--text);
  font-size: 0.9rem;
  font-weight: 650;
  cursor: pointer;
  transition: transform 150ms ease, border-color 150ms ease, background 150ms ease;
}

.refresh-button:hover,
.refresh-button:focus-visible,
.login-button:hover,
.login-button:focus-visible {
  border-color: #6976cd;
  background: #20253a;
  outline: none;
  transform: translateY(-1px);
}

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

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

.summary {
  display: grid;
  grid-template-columns: minmax(260px, 1.5fr) repeat(3, minmax(100px, 0.5fr));
  margin-top: 38px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--surface);
}

.summary > div {
  min-height: 112px;
  padding: 22px 24px;
}

.summary > div + div {
  border-left: 1px solid var(--line);
}

.summary-primary,
.summary-metric {
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.summary-label,
.metric-label,
.summary-time {
  color: var(--muted);
  font-size: 0.8rem;
}

.summary-primary strong {
  margin: 3px 0;
  font-size: 1.1rem;
}

.metric-value {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 1.85rem;
  font-weight: 750;
  line-height: 1.1;
}

.online-text { color: var(--green); }
.offline-text { color: var(--red); }

.app-section {
  scroll-margin-top: 28px;
  margin-top: 46px;
}

.section-heading {
  display: flex;
  align-items: baseline;
  gap: 10px;
  margin-bottom: 16px;
}

.section-heading h2 {
  margin-bottom: 0;
  font-size: 1.05rem;
  font-weight: 650;
  letter-spacing: -0.015em;
}

.section-heading span {
  color: var(--muted);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.78rem;
}

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

.app-card {
  position: relative;
  display: flex;
  min-height: 226px;
  flex-direction: column;
  overflow: hidden;
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--surface);
  transition: border-color 160ms ease, background 160ms ease, transform 160ms ease;
}

.app-card::before {
  position: absolute;
  inset: 0 auto 0 0;
  width: 3px;
  background: var(--accent);
  content: "";
  opacity: 0.8;
}

.app-card:hover {
  border-color: #424858;
  background: #141721;
  transform: translateY(-2px);
}

.app-card-head,
.app-card-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.app-badge {
  display: grid;
  min-width: 42px;
  height: 36px;
  padding: 0 9px;
  place-items: center;
  border: 1px solid color-mix(in srgb, var(--accent) 58%, #222633);
  border-radius: 9px;
  background: color-mix(in srgb, var(--accent) 14%, #141720);
  color: color-mix(in srgb, var(--accent) 72%, white);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.73rem;
  font-weight: 800;
  letter-spacing: 0.05em;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: var(--muted-strong);
  font-size: 0.78rem;
}

.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--amber);
  box-shadow: 0 0 0 4px rgb(228 183 101 / 10%);
}

.app-card[data-state="online"] .status-dot {
  background: var(--green);
  box-shadow: 0 0 0 4px rgb(102 217 164 / 10%);
}

.app-card[data-state="offline"] .status-dot {
  background: var(--red);
  box-shadow: 0 0 0 4px rgb(255 125 135 / 10%);
}

.app-card[data-state="link"] .status-dot {
  background: var(--muted);
  box-shadow: none;
}

.app-copy {
  margin-top: 25px;
}

.app-copy h3 {
  margin-bottom: 7px;
  font-size: 1.25rem;
  letter-spacing: -0.025em;
}

.app-copy p {
  max-width: 46ch;
  margin-bottom: 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.app-card-foot {
  margin-top: auto;
  padding-top: 24px;
}

.status-detail {
  color: var(--muted);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.75rem;
}

.open-link {
  color: #d5d9e5;
  font-size: 0.86rem;
  font-weight: 650;
  text-decoration: none;
}

.open-link:hover,
.open-link:focus-visible {
  color: white;
  outline: none;
}

.empty-state {
  margin-top: 46px;
  padding: 60px 24px;
  border: 1px dashed var(--line);
  border-radius: 16px;
  color: var(--muted);
  text-align: center;
}

.empty-state .app-badge {
  width: 42px;
  margin: 0 auto 18px;
}

.empty-state h2 {
  margin-bottom: 6px;
  color: var(--text);
}

.empty-state code {
  color: var(--muted-strong);
}

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

.login-card {
  width: min(100%, 440px);
  padding: 30px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--surface);
  box-shadow: 0 30px 80px rgb(0 0 0 / 35%);
}

.login-brand {
  padding-bottom: 30px;
  border-bottom: 1px solid var(--line-soft);
}

.login-copy {
  margin-top: 34px;
}

.login-copy h1 {
  margin-bottom: 12px;
  font-size: 2.2rem;
}

.login-copy > p:last-child {
  color: var(--muted);
}

.login-form {
  display: grid;
  gap: 10px;
  margin-top: 28px;
}

.login-form label {
  color: var(--muted-strong);
  font-size: 0.86rem;
  font-weight: 650;
}

.login-form input {
  width: 100%;
  height: 46px;
  padding: 0 13px;
  border: 1px solid #343947;
  border-radius: 10px;
  background: #0d0f14;
  color: var(--text);
  outline: none;
}

.login-form input:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgb(130 148 255 / 14%);
}

.form-error {
  margin: 1px 0 0;
  color: var(--red);
  font-size: 0.86rem;
}

.login-button {
  width: 100%;
  margin-top: 8px;
  border-color: #6675d8;
  background: #5262c2;
}

@media (max-width: 880px) {
  .sidebar {
    position: static;
    width: auto;
    height: auto;
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    padding: 18px 22px;
    border-right: 0;
    border-bottom: 1px solid var(--line-soft);
  }

  .sidebar-nav {
    display: none;
  }

  .sidebar-foot {
    margin-top: 0;
    gap: 14px;
  }

  .content {
    width: 100%;
    margin-left: 0;
    padding: 38px 22px 60px;
  }

  .summary {
    grid-template-columns: repeat(3, 1fr);
  }

  .summary-primary {
    grid-column: 1 / -1;
    border-bottom: 1px solid var(--line);
  }

  .summary > div:nth-child(2) {
    border-left: 0;
  }
}

@media (max-width: 640px) {
  .brand small,
  .version {
    display: none;
  }

  .content {
    padding-inline: 16px;
  }

  .topbar {
    align-items: center;
  }

  h1 {
    font-size: 2.5rem;
  }

  .refresh-button {
    padding-inline: 12px;
  }

  .summary > div {
    min-height: 92px;
    padding: 18px;
  }

  .summary-primary {
    min-height: 104px !important;
  }

  .metric-value {
    font-size: 1.5rem;
  }

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

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