:root {
  --bg: #f3f5f4;
  --card: #ffffff;
  --ink: #17211e;
  --muted: #74807b;
  --line: #e1e6e3;
  --green: #138a5b;
  --green-soft: #e5f5ed;
  --blue: #4767d8;
  --blue-soft: #ebefff;
  --yellow: #d49221;
  --red: #d14c43;
}

* { box-sizing: border-box; }

body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  display: grid;
  place-items: center;
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
}

button { font: inherit; }

.shell {
  width: min(680px, calc(100% - 32px));
  margin: 32px auto;
}

header, footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

header {
  margin-bottom: 72px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 11px;
  color: var(--ink);
  text-decoration: none;
  letter-spacing: .16em;
  font-size: 13px;
}

.brand-icon, .menu-icon, .modal-icon {
  display: grid;
  place-items: center;
  border-radius: 12px;
}

.brand-icon {
  width: 36px;
  height: 36px;
  border: 1px solid var(--ink);
  border-radius: 50%;
  font-size: 13px;
}

.live {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
}

.live i, .menu-state i {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 0 4px rgba(19, 138, 91, .1);
}

.intro { margin-bottom: 28px; }

.intro p {
  margin: 0 0 10px;
  color: var(--green);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: .16em;
}

.intro h1 {
  margin: 0 0 9px;
  font-size: clamp(30px, 7vw, 44px);
  letter-spacing: -.045em;
}

.intro > span {
  color: var(--muted);
  font-size: 12px;
}

.menu-grid { display: grid; gap: 12px; }

.menu-card {
  width: 100%;
  min-height: 92px;
  display: grid;
  grid-template-columns: auto 1fr auto auto;
  align-items: center;
  gap: 16px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--card);
  color: var(--ink);
  cursor: pointer;
  text-align: left;
  box-shadow: 0 8px 28px rgba(28, 45, 38, .035);
  transition: transform .18s ease, border-color .18s ease, box-shadow .18s ease;
}

.menu-card:hover {
  transform: translateY(-2px);
  border-color: #cbd3cf;
  box-shadow: 0 14px 34px rgba(28, 45, 38, .07);
}

.menu-icon, .modal-icon {
  width: 48px;
  height: 48px;
  font-size: 16px;
}

.green { color: var(--green); background: var(--green-soft); }
.blue { color: var(--blue); background: var(--blue-soft); }

.menu-copy { display: flex; flex-direction: column; gap: 5px; }
.menu-copy strong { font-size: 16px; }
.menu-copy small { color: var(--muted); font-size: 11px; }

.menu-state {
  display: flex;
  align-items: center;
  gap: 7px;
  color: var(--green);
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: .08em;
}

