*,
*::before,
*::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: #0d1117;
  color: #e6edf3;
  min-height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;
}

#app {
  width: 100%;
  max-width: 1200px;
  padding: 2rem;
}

main {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 2rem;
  align-items: start;
}

header {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 1rem;
  margin-bottom: 2rem;
}

header h1 {
  font-size: 1.5rem;
  font-weight: 600;
  color: #e6edf3;
}

#page-title {
  display: block;
  margin-top: 0.25rem;
  color: #8b949e;
  font-size: 0.8rem;
}

#status {
  font-size: 0.85rem;
  padding: 0.3rem 0.75rem;
  border-radius: 999px;
  background: #21262d;
  color: #f85149;
  transition: background 0.3s, color 0.3s;
}

#status.connected {
  background: #238636;
  color: #fff;
}

#grid {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(5, 1fr);
}

#services {
  min-width: 0;
}

#services h2 {
  font-size: 1rem;
  font-weight: 600;
  color: #8b949e;
  margin-bottom: 0.75rem;
}

.service-group {
  margin-bottom: 1rem;
}

.service-group-title {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #8b949e;
  margin-bottom: 0.4rem;
}

.service-row {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.4rem 0.6rem;
  border-radius: 8px;
  background: #161b22;
  border: 1px solid #21262d;
  margin-bottom: 6px;
  font-size: 0.8rem;
}

.service-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
  background: #8b949e;
}

.service-dot.active {
  background: #3fb950;
  box-shadow: 0 0 6px rgba(63, 185, 80, 0.6);
}

.service-dot.failed,
.service-dot.inactive {
  background: #f85149;
}

.service-dot.activating,
.service-dot.deactivating,
.service-dot.reloading {
  background: #d29922;
}

.service-name {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.service-state {
  font-size: 0.7rem;
  color: #8b949e;
}

.service-link {
  font-size: 0.7rem;
  line-height: 1;
  padding: 0.2rem 0.45rem;
  border-radius: 6px;
  background: #21262d;
  color: #8b949e;
  text-decoration: none;
  transition: background 0.2s, color 0.2s;
}

.service-link:hover {
  background: #30363d;
  color: #e6edf3;
}

.service-link-public {
  background: rgba(31, 111, 235, 0.15);
  color: #58a6ff;
}

.service-link-public:hover {
  background: rgba(31, 111, 235, 0.3);
  color: #79c0ff;
}

.btn {
  aspect-ratio: 1;
  border-radius: 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  user-select: none;
  position: relative;
  transition: transform 0.1s, box-shadow 0.2s, background 0.3s;
  border: 2px solid #21262d;
  background: #161b22;
  outline: none;
}

.btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.4);
}

.btn:active {
  transform: translateY(0);
  box-shadow: none;
}

.btn.active {
  border-color: #facc15;
  box-shadow: 0 0 16px rgba(250, 204, 21, 0.3);
}

.btn-icon {
  width: 48px;
  height: 48px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.7rem;
  color: #fff;
  letter-spacing: 0.03em;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.6);
  text-align: center;
  white-space: pre-line;
}

.btn-label {
  margin-top: 6px;
  font-size: 0.7rem;
  color: #8b949e;
  text-align: center;
  line-height: 1.1;
  white-space: pre-line;
}

.btn-tooltip {
  display: none;
  position: absolute;
  bottom: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%);
  background: #1f242c;
  color: #e6edf3;
  font-size: 0.75rem;
  padding: 0.4rem 0.75rem;
  border-radius: 6px;
  white-space: nowrap;
  pointer-events: none;
  z-index: 10;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
}

.btn-tooltip::after {
  content: '';
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  border: 5px solid transparent;
  border-top-color: #1f242c;
}

.btn:hover .btn-tooltip {
  display: block;
}

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

@media (max-width: 560px) {
  #grid {
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
  }

  .btn-icon {
    width: 36px;
    height: 36px;
    font-size: 0.6rem;
  }
}

#login {
  position: fixed;
  inset: 0;
  display: flex;
  justify-content: center;
  align-items: center;
  background: #0d1117;
  z-index: 100;
}

#login[hidden] {
  display: none;
}

.login-box {
  width: 100%;
  max-width: 360px;
  padding: 0 1rem;
  text-align: center;
}

.login-box h1 {
  font-size: 1.5rem;
  font-weight: 600;
  margin-bottom: 0.5rem;
}

.login-box p {
  color: #8b949e;
  font-size: 0.9rem;
  margin-bottom: 1.5rem;
}

.login-box input {
  width: 100%;
  padding: 0.75rem 1rem;
  border-radius: 0.5rem;
  border: 1px solid #30363d;
  background: #161b22;
  color: #e6edf3;
  font-size: 1rem;
  margin-bottom: 1rem;
}

.login-error {
  display: none;
  color: #f85149;
  font-size: 0.85rem;
  margin-top: 0.75rem;
}

.login-box button {
  width: 100%;
  padding: 0.75rem;
  border: none;
  border-radius: 0.5rem;
  background: #238636;
  color: #ffffff;
  font-size: 1rem;
  cursor: pointer;
  transition: background 0.2s;
}

.login-box button:hover {
  background: #2ea043;
}