.menu-state.is-error { color: var(--red); }
.menu-state.is-error i { background: var(--red); box-shadow: 0 0 0 4px rgba(209, 76, 67, .1); }
.menu-state b { font-weight: 800; }
.mini-metric { color: var(--blue); font-size: 13px; font-weight: 800; }
.arrow { color: #b2bbb7; font-size: 11px; }

.hint {
  margin: 17px 0 64px;
  color: var(--muted);
  font-size: 10px;
  text-align: center;
}

.hint i { margin-right: 5px; }

footer {
  padding-top: 18px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 10px;
}

footer button {
  padding: 8px 11px;
  border: 0;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 10px;
}

footer button:hover { color: var(--ink); }
footer button i { margin-right: 5px; }
footer button.is-loading i { animation: spin .8s linear infinite; }

.modal[hidden] { display: none; }

.modal {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: grid;
  place-items: center;
  padding: 20px;
}

.backdrop {
  position: absolute;
  inset: 0;
  background: rgba(19, 28, 25, .48);
  backdrop-filter: blur(4px);
  animation: fade-in .16s ease;
}

.modal-panel {
  position: relative;
  width: min(500px, 100%);
  max-height: min(680px, calc(100vh - 40px));
  overflow-y: auto;
  padding: 24px;
  border-radius: 20px;
  background: var(--card);
  box-shadow: 0 24px 80px rgba(14, 24, 20, .22);
  animation: pop-in .2s ease;
}

.modal-header, .modal-header > div {
  display: flex;
  align-items: center;
}

.modal-header {
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 24px;
}

.modal-header > div { gap: 13px; }
.modal-icon { width: 42px; height: 42px; }
.modal-header h2 { margin: 0 0 3px; font-size: 18px; }
.modal-header p { margin: 0; color: var(--muted); font-size: 10px; }

.close-button {
  width: 34px;
  height: 34px;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: white;
  color: var(--muted);
  cursor: pointer;
}

.close-button:hover { color: var(--ink); }

.app-list { display: grid; gap: 9px; }

.app-row {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 12px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
}

.app-row > i {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: 9px;
  background: #f3f5f4;
  font-size: 12px;
}

.app-row strong, .app-row small { display: block; }
.app-row strong { margin-bottom: 3px; font-size: 13px; }
.app-row small { color: var(--muted); font-size: 9px; }

.app-status {
  display: flex;
  align-items: center;
  gap: 7px;
  color: var(--green);
  font-size: 9px;
  font-weight: 800;
  text-transform: uppercase;
}

.app-status i {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: currentColor;
}

.app-status.is-degraded { color: var(--yellow); }
.app-status.is-offline { color: var(--red); }

.modal-updated {
  margin: 17px 0 0;
  color: var(--muted);
  font-size: 9px;
  text-align: center;
}

.metrics { display: grid; gap: 12px; }

.metric {
  padding: 17px;
  border: 1px solid var(--line);
  border-radius: 13px;
}

.metric-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
  font-size: 12px;
  font-weight: 700;
}

.metric-head strong { font-size: 20px; }

.progress {
  height: 8px;
  overflow: hidden;
  margin-bottom: 10px;
  border-radius: 999px;
  background: #edf0ee;
}

.progress i {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: var(--green);
  transition: width .35s ease;
}

.progress i.medium { background: var(--yellow); }
.progress i.high { background: var(--red); }
.metric small { color: var(--muted); font-size: 9px; }

.thresholds {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  margin: 18px 0;
  padding: 14px 0;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  font-size: 8px;
}

.thresholds span { display: flex; align-items: center; gap: 4px; }
.thresholds i { width: 7px; height: 7px; border-radius: 50%; }
.thresholds .low { background: var(--green); }
.thresholds .medium { background: var(--yellow); }
.thresholds .high { background: var(--red); }
.thresholds b { color: var(--ink); }

.server-meta { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

.server-meta span {
  display: flex;
  flex-direction: column;
  gap: 5px;
  padding: 13px;
  border-radius: 11px;
  background: #f5f7f6;
}

.server-meta small { color: var(--muted); font-size: 8px; letter-spacing: .08em; }
.server-meta b { font-size: 12px; }

body.modal-open { overflow: hidden; }

@keyframes spin { to { transform: rotate(360deg); } }
@keyframes fade-in { from { opacity: 0; } }
@keyframes pop-in { from { opacity: 0; transform: translateY(8px) scale(.98); } }

@media (max-width: 520px) {
  body { display: block; }
  .shell { margin: 22px auto; }
  header { margin-bottom: 64px; }
  .menu-card { grid-template-columns: auto 1fr auto; gap: 12px; }
  .menu-state, .mini-metric { grid-column: 2; justify-self: start; margin-top: -11px; }
  .arrow { grid-column: 3; grid-row: 1 / span 2; }
  .hint { margin-bottom: 48px; }
  .modal { align-items: end; padding: 0; }
  .modal-panel { width: 100%; max-height: 88vh; border-radius: 20px 20px 0 0; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    transition-duration: .01ms !important;
  }
}
